Downloads · 30 days
13
9% of all-time downloads
luongmanhlinh/M2M100-Lo2Vi-Translation
M2M100-Lo2Vi-Translation is a translation model from luongmanhlinh. Use it when you need text moved from one language to another. The card lists the license as apache-2.0.
This model is a neural machine translation system for Lao ➜ Vietnamese, built from scratch using the architecture and configuration of Facebook's M2M100. It is specifically trained for low-resource translation tasks b…
Downloads · 30 days
13
9% of all-time downloads
All-time downloads
138
Public
Parameters
209M
838 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors836 MB · 100%
From the Hugging Face model README
This model is a neural machine translation system for Lao ➜ Vietnamese, built from scratch using the architecture and configuration of Facebook's M2M100. It is specifically trained for low-resource translation tasks between Lao and Vietnamese.
lo)vi)The model was trained on the VLSP 2023 Vietnamese-Lao parallel dataset, supplemented with synthetic translations generated using:
Full dataset details: Kaggle - Vietnamese-Lao Parallel Corpus
The model achieved a BLEU score of ~41 on the VLSP2023 test set, calculated using:
sacrebleuevaluate libraryBIG NOTE: The training data and the vocab are all lowercased 😃, so please lowercase your text before pass it into the tokenizer
To perform translation using this model with 🤗 Transformers:
from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = M2M100ForConditionalGeneration.from_pretrained("luongmanhlinh/M2M100-Lo2Vi-Translation").to(device)
tokenizer = M2M100Tokenizer.from_pretrained("luongmanhlinh/M2M100-Lo2Vi-Translation")
# Example input
src_lang = "lo"
tgt_lang = "vi"
text = "ເຈົ້າຊື່ຫຍັງ?" # Lao sentence
# Prepare input
text = text.lower()
tokenizer.src_lang = src_lang
inputs = tokenizer(text, return_tensors="pt", padding=False).to(device)
# Set decoder language
forced_bos_token_id = tokenizer.lang_code_to_id[tgt_lang]
decoder_start_token_id = tokenizer.lang_code_to_id[tgt_lang]
# Generate translation
outputs = model.generate(
**inputs,
forced_bos_token_id=forced_bos_token_id,
decoder_start_token_id=decoder_start_token_id,
num_beams=5,
early_stopping=True,
max_new_tokens=100,
)
# Decode translation
translation = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
print("Translation:", translation)