Views
No views yet
1import torch
2from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
3
4model_name = "cloghost/nllb-200-distilled-600M-hin-kang-v1"
5
6model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
7tokenizer = AutoTokenizer.from_pretrained(model_name)
8
9device = 0 if torch.cuda.is_available() else -1
10translator = pipeline(
11 "translation",
12 model=model,
13 tokenizer=tokenizer,
14 src_lang="hin_Deva",
15 tgt_lang="kang_Deva",
16 device=device
17)
18
19text = """मगर हिमाचली भाषा तो पहले से बोली जा रही है।
20लोग सदियों से ही इसके संग जी रहे हैं।
21पहाड़ी भाषा का इतिहास हिन्दी साहित्य के आदिकाल ,जिसे सिद्ध चारण काल के नाम से भी जानते हैं
22"""
23
24translation = translator(text)