Views
No views yet
microsoft/Phi-3-mini-128k-instruct, optimized for bidirectional translation between English and Tamil. The model has been fine-tuned using Low-Rank Adaptation (LoRA) with 4-bit quantization, enabling efficient inference on resource-constrained devices.aryaumesh/english-to-tamil1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4model_name = "shangeth/phi3-mini-ta_en"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForCausalLM.from_pretrained(model_name)
7model.eval()
8
9def translate_text(input_text, target_language="Tamil"):
10 prompt = f"Translate the following sentence to {target_language}: {input_text}\nTranslated Sentence:"
11 inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
12 with torch.no_grad():
13 outputs = model.generate(**inputs, max_length=512, num_beams=5, early_stopping=True)
14 return tokenizer.decode(outputs[0], skip_special_tokens=True)
15
16input_sentence = "Hello, how are you?"
17translated_sentence = translate_text(input_sentence, target_language="Tamil")
18print("Translated Sentence:", translated_sentence)1@misc{shangeth_phi3_mini_ta_en,
2 author = {Shangeth Rajaa},
3 title = {Phi-3 Mini Tamil-English Translator},
4 year = {2024},
5 url = {https://huggingface.co/shangeth/phi3-mini-ta_en}
6}