Created
August 28, 2022 14:55
-
-
Save gamingflexer/d90b802b328334c69e62ac0ecaf207d4 to your computer and use it in GitHub Desktop.
NLLB FB 200 Language Translator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline | |
model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M") | |
tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-600M") | |
#for source and target lang check this - https://github.com/facebookresearch/flores/tree/main/flores200#languages-in-flores-200 | |
def translation(text,src_lang,tgt_lang): | |
translator = pipeline('translation', model=model, tokenizer=tokenizer, src_lang=src_lang, tgt_lang=tgt_lang, max_length = 400) | |
return translator(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment