Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- fa
|
4 |
+
- multilingual
|
5 |
+
thumbnail: "https://upload.wikimedia.org/wikipedia/commons/a/a2/Farsi.svg"
|
6 |
+
tags:
|
7 |
+
- machine-translation
|
8 |
+
- mt5
|
9 |
+
- persian
|
10 |
+
- farsi
|
11 |
+
license: "CC BY-NC-SA 4.0"
|
12 |
+
datasets:
|
13 |
+
- parsinlu
|
14 |
+
metrics:
|
15 |
+
- accuracy
|
16 |
+
---
|
17 |
+
|
18 |
+
# Machine Translation (ترجمهی ماشینی)
|
19 |
+
|
20 |
+
This is an mT5-based model for machine translation (English -> Persian).
|
21 |
+
Here is an example of how you can run this model:
|
22 |
+
|
23 |
+
```python
|
24 |
+
from transformers import MT5ForConditionalGeneration, MT5Tokenizer
|
25 |
+
|
26 |
+
model_size = "small"
|
27 |
+
model_name = f"persiannlp/mt5-{model_size}-parsinlu-translation_en_fa"
|
28 |
+
tokenizer = MT5Tokenizer.from_pretrained(model_name)
|
29 |
+
model = MT5ForConditionalGeneration.from_pretrained(model_name)
|
30 |
+
|
31 |
+
|
32 |
+
def run_model(input_string, **generator_args):
|
33 |
+
input_ids = tokenizer.encode(input_string, return_tensors="pt")
|
34 |
+
res = model.generate(input_ids, **generator_args)
|
35 |
+
output = tokenizer.batch_decode(res, skip_special_tokens=True)
|
36 |
+
print(output)
|
37 |
+
return output
|
38 |
+
|
39 |
+
|
40 |
+
run_model("Praise be to Allah, the Cherisher and Sustainer of the worlds;")
|
41 |
+
run_model("shrouds herself in white and walks penitentially disguised as brotherly love through factories and parliaments; offers help, but desires power;")
|
42 |
+
run_model("He thanked all fellow bloggers and organizations that showed support.")
|
43 |
+
run_model("Races are held between April and December at the Veliefendi Hippodrome near Bakerky, 15 km (9 miles) west of Istanbul.")
|
44 |
+
run_model("I want to pursue PhD in Computer Science about social network,what is the open problem in social networks?")
|
45 |
+
```
|
46 |
+
|
47 |
+
|
48 |
+
For more details, visit this page: https://github.com/persiannlp/parsinlu/
|