wikimedia/wikipedia
Viewer • Updated • 61.6M • 336k • 1.78k
Adds the accents back to Vietnamese text typed without them:
toi di hoc o truong dai hoc -> tôi đi học ở trường đại học.
ViT5-base fine-tuned as a sequence-to-sequence model on 100,000 lowercase sentences from Vietnamese Wikipedia (1 epoch). A smaller model from the same project, a BiLSTM, runs right in your browser in the live demo.
| Model | Syllable accuracy | Sentence accuracy |
|---|---|---|
| Bigram + Viterbi baseline | 94.47% | 47.95% |
| Character BiLSTM, trained from scratch | 94.73% | 49.04% |
| This model | 95.43% | 55.35% |
Sentence accuracy is the share of sentences where every word is correct.
from transformers import AutoModelForSeq2SeqLM, PreTrainedTokenizerFast
tokenizer = PreTrainedTokenizerFast.from_pretrained("hao0256/vit5-vietnamese-diacritics")
model = AutoModelForSeq2SeqLM.from_pretrained("hao0256/vit5-vietnamese-diacritics")
inputs = tokenizer(["toi di hoc o truong dai hoc"], return_tensors="pt")
output = model.generate(**inputs, max_new_tokens=64)
print(tokenizer.decode(output[0], skip_special_tokens=True))
Notes:
PreTrainedTokenizerFast: with transformers 5, AutoTokenizer fails on ViT5's BPE tokenizer.app.py in the Space).Trained on Wikipedia, which is formal text: slang, abbreviations and chat-style text may work less well. Proper names are the hardest case, partly because the training text was lowercased.
Base model
VietAI/vit5-base