|
|
| --- |
| license: mit |
| language: |
| - en |
| - de |
| library_name: pytorch |
| pipeline_tag: translation |
| tags: |
| - pytorch |
| - rnn |
| - seq2seq |
| - machine-translation |
| - multi30k |
| datasets: |
| - bentrevett/multi30k |
| --- |
| |
| # Seq2Seq RNN Translator (English -> German) |
|
|
| A PyTorch Seq2Seq Encoder-Decoder RNN trained from scratch on the Multi30k dataset. |
|
|
| ## Model Details |
|
|
| - Architecture: Seq2Seq |
| - Framework: PyTorch |
| - Dataset: Multi30k (English -> German) |
| - Embedding Dimension: 128 |
| - Hidden Dimension: 256 |
|
|
| ## Training |
|
|
| - Optimizer: Adam |
| - Learning Rate: 1e-3 |
| - Loss: CrossEntropyLoss (ignore_index=PAD) |
| - Gradient Clipping: max_norm=1.0 |
| - Epochs: 50 |
| - Batch Size: 64 |
|
|
| ## Dataset |
|
|
| | Split | Samples | |
| |------|--------:| |
| | Train | 29,000 | |
| | Validation | 1,014 | |
| | Test | 1,000 | |
|
|
| ## Performance |
|
|
| | Metric | Value | |
| |------|------:| |
| | Train Loss | 3.63 | |
| | Validation Loss | 5.51 | |
| | Test Loss | 5.13 | |
| | BLEU | 2.29 | |
|
|
|  |
|
|
| ## Usage |
|
|
| ```python |
| # Load model |
| model = Seq2Seq(encoder, decoder, device) |
| |
| model.load_state_dict( |
| load_file("best_seq2seq_rnn.safetensors") |
| ) |
| |
| model.eval() |
| |
| # Inference |
| sentence = "A man is riding a bicycle." |
| |
| translation = translate_sentence( |
| sentence, |
| model |
| ) |
| |
| print(" ".join(translation)) |
| ``` |
|
|
| Author |
| Ankit Bari |
|
|
| GitHub: https://github.com/aijadugar |
| Hugging Face: https://huggingface.co/aijadugar |
|
|