Views
No views yet
ogx786/urdu-roman-transliterator-tiny-aya. It was trained to convert Urdu-script sentences into their Roman Urdu equivalents using an instruction-style prompt format.1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3
4base_model_name = "ogx786/urdu-roman-transliterator-tiny-aya"
5adapter_repo = "hina6198/urdu-roman-transliterator-lora" # update with your username
6
7tokenizer = AutoTokenizer.from_pretrained(adapter_repo)
8base_model = AutoModelForCausalLM.from_pretrained(base_model_name, device_map="auto")
9model = PeftModel.from_pretrained(base_model, adapter_repo)
10model.eval()
11
12def transliterate(urdu_text):
13 prompt = f"""### Instruction:
14Transliterate Urdu to Roman Urdu.
15
16### Input:
17{urdu_text}
18
19### Response:
20"""
21 inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
22 outputs = model.generate(**inputs, max_new_tokens=100, do_sample=False)
23 result = tokenizer.decode(outputs[0], skip_special_tokens=True)
24 return result.split("### Response:")[-1].strip()
25
26print(transliterate("تم کیسے ہو؟"))q_proj, v_proj, dropout=0.05