File size: 1,806 Bytes
69fca15
 
 
 
 
 
 
3fdc066
8700cdc
 
 
 
3fdc066
 
69fca15
 
58f13b1
 
 
 
69fca15
58f13b1
69fca15
58f13b1
 
 
69fca15
58f13b1
 
 
 
 
 
 
 
 
 
 
69fca15
58f13b1
 
69fca15
58f13b1
 
 
69fca15
58f13b1
 
 
69fca15
58f13b1
 
 
 
69fca15
 
 
58f13b1
69fca15
58f13b1
 
69fca15
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
library_name: transformers
tags: []
---

# Model Card for Model ID

This model is a translator into Lithuanian and vice versa. 
It was trained on the following datasets:  
* [ted_talks_iwslt](https://huggingface.co/datasets/IWSLT/ted_talks_iwslt)
* [ayymen/Pontoon-Translations](https://huggingface.co/datasets/ayymen/Pontoon-Translations)
  
**Note** This model is currently under development and only supports translation from English to Lithuanian.  
Other languages will also be added in the future.


## Model Usage
```Python
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

from transformers import T5Tokenizer, MT5ForConditionalGeneration

tokenizer = T5Tokenizer.from_pretrained('google/mt5-small')
model = MT5ForConditionalGeneration.from_pretrained("werent4/mt5TranslatorLT")
model.to(device)

def translate(text, model, tokenizer, device):
    input_text = f"translate English to Lithuanian: {text}"
    encoded_input = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True, max_length=128).to(device)
    with torch.no_grad():
        output_tokens = model.generate(
          **encoded_input,
          max_length=128,
          num_beams=5,
          no_repeat_ngram_size=2,
          early_stopping=True
      )

    translated_text = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
    return translated_text

text = "women"
translate(text, model, tokenizer, device)
`moteris`

text = "How are you?"
translate(text, model, tokenizer, device)
`Kaip esate?`

text = "I live in Kaunas"
translate(text, model, tokenizer, device)
`Aš gyvenu Kaunas`
```



## Model Card Authors

[werent4](https://huggingface.co/werent4)  
[Mykhailo Shtopko](https://huggingface.co/BioMike)

## Model Card Contact

[More Information Needed]