A simple yet strong implementation of neural machine translation in pytorch
Alternatives To Pytorch_basic_nmt
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Pytorch Cyclegan And Pix2pix19,434
9 days ago476otherPython
Image-to-Image Translation in PyTorch
9 days ago222Jupyter Notebook
State-of-the-Art Deep Learning scripts organized by models - easy to train and deploy with reproducible accuracy and performance on enterprise-grade infrastructure.
Attention Is All You Need Pytorch7,000
4 months ago69mitPython
A PyTorch implementation of the Transformer model in "Attention is All You Need".
Opennmt Py5,94827a day ago20September 14, 202129mitPython
Open Source Neural Machine Translation in PyTorch
Practical Pytorch4,272
2 years ago91mitJupyter Notebook
Go to - this repo is deprecated and no longer maintained
a year ago6mitPython
人像卡通化探索项目 (photo-to-cartoon translation project)
Contrastive Unpaired Translation1,729
4 months ago79otherPython
Contrastive unpaired image-to-image translation, faster and lighter training than cyclegan (ECCV 2020, in PyTorch)
220 days ago80May 05, 20222apache-2.0Python
Sequence-to-sequence framework with a focus on Neural Machine Translation based on PyTorch
Nlp Tutorial836
3 years ago6mitJupyter Notebook
A list of NLP(Natural Language Processing) tutorials
a month ago15otherPython
AttentionGAN for Unpaired Image-to-Image Translation & Multi-Domain Image-to-Image Translation
Alternatives To Pytorch_basic_nmt
Select To Compare

Alternative Project Comparisons

A Basic PyTorch Implementation of Attentional Neural Machine Translation

This is a basic implementation of attentional neural machine translation (Bahdanau et al., 2015, Luong et al., 2015) in Pytorch. It implements the model described in Luong et al., 2015, and supports label smoothing, beam-search decoding and random sampling. With 256-dimensional LSTM hidden size, it achieves 28.13 BLEU score on the IWSLT 2014 Germen-English dataset (Ranzato et al., 2015).

This codebase is used for instructional purposes in Stanford CS224N Nautral Language Processing with Deep Learning and CMU 11-731 Machine Translation and Sequence-to-Sequence Models.

File Structure

  • contains the neural machine translation model and training/testing code.
  • a script that extracts vocabulary from training data
  • contains utility/helper functions

Example Dataset

We provide a preprocessed version of the IWSLT 2014 German-English translation task used in (Ranzato et al., 2015) [script]. To download the dataset:


Running the script will extract adata/ folder which contains the IWSLT 2014 dataset. The dataset has 150K German-English training sentences. The data/ folder contains a copy of the public release of the dataset. Files with suffix *.wmixerprep are pre-processed versions of the dataset from Ranzato et al., 2015, with long sentences chopped and rared words replaced by a special <unk> token. You could use the pre-processed training files for training/developing (or come up with your own pre-processing strategy), but for testing you have to use the original version of testing files, ie.,|en).


The code is written in Python 3.6 using some supporting third-party libraries. We provided a conda environment to install Python 3.6 with required libraries. Simply run

conda env create -f environment.yml


Each runnable script (, is annotated using dotopt. Please refer to the source file for complete usage.

First, we extract a vocabulary file from the training data using the command:

python \
    --train-src=data/ \
    --train-tgt=data/ \

This generates a vocabulary file data/vocab.json. The script also has options to control the cutoff frequency and the size of generated vocabulary, which you may play with.

To start training and evaluation, simply run scripts/ After training and decoding, we call the official evaluation script multi-bleu.perl to compute the corpus-level BLEU score of the decoding results against the gold-standard.


This work is licensed under a Creative Commons Attribution 4.0 International License.

Popular Pytorch Projects
Popular Translation Projects
Popular Machine Learning Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Deep Learning
Natural Language Processing
Machine Translation
Neural Machine Translation