Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- vi
|
4 |
+
|
5 |
+
tags:
|
6 |
+
- t5
|
7 |
+
- seq2seq
|
8 |
+
|
9 |
+
# Machine translation for vietnamese
|
10 |
+
## Model Description
|
11 |
+
T5-vi-en-base is a transformer model for vietnamese machine translation designed using T5 architecture.
|
12 |
+
## Training data
|
13 |
+
T5-vi-en-base was trained on 4M sentence pairs (english,vietnamese)
|
14 |
+
### How to use
|
15 |
+
|
16 |
+
```py
|
17 |
+
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
18 |
+
import torch
|
19 |
+
if torch.cuda.is_available():
|
20 |
+
device = torch.device("cuda")
|
21 |
+
|
22 |
+
print('There are %d GPU(s) available.' % torch.cuda.device_count())
|
23 |
+
|
24 |
+
print('We will use the GPU:', torch.cuda.get_device_name(0))
|
25 |
+
else:
|
26 |
+
print('No GPU available, using the CPU instead.')
|
27 |
+
device = torch.device("cpu")
|
28 |
+
|
29 |
+
model = T5ForConditionalGeneration.from_pretrained("NlpHUST/t5-vi-en-base")
|
30 |
+
tokenizer = T5Tokenizer.from_pretrained("NlpHUST/t5-vi-en-base")
|
31 |
+
model.to(device)
|
32 |
+
|
33 |
+
src = "Theo lãnh đạo Sở Y tế, 3 người này không có triệu chứng sốt, ho, khó thở, đã được lấy mẫu xét nghiệm và cách ly tập trung."
|
34 |
+
tokenized_text = tokenizer.encode(src, return_tensors="pt").to(device)
|
35 |
+
model.eval()
|
36 |
+
summary_ids = model.generate(
|
37 |
+
tokenized_text,
|
38 |
+
max_length=256,
|
39 |
+
num_beams=5,
|
40 |
+
repetition_penalty=2.5,
|
41 |
+
length_penalty=1.0,
|
42 |
+
early_stopping=True
|
43 |
+
)
|
44 |
+
output = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
45 |
+
print(output)
|
46 |
+
|
47 |
+
According to the head of the Department of Health, the three people had no symptoms of fever, cough, shortness of breath, were taken samples for testing and concentrated quarantine.
|
48 |
+
```
|