import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
deftranslate(text, source_lang, target_lang, model_name="TenzinGayche/nllb_600M_bi_boen_3"):
# Define flores codes
flores_codes = {
"Standard Tibetan": "bod_Tibt",
"English": "eng_Latn"
}
# Convert language names to flores codes
source = flores_codes[source_lang]
target = flores_codes[target_lang]
# Load model and tokenizer
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-600M")
# Check if a GPU is available and set device accordingly
device = 0if torch.cuda.is_available() else -1# Create translator pipeline
translator = pipeline('translation', model=model, tokenizer=tokenizer,
src_lang=source, tgt_lang=target, device=device)
# Perform translation
output = translator(text, max_length=400)
# Extract translated text
translated_text = output[0]['translation_text']
return translated_text
# Example usageif __name__ == "__main__":
input_text = "Hello, how are you?"
source_language = "English"
target_language = "Standard Tibetan"
result = translate(input_text, source_language, target_language)
print(f"Original: {input_text}")
print(f"Translated: {result}")
Runs of openpecha nllb_600M_bi_boen_3 on huggingface.co
48
Total runs
15
24-hour runs
14
3-day runs
17
7-day runs
4
30-day runs
More Information About nllb_600M_bi_boen_3 huggingface.co Model
nllb_600M_bi_boen_3 huggingface.co
nllb_600M_bi_boen_3 huggingface.co is an AI model on huggingface.co that provides nllb_600M_bi_boen_3's model effect (), which can be used instantly with this openpecha nllb_600M_bi_boen_3 model. huggingface.co supports a free trial of the nllb_600M_bi_boen_3 model, and also provides paid use of the nllb_600M_bi_boen_3. Support call nllb_600M_bi_boen_3 model through api, including Node.js, Python, http.
nllb_600M_bi_boen_3 huggingface.co is an online trial and call api platform, which integrates nllb_600M_bi_boen_3's modeling effects, including api services, and provides a free online trial of nllb_600M_bi_boen_3, you can try nllb_600M_bi_boen_3 online for free by clicking the link below.
openpecha nllb_600M_bi_boen_3 online free url in huggingface.co:
nllb_600M_bi_boen_3 is an open source model from GitHub that offers a free installation service, and any user can find nllb_600M_bi_boen_3 on GitHub to install. At the same time, huggingface.co provides the effect of nllb_600M_bi_boen_3 install, users can directly use nllb_600M_bi_boen_3 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
nllb_600M_bi_boen_3 install url in huggingface.co: