Downloads · 30 days
0
0% of all-time downloads
MothMalone/transformer-vi2en-v2
transformer-vi2en-v2 is a translation model from MothMalone. Use it when you need text moved from one language to another. The card lists the license as mit.
Improved Vi→En training with label smoothing and AdamW
Downloads · 30 days
0
0% of all-time downloads
All-time downloads
8
Public
Repo size
1 GB
Likes
0
Public
Click a slice to open those files.
.pt1 GB · 100%
From the Hugging Face model README
Improved Vi→En training with label smoothing and AdamW
This model is trained from scratch using the Transformer architecture for machine translation.
# Load model and translate
from src.models.transformer import Transformer
from src.inference.translator import Translator
from src.data.vocabulary import Vocabulary
import torch
# Load vocabularies
src_vocab = Vocabulary.load('src_vocab.json')
tgt_vocab = Vocabulary.load('tgt_vocab.json')
# Load model
model = Transformer(
src_vocab_size=len(src_vocab),
tgt_vocab_size=len(tgt_vocab),
d_model=512,
n_heads=8,
n_encoder_layers=6,
n_decoder_layers=6,
d_ff=2048,
dropout=0.1,
max_seq_length=512,
pad_idx=0
)
checkpoint = torch.load('best_model.pt')
model.load_state_dict(checkpoint['model_state_dict'])
# Create translator
translator = Translator(
model=model,
src_vocab=src_vocab,
tgt_vocab=tgt_vocab,
device='cuda',
decoding_method='beam',
beam_size=5
)
# Translate
vietnamese_text = "Xin chào, bạn khỏe không?"
translation = translator.translate(vietnamese_text)
print(translation)
@misc{nlp-transformer-mt,
author = {MothMalone},
title = {Transformer Machine Translation Vi-En},
year = {2025},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/MothMalone}}
}