|
from transformers import AutoTokenizer, AutoModelForCausalLM |
|
|
|
tokenizer = AutoTokenizer.from_pretrained("rudrashah/RLM-hinglish-translator") |
|
model = AutoModelForCausalLM.from_pretrained("rudrashah/RLM-hinglish-translator") |
|
|
|
text = "mere paas 100 rupaye hain" |
|
|
|
template = "Hinglish:\n{hi_en}\n\nEnglish:\n{en}" |
|
input_text = tokenizer(template.format(hi_en=text,en=""),return_tensors="pt") |
|
|
|
output = model.generate(**input_text, max_length=250) |
|
english = tokenizer.decode(output[0]) |
|
english = english.replace("<bos>","").replace("<eos>","") |
|
english = english[len(template.format(hi_en=text,en="")):] |
|
print(english.strip()) |