Kyrmasch commited on
Commit
1376f22
1 Parent(s): 99cc78b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +22 -1
README.md CHANGED
@@ -21,4 +21,25 @@ language:
21
 
22
  ## Model Description
23
 
24
- This model is based on the google/mt5-large model. The model was fine-tuned on a Kazakh language version of the Stanford Question Answering Dataset (SQuAD) using 30,000 samples.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  ## Model Description
23
 
24
+ This model is based on the google/mt5-large model. The model was fine-tuned on a Kazakh language version of the Stanford Question Answering Dataset (SQuAD) using 30,000 samples.
25
+
26
+ ## Inference
27
+
28
+ ```python
29
+
30
+ from transformers import T5Tokenizer, T5TokenizerFast
31
+ from transformers import T5ForConditionalGeneration
32
+ import sentencepiece
33
+
34
+ tokenizer = T5Tokenizer.from_pretrained("Kyrmasch/t5-kazakh")
35
+ model = T5ForConditionalGeneration.from_pretrained("Kyrmasch/t5-kazakh")
36
+
37
+ context = "Қазақстан Еуразия құрлығының орталығында орналасқан және аумақтың көлемі бойынша (жер шарының бетінде 2%) әлемде тоғызыншы орынға ие. Қазақстан аумағы бүкіл Батыс Еуропадан үлкен."
38
+ question = "Қазақстан жер көлемі жөнінен дүние жүзінде нешінші орында?"
39
+
40
+ encoded = tokenizer.encode_plus(context, question, max_length=128, pad_to_max_length=True, truncation=True, return_tensors="pt")
41
+ input_ids = encoded["input_ids"].to('cpu')
42
+ attention_mask = encoded["attention_mask"].to('cpu')
43
+ output = model.generate(input_ids=input_ids, attention_mask=attention_mask, max_length=128)
44
+ answer = ''.join([tokenizer.decode(ids, skip_special_tokens=True) for ids in output])
45
+ ```