Views
No views yet
debug_divas_dataset.json) with English → Colloquial Tamil translation pairs.pip install torch transformers datasets unsloth accelerate1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4# Load fine-tuned model from Hugging Face
5model_name = "your-huggingface-username/debug-divas-tamil-translation"
6device = "cuda" if torch.cuda.is_available() else "cpu"
7
8model = AutoModelForCausalLM.from_pretrained(model_name).to(device)
9tokenizer = AutoTokenizer.from_pretrained(model_name)
10
11# Translation function
12def translate_english_to_tamil(input_text):
13 instruction = "Translate the following English sentence to colloquial Tamil"
14 inputs = tokenizer(f"{instruction}: {input_text}", return_tensors="pt").to(device)
15
16 translated_tokens = model.generate(**inputs, max_length=128)
17 translated_text = tokenizer.decode(translated_tokens[0], skip_special_tokens=True)
18
19 return translated_text
20
21# Example usage
22input_text = "The pharmacy is near the bus stop."
23translated_text = translate_english_to_tamil(input_text)
24print("Colloquial Tamil:", translated_text)| English | Colloquial Tamil Translation |
|---|---|
| "How are you?" | "நீங்க எப்படி இருக்கீங்க?" |
| "I am going to the market." | "நான் மார்க்கெட்டுக்கு பொறேன்." |
| "The pharmacy is near the bus stop." | "மருந்துக் கடை பஸ்ஸ்டாப் அருகே இருக்க." |
1[
2 {
3 "input": "How are you?",
4 "output": "நீங்க எப்படி இருக்கீங்க?"
5 },
6 {
7 "input": "I am going to the market.",
8 "output": "நான் மார்க்கெட்டுக்கு பொறேன்."
9 }
10]1@misc{debugdivas2025,
2 author = {Debug Divas},
3 title = {Fine-tuned Mistral-7B for Colloquial Tamil Translation},
4 year = {2025},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/your-huggingface-username/debug-divas-tamil-translation}
7}