Update README.md
Browse files
README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
language:
|
3 |
- ar
|
4 |
widget:
|
5 |
-
-
|
6 |
answer: "7 سنوات ونصف"
|
7 |
|
8 |
---
|
@@ -19,7 +19,36 @@ Get the Question from given Context and a Answer
|
|
19 |
The **Ara-T5** model was presented in [AraT5: Text-to-Text Transformers for Arabic Language Generation](https://arxiv.org/abs/2109.12068) by *El Moatez Billah Nagoudi, AbdelRahim Elmadany, Muhammad Abdul-Mageed*
|
20 |
|
21 |
|
|
|
|
|
|
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
## Citation
|
24 |
If you want to cite this model you can use this:
|
25 |
|
|
|
2 |
language:
|
3 |
- ar
|
4 |
widget:
|
5 |
+
- context: "الثورة الجزائرية أو ثورة المليون شهيد، اندلعت في 1 نوفمبر 1954 ضد المستعمر الفرنسي ودامت 7 سنوات ونصف. استشهد فيها أكثر من مليون ونصف مليون جزائري"
|
6 |
answer: "7 سنوات ونصف"
|
7 |
|
8 |
---
|
|
|
19 |
The **Ara-T5** model was presented in [AraT5: Text-to-Text Transformers for Arabic Language Generation](https://arxiv.org/abs/2109.12068) by *El Moatez Billah Nagoudi, AbdelRahim Elmadany, Muhammad Abdul-Mageed*
|
20 |
|
21 |
|
22 |
+
## Model in Action 🚀
|
23 |
+
```python
|
24 |
+
from transformers import AutoTokenizer,AutoModelForSeq2SeqLM
|
25 |
|
26 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Mihakram/Arabic_Question_Generation")
|
27 |
+
tokenizer = AutoTokenizer.from_pretrained("Mihakram/Arabic_Question_Generation")
|
28 |
+
|
29 |
+
def get_question(context,answer):
|
30 |
+
text="context: " +context + " " + "answer: " + answer + " </s>"
|
31 |
+
text_encoding = tokenizer.encode_plus(
|
32 |
+
text,return_tensors="pt"
|
33 |
+
)
|
34 |
+
model.eval()
|
35 |
+
generated_ids = model.generate(
|
36 |
+
input_ids=text_encoding['input_ids'],
|
37 |
+
attention_mask=text_encoding['attention_mask'],
|
38 |
+
max_length=64,
|
39 |
+
num_beams=5,
|
40 |
+
num_return_sequences=1
|
41 |
+
)
|
42 |
+
return tokenizer.decode(generated_ids[0],skip_special_tokens=True,clean_up_tokenization_spaces=True).replace('question: ',' ')
|
43 |
+
|
44 |
+
context="الثورة الجزائرية أو ثورة المليون شهيد، اندلعت في 1 نوفمبر 1954 ضد المستعمر الفرنسي ودامت 7 سنوات ونصف. استشهد فيها أكثر من مليون ونصف مليون جزائري"
|
45 |
+
answer =" 7 سنوات ونصف"
|
46 |
+
|
47 |
+
get_question(context,answer)
|
48 |
+
|
49 |
+
#output : question="كم استمرت الثورة الجزائرية؟ "
|
50 |
+
|
51 |
+
```
|
52 |
## Citation
|
53 |
If you want to cite this model you can use this:
|
54 |
|