File size: 1,957 Bytes
a5e8aea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
language:
- vi
- vi
license: bsd-3-clause
base_model: facebook/mbart-large-50
tags:
- generated_from_trainer
metrics:
- bleu
model-index:
- name: PhoTextNormalization
  results:
  - task:
      name: Translation
      type: translation
    metrics:
    - name: Bleu
      type: bleu
      value: 88.8267
---

# PhoTextNormalization: Text normalization model for Vietnamese

PhoTextNormalization converts Vietnamese text from written to spoken form. For example, "Một tháng có 30 hoặc 31 ngày, riêng tháng 2 có 28 ngày." will be converted to "một tháng có ba mươi hoặc ba mươi mốt ngày, riêng tháng hai có hai tám ngày."

Details of the training can be found in our [ACL 2025 paper](https://arxiv.org/abs/2506.01322):

```bibtex
@inproceedings{vu2025zeroshottexttospeechvietnamese,
      title={Zero-Shot Text-to-Speech for Vietnamese}, 
      author={Thi Vu and Linh The Nguyen and Dat Quoc Nguyen},
      year={2025},
      booktitle={Proceedings of ACL},
}
```

## Usage
```python
import torch
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

device = "cuda:0" if torch.cuda.is_available() else "cpu"

model_name = "thivux/PhoTextNormalization"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name).to(device)

text = 'Một tháng có 30 hoặc 31 ngày, riêng tháng 2 có 28 ngày.'
inputs = tokenizer(text, return_tensors="pt", padding=True,
                    truncation=True, max_length=1024).to(device)

# Generate translations
with torch.no_grad():
    translated_tokens = model.generate(
        **inputs, max_length=1024, num_beams=5)

# Decode 
decoded_outputs = [tokenizer.decode(output, skip_special_tokens=True)
                    for output in translated_tokens]

# decoded_outputs: ['một tháng có ba mươi hoặc ba mươi mốt ngày, riêng tháng hai có hai tám ngày.']
print(f'decoded_outputs: {decoded_outputs}')
```