Downloads · 30 days
0
Hanish09/seq2seq-en-es
seq2seq-en-es is a machine learning model from Hanish09. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
A PyTorch implementation of a Sequence-to-Sequence model with Attention for English-Spanish translation.
Downloads · 30 days
0
Access
Public
Updated Jan 26, 2025
Repo size
625 MB
Likes
3
Public
Click a slice to open those files.
.pth625 MB · 100%
From the Hugging Face model README
A PyTorch implementation of a Sequence-to-Sequence model with Attention for English-Spanish translation.
The model consists of three main components:
Input → Encoder → Attention → Decoder → Translation
↑ ↑ ↑
Embeddings Context Attention Weights
git clone https://github.com/yourusername/nmt-attention.git
cd nmt-attention
pip install torch transformers datasets
python train.py
from translate import translate
text = "How are you?"
translated = translate(model, text, tokenizer)
print(translated)
# Loading a saved model
model = Seq2Seq(encoder, decoder, device)
model.load_state_dict(torch.load('LSTM_text_generator.pth'))
model.eval()
Training metrics after 10 epochs:
BATCH_SIZE = 32
LEARNING_RATE = 1e-3
CLIP = 1.0
N_EPOCHS = 10
ENC_EMB_DIM = 256
DEC_EMB_DIM = 256
ENC_HID_DIM = 512
DEC_HID_DIM = 512
Using the loresiensis/corpus-en-es dataset from Hugging Face Hub, which provides English-Spanish sentence pairs for training.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
⭐️ If you found this project helpful, please consider giving it a star!