File size: 707 Bytes
2d6f21e
 
ff18b46
 
 
 
dc103c8
2d6f21e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e2cf70d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
---
license: apache-2.0
widget:
- text: >-
    I was born at 2003 and my sister was born at 2000.
- text: >-
    How are You?
language:
- ta
---
```python
def language_translator(text):
    tokenizer = AutoTokenizer.from_pretrained(checkpoint)
    model = AutoModelForSeq2SeqLM.from_pretrained("finetune-EN-to-Ta/")
    # model = AutoModelForSeq2SeqLM.from_pretrained("finetune-EN-to-Ta/")
    tokenized = tokenizer([text], return_tensors='pt')
    out = model.generate(**tokenized, max_length=128)
    with tokenizer.as_target_tokenizer():
        return tokenizer.decode(out[0],skip_special_tokens=True)

text_to_translate = "How are you?"
output = language_translator(text_to_translate)
print(output)
```