Downloads · 30 days
58
34% of all-time downloads
mavietduc/ViTay-translation
ViTay-translation is a translation model from mavietduc. Use it when you need text moved from one language to another. It is set up for pytorch. The card lists the license as mit.
This is the first public release of a Vietnamese-Tày translation model. Expect imperfections and feel free to report issues or suggest improvements so the model can better serve the Tày and Vietnamese communities.
Downloads · 30 days
58
34% of all-time downloads
All-time downloads
170
Public
Repo size
334 MB
Likes
1
Public
Click a slice to open those files.
.bin167 MB · 100%
From the Hugging Face model README
This is the first public release of a Vietnamese-Tày translation model. Expect imperfections and feel free to report issues or suggest improvements so the model can better serve the Tày and Vietnamese communities.
Model name: Vi-Tày Transformer
Description: First publicly released neural translation model for Vietnamese ↔ Tày
First release date: 12/11/2025
This repository provides a sequence-to-sequence Transformer model for bidirectional translation between Vietnamese (vi) and Tày (tyz), implemented in pure PyTorch with a SentencePiece tokenizer.
The model is intended for:
spm.modelvi - Vietnamesetyz - Tày (ISO 639-3: tyz)The code assumes the following key components are defined in model.py:
ModelConfigSeq2SeqTransformerPAD, BOS, EOS, LANG2IDgenerate method for sequence decodingTypical files you will see:
pytorch_model.bin - Model weights (PyTorch state_dict)config.json - Model configuration (hyperparameters, vocabulary size, etc.)spm.model - SentencePiece tokenizer modelmodel.py - Model architecture and utilitiesREADME.md - This fileimport json
import torch
import sentencepiece as spm
from model import ModelConfig, Seq2SeqTransformer, PAD, BOS, EOS, LANG2ID
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Load SentencePiece tokenizer
sp = spm.SentencePieceProcessor(model_file="spm.model")
# Load config
with open("config.json", "r", encoding="utf-8") as f:
cfg_dict = json.load(f)
cfg = ModelConfig(cfg_dict) # or ModelConfig(**cfg_dict) depending on implementation
# Create model & load weights
model = Seq2SeqTransformer(cfg)
state_dict = torch.load("pytorch_model.bin", map_location=device)
model.load_state_dict(state_dict)
model.to(device)
model.eval()
If you don’t already have a decoding helper, you can use:
def decode_ids(token_ids):
"""Decode a sequence of token IDs to text, removing special tokens."""
clean_ids = [tid for tid in token_ids if tid not in (PAD, BOS, EOS)]
return sp.decode(clean_ids)
@torch.inference_mode()
def translate_vi_to_tay(model, text_vi: str, max_len: int = 128, beam_size: int = 4):
model.eval()
# Encode Vietnamese sentence
src_ids = sp.encode(text_vi, out_type=int)
src_tensor = torch.tensor(src_ids, dtype=torch.long, device=device).unsqueeze(0) # [1, src_len]
# Generate Tày translation
out = model.generate(
src_tensor,
src_lang_id=LANG2ID["vi"],
tgt_lang_id=LANG2ID["tyz"],
bos_id=BOS,
eos_id=EOS,
beam_size=beam_size,
max_len=max_len,
)
# Assuming model.generate returns shape [1, T]
output_ids = out[0].tolist()
return decode_ids(output_ids)
example_vi = "À ơi em ngủ, ngủ say đi, đợi tý mẹ về."
print(translate_vi_to_tay(model, example_vi))
Example output:
Ừ hở noọng nòn, nòn đắc nòn pây, đợi tý me mà.
spm.modelmax_lenis set around 128 tokens (can be adjusted)Note: This is a high-level description only. Exact dataset details and statistics can be added here if/when they are released.
Tày is a low-resource and minority language. When using this model:
Issues / bugs: Please open an issue on the model's Hugging Face page or repository.
Contributions: Contributions (bug fixes, better examples, improved evaluation, or documentation for Tày) are very welcome. You can: