Update README.md
Browse filesAdded example usage. It SHOULD work
README.md
CHANGED
@@ -13,6 +13,23 @@ metrics:
|
|
13 |
|
14 |
This is a finetuning of a MarianMT pretrained on Chinese-English. The target language pair is Vietnamese-English.
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
### Training results
|
18 |
|
|
|
13 |
|
14 |
This is a finetuning of a MarianMT pretrained on Chinese-English. The target language pair is Vietnamese-English.
|
15 |
|
16 |
+
### Example
|
17 |
+
```
|
18 |
+
%%capture
|
19 |
+
!pip install transformers transformers[sentencepiece]
|
20 |
+
|
21 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
22 |
+
# Download the pretrained model for English-Vietnamese available on the hub
|
23 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("CLAck/vi-en")
|
24 |
+
|
25 |
+
tokenizer = AutoTokenizer.from_pretrained("CLAck/vi-en")
|
26 |
+
|
27 |
+
sentence = your_vietnamese_sentence
|
28 |
+
# This token is needed to identify the source language
|
29 |
+
input_sentence = "<2vi> " + sentence
|
30 |
+
translated = model.generate(**tokenizer(input_sentence, return_tensors="pt", padding=True))
|
31 |
+
output_sentence = [tokenizer.decode(t, skip_special_tokens=True) for t in translated]
|
32 |
+
```
|
33 |
|
34 |
### Training results
|
35 |
|