All Projects → whr94621 → Njunmt Pytorch

whr94621 / Njunmt Pytorch

Licence: mit

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Njunmt Pytorch

Nmt Keras
Neural Machine Translation with Keras
Stars: ✭ 501 (+534.18%)
Mutual labels:  neural-machine-translation, nmt, attention-is-all-you-need
parallel-corpora-tools
Tools for filtering and cleaning parallel and monolingual corpora for machine translation and other natural language processing tasks.
Stars: ✭ 35 (-55.7%)
Mutual labels:  neural-machine-translation, nmt
Rnn Nmt
基于双向RNN,Attention机制的编解码神经机器翻译模型
Stars: ✭ 46 (-41.77%)
Mutual labels:  neural-machine-translation, nmt
Sockeye
Sequence-to-sequence framework with a focus on Neural Machine Translation based on Apache MXNet
Stars: ✭ 990 (+1153.16%)
Mutual labels:  neural-machine-translation, attention-is-all-you-need
Subword Nmt
Unsupervised Word Segmentation for Neural Machine Translation and Text Generation
Stars: ✭ 1,819 (+2202.53%)
Mutual labels:  neural-machine-translation, nmt
vat nmt
Implementation of "Effective Adversarial Regularization for Neural Machine Translation", ACL 2019
Stars: ✭ 22 (-72.15%)
Mutual labels:  neural-machine-translation, nmt
transformer
Neutron: A pytorch based implementation of Transformer and its variants.
Stars: ✭ 60 (-24.05%)
Mutual labels:  neural-machine-translation, attention-is-all-you-need
RNNSearch
An implementation of attention-based neural machine translation using Pytorch
Stars: ✭ 43 (-45.57%)
Mutual labels:  neural-machine-translation, nmt
Tf Seq2seq
Sequence to sequence learning using TensorFlow.
Stars: ✭ 387 (+389.87%)
Mutual labels:  neural-machine-translation, nmt
Nmtpytorch
Sequence-to-Sequence Framework in PyTorch
Stars: ✭ 392 (+396.2%)
Mutual labels:  neural-machine-translation, nmt
Neuralmonkey
An open-source tool for sequence learning in NLP built on TensorFlow.
Stars: ✭ 400 (+406.33%)
Mutual labels:  neural-machine-translation, nmt
Nmtpy
nmtpy is a Python framework based on dl4mt-tutorial to experiment with Neural Machine Translation pipelines.
Stars: ✭ 127 (+60.76%)
Mutual labels:  neural-machine-translation, nmt
Njunmt Tf
An open-source neural machine translation system developed by Natural Language Processing Group, Nanjing University.
Stars: ✭ 97 (+22.78%)
Mutual labels:  neural-machine-translation, nmt
Nematus
Open-Source Neural Machine Translation in Tensorflow
Stars: ✭ 730 (+824.05%)
Mutual labels:  neural-machine-translation, nmt
Nmt List
A list of Neural MT implementations
Stars: ✭ 359 (+354.43%)
Mutual labels:  neural-machine-translation, nmt
Joeynmt
Minimalist NMT for educational purposes
Stars: ✭ 420 (+431.65%)
Mutual labels:  neural-machine-translation, nmt
Xmunmt
An implementation of RNNsearch using TensorFlow
Stars: ✭ 69 (-12.66%)
Mutual labels:  neural-machine-translation, nmt
Marian
Fast Neural Machine Translation in C++
Stars: ✭ 777 (+883.54%)
Mutual labels:  neural-machine-translation
Machine Translation
Stars: ✭ 51 (-35.44%)
Mutual labels:  attention-is-all-you-need
Tensorflow Tutorial
TensorFlow and Deep Learning Tutorials
Stars: ✭ 748 (+846.84%)
Mutual labels:  neural-machine-translation

NJUNMT-pytorch


English, 中文

License: MIT Build Status

NJUNMT-pytorch is an open-source toolkit for neural machine translation. This toolkit is highly research-oriented, which contains some common baseline model:

  • DL4MT-tutorial: A rnn-base nmt model widely used as baseline. To our knowledge, this is the only pytorch implementation which is exactly the same as original model.(nmtpytorch is another pytorch implementation but with minor structure difference.)

  • Attention is all you need: A strong nmt model introduced by Google, which only relies on attenion mechanism.

Table of Contents

Requirements

  • python 3.5+
  • pytorch 0.4.0+
  • tqdm
  • tensorboardX
  • sacrebleu

Usage

0. Quick Start

We provide push-button scripts to setup training and inference of transformer model on NIST Chinese-English Corpus (only on NJUNLP's server). Just execute under root directory of this repo

bash ./scripts/train.sh

for training and

# 3 means decoding on NIST 2003. This value
# can also be 4,5,6, which represents NIST 2004, 2005, 2006 respectively. 
bash ./scripts/translate.sh 3 

1. Build Vocabulary

First we should generate vocabulary files for both source and target language. We provide a script in ./data/build_dictionary.py to build them in json format.

See how to use this script by running:

python ./scripts/build_dictionary.py --help

We highly recommend not to set the limitation of the number of words and control it by config files while training.

2. Write Configuration File

See examples in ./configs folder. We provide several examples:

  • dl4mt_nist_zh2en.yaml: to run a DL4MT model on NIST Chinese to Enligsh
  • transformer_nist_zh2en.yaml: to run a Transformer model on NIST Chinese to English
  • transformer_nist_zh2en_bpe.yaml: to run a Transformer model on NIST Chinese to English using BPE.
  • transformer_wmt14_en2de.yaml: to run a Transformer model on WMT14 English to German

To further learn how to configure a NMT training task, see this wiki page.

3. Training

We can setup a training task by running

export CUDA_VISIBLE_DEVICES=0
python -m src.bin.train \
    --model_name <your-model-name> \
    --reload \
    --config_path <your-config-path> \
    --log_path <your-log-path> \
    --saveto <path-to-save-checkpoints> \
    --valid_path <path-to-save-validation-translation> \
    --use_gpu

See detail options by running python -m src.bin.train --help.

During training, checkpoints and best models will be saved under the directory specified by option ---saveto. Suppose that the model name is "MyModel", there would be several files under that directory:

  • MyModel.ckpt: A text file recording names of all the kept checkpoints

  • MyModel.ckpt.xxxx: Checkpoint stored in step xxxx

  • MyModel.best: A text file recording names of all the kept best checkpoints

  • MyModel.best.xxxx: Best checkpoint stored in step xxxx.

  • MyModel.best.final: Final best model, i.e., the model achieved best performance on validation set. Only model parameters are kept in it.

4. Translation

When training is over, our code will automatically save the best model. Usually you could just use the final best model, which is named as xxxx.best.final, to translate. This model achieves the best performance on the validation set.

We can translation any text by running:

export CUDA_VISIBLE_DEVICES=0
python -m src.bin.translate \
    --model_name <your-model-name> \
    --source_path <path-to-source-text> \
    --model_path <path-to-model> \
    --config_path <path-to-configuration> \
    --batch_size <your-batch-size> \
    --beam_size <your-beam-size> \
    --alpha <your-length-penalty> \
    --use_gpu

See detail options by running python -m src.bin.translate --help.

Also our code support ensemble decoding. See more options by running python -m src.bin.ensemble_translate --help

Benchmark

See BENCHMARK.md

Contact

If you have any question, please contact [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].