| license: mit | |
| language: | |
| - en | |
| - de | |
| library_name: pytorch | |
| pipeline_tag: translation | |
| tags: | |
| - pytorch | |
| - gru | |
| - seq2seq | |
| - machine-translation | |
| - multi30k | |
| datasets: | |
| - bentrevett/multi30k | |
| # Seq2Seq GRU Translator (English -> German) | |
| A PyTorch Seq2Seq Encoder-Decoder GRU 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 | 0.87 | | |
| | Validation Loss | 5.19 | | |
| | Test Loss | 3.75 | | |
| | BLEU | 16.06 | | |
|  | |
| ## Usage | |
| ```python | |
| # Load model | |
| model = Seq2Seq(encoder, decoder, device) | |
| model.load_state_dict( | |
| load_file("best_seq2seq_gru.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 | |