This repository contains a Neural Machine Translation (NMT) system implemented in PyTorch. It translates English to German using an LSTM-based Encoder-Decoder architecture.
The project explores two main architectures:
- Basic Encoder-Decoder LSTM: A standard Seq2Seq model with a bidirectional LSTM encoder and a unidirectional LSTM decoder.
- Encoder-Decoder with Attention: Enhances the basic model with an attention mechanism to improve translation quality for longer sequences.
The project uses the Multi30k dataset provided by torchtext.
- Source Language: English
- Target Language: German
- Vocabulary: Built using
spacytokenizers for both languages.
The models are evaluated using the BLEU score metric.
| Model Configuration | BLEU Score | Description |
|---|---|---|
| Basic LSTM | ~25.66 - 26.78 | Bidirectional Encoder, Greedy/Beam Search Decoding |
| LSTM + Attention | ~30.07 | Adds Attention mechanism, significantly improving performance |
- Python 3.1x
- PyTorch
- TorchText
- Spacy (with
en_core_web_smandde_core_news_smmodels) - NLTK (for BLEU score calculation)
- NumPy, Matplotlib, Seaborn, Tqdm
-
Install Dependencies:
pip install torch torchtext spacy nltk numpy matplotlib seaborn tqdm python -m spacy download en_core_web_sm python -m spacy download de_core_news_sm
-
Run the Notebooks:
nmt_encoder_decoder_lstm_basic_25.66.ipynb: Training and evaluation of the basic model with greedy decoding.nmt_encoder_decoder_lstm_atten.ipynb: Training and evaluation of the based and attention-based models with beam search.
nmt_encoder_decoder_lstm_basic_25.66.ipynb: Notebook for the basic LSTM model using greedy decoding.nmt_encoder_decoder_lstm_atten.ipynb: Notebook for the based and Attention-based LSTM model using beam search.Output model/: Directory containing saved model weights (.pthfiles).
Members: Huỳnh Thanh Tuấn
Members: Nguyễn Trọng Nghĩa
