Skip to content

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Attention-is-all-you-need

This repository implements the original "Attention is all you need" paper from scratch, and explores the complete transformer architecture, implementing scaled dot product attention, multi-headed attention, etc. Furthermore, this work also applies the transformer architecture for the task of machine translation by training on the iwslt2017-en-de dataset, thus equipping the model for bidirectional English <---> German translation.

Model Training

The model was trained on the iwslt2017-en-de dataset for 20 epochs, with a learning rate of 1e-4.

Run the follwing command to train the model.

python train.py

Run the following command for inference.

python predict.py --source_sentence <src-sentence> --source_lang {en, de} --target_lang {en, de} --model_path <path-to-ckpt>

Kaggle Notebook Playground

Feel free to play around with the translations on this kaggle notebook!

Link to IPYNB

Results

Check out the results below. They are quite interesting - small sentences which are very common are translated accurately, but slightly larger sentences tend to get messed up or "lost in translation" by the model.

Given that this model was trained in a toy setting for only 20 epochs, without even a learning rate warm up or any other hyperparameter tuning, these results are expected.

Correct translation of a simple, common sentence
Figure 1: Correct translation of a simple, common sentence.

Another correct translation example
Figure 2: Another correct translation example.

Example where the model “loses” the meaning in a longer sentence
Figure 3: Example where the model “loses” the meaning in a longer sentence.

Citations

@inproceedings{vaswani2017attention, title={Attention is all you need}, author={Vaswani, Ashish and Shazeer, Noam and Parmar, Niki and Uszkoreit, Jakob and Jones, Llion and Gomez, Aidan N. and Kaiser, {\L}ukasz and Polosukhin, Illia}, booktitle={Advances in Neural Information Processing Systems}, volume={30}, year={2017} }

About

Bidirectional neural machine translator for English <--> German, built from scratch following the transformer architecture described in the paper "Attention is all you need".

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages