- 25th January 2024: upgraded to JoeyNMT v2.3.0
- 12th January 2023: upgraded to JoeyNMT v2.2.0
- 26th December 2022: @IT にて、 「Python+Pytorch」と「JoeyNMT」で学ぶニューラル機械翻訳 の記事が電子書籍化されました。
- 4th September 2022: upgraded to JoeyNMT v2.1.0
🐨 Joey NMT framework is developed for educational purposes. It aims to be a clean and minimalistic code base to help novices find fast answers to the following questions.
- ❔ How to implement classic NMT architectures (RNN and Transformer) in PyTorch?
- ❔ What are the building blocks of these architectures and how do they interact?
- ❔ How to modify these blocks (e.g. deeper, wider, ...)?
- ❔ How to modify the training procedure (e.g. add a regularizer)?
In contrast to other NMT frameworks, we will not aim for the most recent features or speed through engineering or training tricks since this often goes in hand with an increase in code complexity and a decrease in readability. 👀
However, Joey NMT re-implements baselines from major publications.
Check out the detailed documentation 📚 and our paper. 📰
Joey NMT was initially developed and is maintained by Jasmijn Bastings (University of Amsterdam) and Julia Kreutzer (Heidelberg University), now both at Google Research. Mayumi Ohta at Fraunhofer Institute is continuing the legacy.
Welcome to our new contributors
Joey NMT implements the following features (aka the minimalist toolkit of NMT 🔧):
- Recurrent Encoder-Decoder with GRUs or LSTMs
- Transformer Encoder-Decoder
- Attention Types: MLP, Dot, Multi-Head, Bilinear
- Word-, BPE- and character-based tokenization
- BLEU, ChrF evaluation
- Beam search with length penalty and greedy decoding
- Customizable initialization
- Attention visualization
- Learning curve plotting
- Scoring hypotheses and references
- Multilingual translation with language tags
Joey NMT is built on PyTorch. Please make sure you have a compatible environment. We tested Joey NMT v2.3 with
- python 3.11
- torch 2.1.2
- cuda 12.1
⚠️ Warning When running on GPU you need to manually install the suitable PyTorch version for your CUDA version. For example, you can install PyTorch 2.1.2 with CUDA v12.1 as follows:python -m pip install --upgrade torch==2.1.2 --index-url https://download.pytorch.org/whl/cu121
You can install Joey NMT either A. via pip or B. from source.
python -m pip install joeynmt
git clone https://github.com/joeynmt/joeynmt.git # Clone this repository
cd joeynmt
python -m pip install -e . # Install Joey NMT and it's requirements
python -m unittest # Run the unit tests
📝 Info For Windows users, we recommend to check whether txt files (i.e.
test/data/toy/*
) have utf-8 encoding.
- introduced DistributedDataParallel.
- implemented language tags, see notebooks/torchhub.ipynb
- released a iwslt14 de-en-fr multilingual model (trained using DDP)
- special symbols definition refactoring
- configuration refactoring
- autocast refactoring
- bugfixes
- upgrade to python 3.11, torch 2.1.2
- documentation refactoring
previous releases
- compatibility with torch 1.13 tested
- torchhub introduced
- bugfixes, minor refactoring
- upgrade to python 3.10, torch 1.12
- replace Automated Mixed Precision from NVIDA's amp to Pytorch's amp package
- replace discord.py with pycord in the Discord Bot demo
- data iterator refactoring
- add wmt14 ende / deen benchmark trained on v2 from scratch
- add tokenizer tutorial
- minor bugfixes
- upgrade to python 3.9, torch 1.11
torchtext.legacy
dependencies are completely replaced bytorch.utils.data
joeynmt/tokenizers.py
: handles tokenization internally (also supports bpe-dropout!)joeynmt/datasets.py
: loads data from plaintext, tsv, and huggingface's datasetsscripts/build_vocab.py
: trains subwords, creates joint vocab- enhancement in decoding
- scoring with hypotheses or references
- repetition penalty, ngram blocker
- attention plots for transformers
- yapf, isort, flake8 introduced
- bugfixes, minor refactoring
⚠️ Warning The models trained with Joey NMT v1.x can be decoded with Joey NMT v2.0. But there is no guarantee that you can reproduce the same score as before.
- upgrade to sacrebleu 2.0, python 3.7, torch 1.8
- bugfixes
- upgrade to torchtext 0.9 (torchtext -> torchtext.legacy)
- n-best decoding
- demo colab notebook
- Multi-GPU support
- fp16 (half precision) support
See our documentation!
We provide several benchmark results here.
These models are available via torch hub API:
import torch
model = torch.hub.load('joeynmt/joeynmt', 'wmt14_ende')
translations = model.translate(["Hello world!"])
print(translations[0]) # ['Hallo Welt!']
Follow the tutorials in notebooks dir.
- quick start with joeynmt2 This quick start guide walks you step-by-step through the installation, data preparation, training, and evaluation.
- torch hub interface How to generate translation from a pretrained model
- tokenizer tutorial
- joeyS2T ASR tutorial
- demo notebook
- starter notebook Masakhane - Machine Translation for African Languages in masakhane-io
- joeynmt toy models Collection of Joey NMT scripts by @bricksdont
In order to keep the code clean and readable, we make use of:
- Style checks:
- Typing: Every function has documented input types.
- Docstrings: Every function, class and module has docstrings describing their purpose and usage.
- Unittests: Every module has unit tests, defined in
test/unit/
. - Documentation: Update documentation in
docs/source/
accordingly.
To ensure the repository stays clean, unittests and linters are triggered by github's
workflow on every push or pull request to main
branch. Before you create a pull request,
you can check the validity of your modifications with the following commands:
make test
make check
make -C docs clean html
Since this codebase is supposed to stay clean and minimalistic, contributions addressing the following are welcome:
- code correctness
- code cleanliness
- documentation quality
- speed or memory improvements
- resolving issues
- providing pre-trained models
Code extending the functionalities beyond the basics will most likely not end up in the main branch, but we're curious to learn what you used Joey NMT for.
Here we'll collect projects and repositories that are based on Joey NMT, so you can find inspiration and examples on how to modify and extend the code.
- 👂 JoeyS2T. Joey NMT is extended for Speech-to-Text tasks! Checkout the code and the EMNLP 2022 Paper.
- 🗯️ Discord Joey. This script demonstrates how to deploy Joey NMT models as a Chatbot on Discord. Code
- 🕸️ Masakhane Web. @CateGitau, @Kabongosalomon, @vukosim and team built a whole web translation platform for the African NMT models that Masakhane built with Joey NMT. The best is: it's completely open-source, so anyone can contribute new models or features. Try it out here, and check out the code.
- ⚙️ MutNMT. @sjarmero created a web application to train NMT: it lets the user train, inspect, evaluate and translate with Joey NMT --- perfect for NMT newbies! Code here. The tool was developed by Prompsit in the framework of the European project MultiTraiNMT.
- 🌟 Cantonese-Mandarin Translator. @evelynkyl trained different NMT models for translating between the low-resourced Cantonese and Mandarin, with the help of some cool parallel sentence mining tricks! Check out her work here.
- 📖 Russian-Belarusian Translator. @tsimafeip built a translator from Russian to Belarusian and adapted it to legal and medical domains. The code can be found here.
- 💪 Reinforcement Learning. @samuki implemented various policy gradient variants in Joey NMT: here's the code, could the logo be any more perfect? 💪 🐨
- ✋ Sign Language Translation. @neccam built a sign language translator that continuosly recognizes sign language and translates it. Check out the code and the CVPR 2020 paper!
- 🔤 @bpopeters built Possum-NMT for multilingual grapheme-to-phoneme transduction and morphologic inflection. Read their paper for SIGMORPHON 2020!
- 📷 Image Captioning. @pperle and @stdhd built an image captioning tool on top of Joey NMT, check out the code and the demo!
- 💡 Joey Toy Models. @bricksdont built a collection of scripts showing how to install Joey NMT, preprocess data, train and evaluate models. This is a great starting point for anyone who wants to run systematic experiments, tends to forget python calls, or doesn't like to run notebook cells!
- 🌍 African NMT. @jaderabbit started an initiative at the Indaba Deep Learning School 2019 to "put African NMT on the map". The goal is to build and collect NMT models for low-resource African languages. The Masakhane repository contains and explains all the code you need to train Joey NMT and points to data sources. It also contains benchmark models and configurations that members of Masakhane have built for various African languages. Furthermore, you might be interested in joining the Masakhane community if you're generally interested in low-resource NLP/NMT. Also see the EMNLP Findings paper.
- 💬 Slack Joey. Code to locally deploy a Joey NMT model as chat bot in a Slack workspace. It's a convenient way to probe your model without having to implement an API. And bad translations for chat messages can be very entertaining, too ;)
- 🌐 Flask Joey. @kevindegila built a flask interface to Joey, so you can deploy your trained model in a web app and query it in the browser.
- 👥 User Study. We evaluated the code quality of this repository by testing the understanding of novices through quiz questions. Find the details in Section 3 of the Joey NMT paper.
- 📝 Self-Regulated Interactive Seq2Seq Learning. Julia Kreutzer and Stefan Riezler. Published at ACL 2019. Paper and Code. This project augments the standard fully-supervised learning regime by weak and self-supervision for a better trade-off of quality and supervision costs in interactive NMT.
- 🐫 Hieroglyph Translation. Joey NMT was used to translate hieroglyphs in this IWSLT 2019 paper by Philipp Wiesenbach and Stefan Riezler. They gave Joey NMT multi-tasking abilities.
If you used Joey NMT for a project, publication or built some code on top of it, let us know and we'll link it here.
Please leave an issue if you have questions or issues with the code.
For general questions, email us at joeynmt <at> gmail.com
. 💌
If you use Joey NMT in a publication or thesis, please cite the following paper:
@inproceedings{kreutzer-etal-2019-joey,
title = "Joey {NMT}: A Minimalist {NMT} Toolkit for Novices",
author = "Kreutzer, Julia and
Bastings, Jasmijn and
Riezler, Stefan",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP): System Demonstrations",
month = nov,
year = "2019",
address = "Hong Kong, China",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/D19-3019",
doi = "10.18653/v1/D19-3019",
pages = "109--114",
}
Joeys are infant marsupials. 🐨