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