Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language_details: "quy_Latn, spa_Latn"
|
3 |
+
pipeline_tag: translation
|
4 |
+
tags:
|
5 |
+
- nllb
|
6 |
+
license: "cc-by-nc-4.0"
|
7 |
+
inference: false
|
8 |
+
---
|
9 |
+
|
10 |
+
# Description
|
11 |
+
Finetuned [facebook/nllb-200-3.3B](https://huggingface.co/facebook/nllb-200-3.3B) model to translate between Spanish ("spa_Latn") and Mapuzungun ("quy_Latn").
|
12 |
+
|
13 |
+
# Example
|
14 |
+
```python
|
15 |
+
from transformers import NllbTokenizer, AutoModelForSeq2SeqLM
|
16 |
+
|
17 |
+
tokenizer = NllbTokenizer.from_pretrained("CenIA/nllb-200-3.3B-spa-arn", use_auth_token="HF_TOKEN")
|
18 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("CenIA/nllb-200-3.3B-spa-arn", use_auth_token="HF_TOKEN")
|
19 |
+
|
20 |
+
def translate(sentence: str, translate_from="spa_Latn", translate_to="quy_Latn") -> str:
|
21 |
+
tokenizer.src_lang = translate_from
|
22 |
+
tokenizer.tgt_lang = translate_to
|
23 |
+
|
24 |
+
inputs = tokenizer(sentence, return_tensors="pt")
|
25 |
+
result = model.generate(**inputs, forced_bos_token_id=tokenizer.lang_code_to_id[translate_to])
|
26 |
+
decoded = tokenizer.batch_decode(result, skip_special_tokens=True)[0]
|
27 |
+
|
28 |
+
return decoded
|
29 |
+
|
30 |
+
traduction = translate("Hola, 驴c贸mo est谩s?")
|
31 |
+
|
32 |
+
print(traduction)
|
33 |
+
```
|