File size: 1,714 Bytes
d4e2f3d
 
 
 
 
 
 
a32bec5
 
2fcfc7e
a32bec5
 
 
 
 
 
 
 
171390e
c02b81e
171390e
 
a32bec5
171390e
a32bec5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d083b5f
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
---
language:
- tr
- en
tags:
- mt5
- t5
- text-generation-inference
- turkish
widget:
- text: >-
    Bu hafta hasta olduğum için <extra_id_0> gittim. Midem ağrıyordu ondan
    dolayı şu an <extra_id_1>.
- example_title: Turkish Example 1
- text: Bu gece kar yağacakmış. Yarın yollarda <extra_id_0> olabilir.
- example_title: Turkish Example 2
- text: I bought two tickets for NBA match. Do you like <extra_id_0> ?
- example_title: English Example 2
---
# Model Card

<!-- Provide a quick summary of what the model is/does. -->
Please check [**google/mt5-base**](https://huggingface.co/google/mt5-base) model. This model is pruned version of mt5-base model to only work in Turkish and English. Also for methodology, you can check Russian version of mT5-base [cointegrated/rut5-base](https://huggingface.co/cointegrated/rut5-base).

# Usage

You should import required libraries by:
```python
from transformers import T5ForConditionalGeneration, T5Tokenizer
import torch
```

To load model:
```python
model = T5ForConditionalGeneration.from_pretrained('bonur/t5-base-tr')
tokenizer = T5Tokenizer.from_pretrained('bonur/t5-base-tr')
```

To make inference with given text, you can use the following code:
```python
inputs = tokenizer("Bu hafta hasta olduğum için <extra_id_0> gittim.", return_tensors='pt')
with torch.no_grad():
    hypotheses = model.generate(
        **inputs,
        do_sample=True, top_p=0.95,
        num_return_sequences=2,
        repetition_penalty=2.75,
        max_length=32,
    )
for h in hypotheses:
    print(tokenizer1.decode(h))
```

You can tune parameters for better result, and this model is ready to fine-tune in bilingual downstream tasks with English and Turkish.