Views
No views yet
transformers library or you can use the model via the Hugging Face inference API.1from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
2# Load model and tokenizer
3model_name = "aishu15/colloquial-tamil"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
6# Function to translate text
7def translate(text):
8 inputs = tokenizer(text, return_tensors="pt")
9 outputs = model.generate(**inputs, max_length=128)
10 return tokenizer.decode(outputs[0], skip_special_tokens=True)
11# Example translations
12test_sentences = [
13 "This is so beautiful",
14 "Bro, are you coming or not?",
15 "My mom is gonna kill me if I don't reach home now!"
16]
17for sentence in test_sentences:
18 print(f"English: {sentence}")
19 print(f"Colloquial Tamil: {translate(sentence)}\n")