GithubHelp home page GithubHelp logo

nusnlp / neuqe Goto Github PK

View Code? Open in Web Editor NEW
49.0 3.0 11.0 227 KB

Neural quality estimation toolkit for grammatical error correction and other language generation applications.

License: GNU General Public License v3.0

Python 100.00%

neuqe's Introduction

NeuQE (Neural Quality Estimation)

Neural quality estimation toolkit which can be used for natural language generation tasks such as grammatical error correction, machine translation, simplification, and summarization.

The source code is repository was used in this paper: "Neural Quality Estimation Models for Grammatical Error Correction" (EMNLP 2018).

If you use this code for your work, please cite this paper:

@InProceedings{chollampatt2018neuqe,
    title = {Neural Quality Estimation of Grammatical Error Correction},
    authors = {Chollampatt, Shamil and Ng, Hwee Tou},
    booktitle = {Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing},
    month     = {November},
    year = {2018},
    address = {Brussels, Belgium}
}

Prerequisites

  • Python 3
  • PyTorch 0.3

Training

Pre-training the predictor model

To train the predictor models, use the script train_predictor.py. See the available options by using --help flag

For example, the CNN-based predictor for EMNLP-2018 GEC QE was trained using the following command:

 python train_predictor.py -train $TRAIN_PATH_PREFIX -valid $VALID_PATH_PREFIX -ssuf src -tsuf trg \
    -arch cnn -nsvocab 30000  -ntvocab 30000 \
    -nslayers 7 -ntlayers 7 -skwidth 3 -tkwidth 3 \
    -nhid 700 -nsembed 500 -ntembed 500 \
    -nepochs 10 -bsize 64 -lrate 1.0 -cnorm 5.0 -maxslen 50 -maxtlen 50 \
    -logafter 1000 -outdir $MODEL_OUT_DIR

For training the RNN-based predictor, the following command was used:

python train_predictor.py -train $TRAIN_PATH_PREFIX -valid $VALID_PATH_PREFIX -ssuf src -tsuf trg \
    -arch rnn -nsvocab 30000 -ntvocab 30000 \
    -nhid 700 -nsembed 500 -ntembed 500 \
    -nepochs 10 -bsize 64 -lrate 1.0 -cnorm 5.0 -maxslen 50 -maxtlen 50 \
    -logafter 1000 -outdir $MODEL_OUT_DIR

Training the estimator model

To train the estimator model, use the script train_estimator.py. See the available options by using the --help flag.

For training the estimator for EMNLP-2018 GEC QE model, the following command was used ($ARCH can be cnn or rnn):

python train_estimator.py \
    -train $QE_TRAIN_DATA_PATH_PREFIX \
    -valid $QE_VALID_DATA_PATH_PREFIX \
    -ssuf src -hsuf hyp -scoresuf $SCORE_SUFFIX \
    -pmodel $PRED_MODEL_PATH \
    -arch $ARCH -nhid 100 -qvectype pre  \
    -opt adam -lrate 0.0005 -bsize 32 -validbsize 1 -do 0.5 -nepochs 50 \
    -metrics pc mae rmse -outdir $EST_MODEL_OUT_DIR

The GEC system used for generating system hypotheses for training the EMNLP-2018 GEC QE system was a multilayer convolutional sequence-to-sequence model trained on Lang-8 (code). The downstream GEC system that was improved using QE scores also used the same underlying architecture with additional techniques described in the paper.

Testing

To test the estimator model, use the script test_predictor_estimator. An example is shown below:

python test_predictor_estimator.py \
    -test $QE_TEST_DATA_PATH_PREFIX \
    -ssuf src -hsuf hyp -scoresuf $SCORE_SUFFIX \
    -pemodel $PRED_MODEL_PATH $EST_MODEL_PATH -metrics pc rmse -outdir $OUT_DIR

If you want to use multiple estimators while testing, use multiple -pemodel flags specifying the paths to each predictor-estimator model pair.

Pre-trained Models

For downloading the pre-trained models used for quality estimation of grammatical error correction for EMNLP 2018 paper, run the download_models.sh script inside examples/gec_emnlp18/ directory.

License

The source code is licensed under GNU GPL 3.0 (see LICENSE) for non-commerical use. For commercial use of this code, separate commercial licensing is also available. Please contact:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.