All Projects → pcyin → pytorch_basic_nmt

pcyin / pytorch_basic_nmt

Licence: other
A simple yet strong implementation of neural machine translation in pytorch

Programming Languages

python
139335 projects - #7 most used programming language
perl
6916 projects
shell
77523 projects

Projects that are alternatives of or similar to pytorch basic nmt

Neural-Machine-Translation
Several basic neural machine translation models implemented by PyTorch & TensorFlow
Stars: ✭ 29 (-56.06%)
Mutual labels:  neural-machine-translation, pytorch-implmention
Pytorch Seq2seq
Tutorials on implementing a few sequence-to-sequence (seq2seq) models with PyTorch and TorchText.
Stars: ✭ 3,418 (+5078.79%)
Mutual labels:  neural-machine-translation, pytorch-implmention
MT-Preparation
Machine Translation (MT) Preparation Scripts
Stars: ✭ 15 (-77.27%)
Mutual labels:  neural-machine-translation
SSAN
How Does Selective Mechanism Improve Self-attention Networks?
Stars: ✭ 18 (-72.73%)
Mutual labels:  neural-machine-translation
Data-Rejuvenation
Implementation of our paper "Data Rejuvenation: Exploiting Inactive Training Examples for Neural Machine Translation" in EMNLP-2020.
Stars: ✭ 18 (-72.73%)
Mutual labels:  neural-machine-translation
SharpPeleeNet
ImageNet pre-trained SharpPeleeNet can be used in real-time Semantic Segmentation/Objects Detection
Stars: ✭ 13 (-80.3%)
Mutual labels:  pytorch-implmention
transformer-slt
Sign Language Translation with Transformers (COLING'2020, ECCV'20 SLRTP Workshop)
Stars: ✭ 92 (+39.39%)
Mutual labels:  neural-machine-translation
parallel-corpora-tools
Tools for filtering and cleaning parallel and monolingual corpora for machine translation and other natural language processing tasks.
Stars: ✭ 35 (-46.97%)
Mutual labels:  neural-machine-translation
Attention-Visualization
Visualization for simple attention and Google's multi-head attention.
Stars: ✭ 54 (-18.18%)
Mutual labels:  neural-machine-translation
ABD-NMT
Code for "Asynchronous bidirectional decoding for neural machine translation" (AAAI, 2018)
Stars: ✭ 32 (-51.52%)
Mutual labels:  neural-machine-translation
transformer
Neutron: A pytorch based implementation of Transformer and its variants.
Stars: ✭ 60 (-9.09%)
Mutual labels:  neural-machine-translation
minimal-nmt
A minimal nmt example to serve as an seq2seq+attention reference.
Stars: ✭ 36 (-45.45%)
Mutual labels:  neural-machine-translation
dynmt-py
Neural machine translation implementation using dynet's python bindings
Stars: ✭ 17 (-74.24%)
Mutual labels:  neural-machine-translation
RNNSearch
An implementation of attention-based neural machine translation using Pytorch
Stars: ✭ 43 (-34.85%)
Mutual labels:  neural-machine-translation
sentencepiece-jni
Java JNI wrapper for SentencePiece: unsupervised text tokenizer for Neural Network-based text generation.
Stars: ✭ 26 (-60.61%)
Mutual labels:  neural-machine-translation
pytorch gan
Spectral Normalization and Projection Discriminator
Stars: ✭ 16 (-75.76%)
Mutual labels:  pytorch-implmention
open-solution-ship-detection
Open solution to the Airbus Ship Detection Challenge
Stars: ✭ 54 (-18.18%)
Mutual labels:  pytorch-implmention
NiuTrans.NMT
A Fast Neural Machine Translation System. It is developed in C++ and resorts to NiuTensor for fast tensor APIs.
Stars: ✭ 112 (+69.7%)
Mutual labels:  neural-machine-translation
EffNet
EffNet: AN EFFICIENT STRUCTURE FOR CONVOLUTIONAL NEURAL NETWORKS
Stars: ✭ 20 (-69.7%)
Mutual labels:  pytorch-implmention
Recurrent-Deep-Q-Learning
Solving POMDP using Recurrent networks
Stars: ✭ 52 (-21.21%)
Mutual labels:  pytorch-implmention

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

  • nmt.py: contains the neural machine translation model and training/testing code.
  • vocab.py: a script that extracts vocabulary from training data
  • util.py: 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:

wget http://www.cs.cmu.edu/~pengchey/iwslt2014_ende.zip
unzip iwslt2014_ende.zip

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., test.de-en.(de|en).

Environment

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

Usage

Each runnable script (nmt.py, vocab.py) 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 vocab.py \
    --train-src=data/train.de-en.de.wmixerprep \
    --train-tgt=data/train.de-en.en.wmixerprep \
    data/vocab.json

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/train.sh. 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.

License

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

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].