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
| #!/bin/bash | |
| # conda create -n 4.29 python==3.9 | |
| # source activate 4.29 | |
| # pip install transformers==4.29.2 | |
| # pip install torch accelerate sentencepiece tokenizers colorama sacremoses googletrans | |
| # conda create -n 4.34 python==3.9 | |
| # source activate 4.34 | |
| # pip install transformers==4.34 | |
| # pip install torch accelerate sentencepiece tokenizers colorama sacremoses googletrans |
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 AutoModelForSeq2SeqLM, AutoTokenizer | |
| >>> tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-moe-54b") | |
| >>> model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-moe-54b", device_map = "auto") | |
| >>> article = "Previously, Ring's CEO, Jamie Siminoff, remarked the company started when his doorbell wasn't audible from his shop in his garage." | |
| >>> inputs = tokenizer(article, return_tensors="pt") | |
| >>> translated_tokens = model.generate(**inputs, forced_bos_token_id=tokenizer.lang_code_to_id["fra_Latn"], max_length=50) | |
| >>> tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0] |
NewerOlder