Nmt Keras

Neural Machine Translation with Keras
Alternatives To Nmt Keras
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Keras Docs Zh705
3 years ago12
Chinese (zh-cn) translation of the Keras documentation.
Keras Attention656
5 years ago22agpl-3.0Python
Visualizing RNNs using the attention mechanism
Nmt Keras514
3 years ago4mitPython
Neural Machine Translation with Keras
Keras Transformer3121332 years ago39January 22, 2022mitPython
Transformer implemented in Keras
5 months ago32Jupyter Notebook
전 세계의 멋진 케라스 문서 및 튜토리얼을 한글화하여 케라스x코리아를 널리널리 이롭게합니다.
Cyclegan Keras115
4 years ago14gpl-3.0Python
Keras implementation of CycleGAN using a tensorflow backend.
Pix2pix Keras115
7 years ago4mitPython
Image-to-Image Translation with Conditional Adversarial Networks (Pix2pix) implementation in keras
Nlp Pretrained Model63
4 years agomit
A collection of Natural language processing pre-trained models.
Keras Docs Ja60
4 years ago2
Japanese translation of the Keras documentation.
Munit Keras55
5 years ago2mitJupyter Notebook
A keras (tensorflow) reimplementation of MUNIT: Multimodal Unsupervised Image-to-Image Translation https://arxiv.org/abs/1804.04732
Alternatives To Nmt Keras
Select To Compare

Alternative Project Comparisons


Documentation Build Status Open in colab Compatibility license

Neural Machine Translation with Keras.

Library documentation: nmt-keras.readthedocs.io

Attentional recurrent neural network NMT model

alt text

Transformer NMT model

alt text

Features (in addition to the full Keras cosmos): .


Assuming that you have pip installed and updated (>18), run:

git clone https://github.com/lvapeab/nmt-keras
cd nmt-keras
pip install -e .

for installing the library.


NMT-Keras requires the following libraries:

For accelerating the training and decoding on CUDA GPUs, you can optionally install:

For evaluating with additional metrics (Meteor, TER, etc), you can use the Coco-caption evaluation package and set METRICS='coco' in the config.py file. This package requires java (version 1.8.0 or newer).



  1. Set a training configuration in the config.py script. Each parameter is commented. See the documentation file for further info about each specific hyperparameter. You can also specify the parameters when calling the main.py script following the syntax Key=Value

  2. Train!:

python main.py


Once we have our model trained, we can translate new text using the sample_ensemble.py script. Please refer to the ensembling_tutorial for more details about this script. In short, if we want to use the models from the first three epochs to translate the examples/EuTrans/test.en file, just run:

 python sample_ensemble.py 
             --models trained_models/tutorial_model/epoch_1 \ 
                      trained_models/tutorial_model/epoch_2 \
             --dataset datasets/Dataset_tutorial_dataset.pkl \
             --text examples/EuTrans/test.en


The score.py script can be used to obtain the (-log)probabilities of a parallel corpus. Its syntax is the following:

python score.py --help
usage: Use several translation models for scoring source--target pairs
       [-h] -ds DATASET [-src SOURCE] [-trg TARGET] [-s SPLITS [SPLITS ...]]
       [-d DEST] [-v] [-c CONFIG] --models MODELS [MODELS ...]
optional arguments:
    -h, --help            show this help message and exit
    -ds DATASET, --dataset DATASET
                            Dataset instance with data
    -src SOURCE, --source SOURCE
                            Text file with source sentences
    -trg TARGET, --target TARGET
                            Text file with target sentences
    -s SPLITS [SPLITS ...], --splits SPLITS [SPLITS ...]
                            Splits to sample. Should be already includedinto the
                            dataset object.
    -d DEST, --dest DEST  File to save scores in
    -v, --verbose         Be verbose
    -c CONFIG, --config CONFIG
                            Config pkl for loading the model configuration. If not
                            specified, hyperparameters are read from config.py
    --models MODELS [MODELS ...]
                            path to the models

Advanced features

Other features such as online learning or interactive NMT protocols are implemented in the interactiveNMT branch.



If you use this toolkit in your research, please cite:

 journal = {The Prague Bulletin of Mathematical Linguistics},
 title = {{NMT-Keras: a Very Flexible Toolkit with a Focus on Interactive NMT and Online Learning}},
 author = {\'{A}lvaro Peris and Francisco Casacuberta},
 year = {2018},
 volume = {111},
 pages = {113--124},
 doi = {10.2478/pralin-2018-0010},
 issn = {0032-6585},
 url = {https://ufal.mff.cuni.cz/pbml/111/art-peris-casacuberta.pdf}

NMT-Keras was used in a number of papers:


Much of this library has been developed together with Marc Bolaños (web page) for other sequence-to-sequence problems.

To see other projects following the same philosophy and style of NMT-Keras, take a look to:

TMA: Egocentric captioning based on temporally-linked sequences.

VIBIKNet: Visual question answering.

ABiViRNet: Video description.

Sentence SelectioNN: Sentence classification and selection.

DeepQuest: State-of-the-art models for multi-level Quality Estimation.


The Theano backend is not tested anymore, although it should work. There is a known issue with the Theano backend. When running NMT-Keras, it will show the following message:

raise theano.gof.InconsistencyError("Trying to reintroduce a removed node")
InconsistencyError: Trying to reintroduce a removed node

It is not a critical error, the model keeps working and it is safe to ignore it. However, if you want the message to be gone, use the Theano flag optimizer_excluding=scanOp_pushout_output.


Álvaro Peris (web page): [email protected]

Popular Keras 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.
Machine Learning
Deep Learning
Sequence To Sequence
Machine Translation
Attention Mechanism
Online Learning
Attention Model
Neural Machine Translation