Instructions to use CenIA/nllb-200-3.3B-spa-arn with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CenIA/nllb-200-3.3B-spa-arn with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("translation", model="CenIA/nllb-200-3.3B-spa-arn", device_map="auto")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("CenIA/nllb-200-3.3B-spa-arn") model = AutoModelForSeq2SeqLM.from_pretrained("CenIA/nllb-200-3.3B-spa-arn", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Description
Finetuned facebook/nllb-200-3.3B model to translate between Spanish ("spa_Latn") and Mapuzungún. We support the following languages/graphemaries:
- Spanish (spa_Latn)
- Azümchefe (quy_Latn)
- Ragileo (nso_Latn)
- Unificado (fra_Latn)
Example
from transformers import NllbTokenizerFast, AutoModelForSeq2SeqLM
tokenizer = NllbTokenizerFast.from_pretrained("CenIA/nllb-200-3.3B-spa-arn")
model = AutoModelForSeq2SeqLM.from_pretrained("CenIA/nllb-200-3.3B-spa-arn")
def translate(sentence: str, translate_from="spa_Latn", translate_to="quy_Latn") -> str:
tokenizer.src_lang = translate_from
tokenizer.tgt_lang = translate_to
inputs = tokenizer(sentence, return_tensors="pt")
result = model.generate(**inputs, forced_bos_token_id=tokenizer.convert_tokens_to_ids(translate_to))
decoded = tokenizer.batch_decode(result, skip_special_tokens=True)[0]
return decoded
traduction = translate("Hola, ¿cómo estás?")
print(traduction)
- Downloads last month
- 8