Package: rxn-opennmt-py
OpenNMT-py: Open-Source Neural Machine TranslationThis is the RXN fork ofOpenNMT-py.It can be installed from Pypi with:pip install rxn-opennmt-pyLinks:GitHub repositoryPyPI packageOpenNMT-pyThis is aPytorchport ofOpenNMT,
an open-source (MIT) neural machine translation system. It is designed to be research friendly to try out new ideas in translation, summary, image-to-text, morphology, and many other domains. Some companies have proven the code to be production ready.We love contributions. Please consult the Issues page for anyContributions Welcometagged post.Before raising an issue, make sure you read the requirements and the documentation examples.Unless there is a bug, please use theForumorGitterto ask questions.Table of ContentsFull DocumentationRequirementsFeaturesQuickstartRun on FloydHubAcknowledgementsCitationRequirementsInstallOpenNMT-pyfrompip:pipinstallOpenNMT-pyor from the sources:gitclonehttps://github.com/OpenNMT/OpenNMT-py.gitcdOpenNMT-py
pythonsetup.pyinstallNote: If you have MemoryError in the install try to usepipwith--no-cache-dir.(Optionnal)some advanced features (e.g. working audio, image or pretrained models) requires extra packages, you can install it with:pipinstall-rrequirements.opt.txtNote:some features require Python 3.5 and after (eg: Distributed multigpu, entmax)we currently only support PyTorch 1.2 (should work with 1.1)FeaturesSeq2Seq models (encoder-decoder) with multiple RNN cells (lstm/gru) and attention (dotprod/mlp) typesTransformer models"Copy and Coverage AttentionPretrained EmbeddingsSource word featuresImage-to-text processingSpeech-to-text processingTensorBoard loggingMulti-GPU trainingData preprocessingInference (translation) with batching and beam searchInference time loss functions.[Conv2Conv convolution model]SRU "RNNs faster than CNN" paperMixed-precision training withAPEX, optimized onTensor CoresQuickstartFull DocumentationStep 1: Preprocess the dataonmt_preprocess-train_srcdata/src-train.txt-train_tgtdata/tgt-train.txt-valid_srcdata/src-val.txt-valid_tgtdata/tgt-val.txt-save_datadata/demoWe will be working with some example data indata/folder.The data consists of parallel source (src) and target (tgt) data containing one sentence per line with tokens separated by a space:src-train.txttgt-train.txtsrc-val.txttgt-val.txtValidation files are required and used to evaluate the convergence of the training. It usually contains no more than 5000 sentences.After running the preprocessing, the following files are generated:demo.train.pt: serialized PyTorch file containing training datademo.valid.pt: serialized PyTorch file containing validation datademo.vocab.pt: serialized PyTorch file containing vocabulary dataInternally the system never touches the words themselves, but uses these indices.Step 2: Train the modelonmt_train-datadata/demo-save_modeldemo-modelThe main train command is quite simple. Minimally it takes a data file
and a save file.  This will run the default model, which consists of a
2-layer LSTM with 500 hidden units on both the encoder/decoder.
If you want to train on GPU, you need to set, as an example:
CUDA_VISIBLE_DEVICES=1,3-world_size 2 -gpu_ranks 0 1to use (say) GPU 1 and 3 on this node only.
To know more about distributed training on single or multi nodes, read the FAQ section.Step 3: Translateonmt_translate-modeldemo-model_acc_XX.XX_ppl_XXX.XX_eX.pt-srcdata/src-test.txt-outputpred.txt-replace_unk-verboseNow you have a model which you can use to predict on new data. We do this by running beam search. This will output predictions intopred.txt.!!! note "Note"
The predictions are going to be quite terrible, as the demo dataset is small. Try running on some larger datasets! For example you can download millions of parallel sentences fortranslationorsummarization.Alternative: Run on FloydHubClick this button to open a Workspace onFloydHubfor training/testing your code.Pretrained embeddings (e.g. GloVe)Please see the FAQ:How to use GloVe pre-trained embeddings in OpenNMT-pyPretrained ModelsThe following pretrained models can be downloaded and used with translate.py.http://opennmt.net/Models-py/AcknowledgementsOpenNMT-py is run as a collaborative open-source project.
The original code was written byAdam Lerer(NYC) to reproduce OpenNMT-Lua using Pytorch.Major contributors are:Sasha Rush(Cambridge, MA)Vincent Nguyen(Ubiqus)Ben Peters(Lisbon)Sebastian Gehrmann(Harvard NLP)Yuntian Deng(Harvard NLP)Guillaume Klein(Systran)Paul Tardy(Ubiqus / Lium)François Hernandez(Ubiqus)Jianyu Zhan(Shanghai)
[Dylan Flaute](http://github.com/flauted(University of Dayton)
and more !OpentNMT-py belongs to the OpenNMT project along with OpenNMT-Lua and OpenNMT-tf.CitationOpenNMT: Neural Machine Translation ToolkitOpenNMT technical report@inproceedings{opennmt,
  author    = {Guillaume Klein and
               Yoon Kim and
               Yuntian Deng and
               Jean Senellart and
               Alexander M. Rush},
  title     = {Open{NMT}: Open-Source Toolkit for Neural Machine Translation},
  booktitle = {Proc. ACL},
  year      = {2017},
  url       = {https://doi.org/10.18653/v1/P17-4012},
  doi       = {10.18653/v1/P17-4012}
}