CoolFace
Modelpublic

MIIB-NLP/Arabic-question-generation

sourceHugging Faceupdated 4y agoView on Hugging Face
7likes23downloads
README.md95 linesDownload Raw Back to root
1---2language: 3- ar4tags:5- answer-aware-question-generation 6- question-generation7- QG8widget:9- text: "context: الثورة الجزائرية أو ثورة المليون شهيد، اندلعت في 1 نوفمبر 1954 ضد المستعمر الفرنسي ودامت 7 سنوات ونصف. استشهد فيها أكثر من مليون ونصف مليون جزائري answer:  7 سنوات ونصف </s>10"11- text: "context: اسكتلندا دولة في شمال غرب أوروبا، تعتبر جزء من الدول الأربع المكونة المملكة المتحدة. تحتل الثلث الشمالي من جزيرة بريطانيا العظمى وتحدها جنوبا إنجلترا ويحدها شرقا بحر الشمال وغربا المحيط الأطلسي. عاصمتها أدنبرة، وأهم مدنها وأكبرها مدينة غلاسكو. كانت اسكتلندا مملكة مستقلة حتى 1 مايو 1707  answer:  أدنبرة  </s>"12 13- text: "context: تم تفكيك الإمبراطورية النمساوية المجرية في عام 1918 بعد نهاية الحرب العالمية الأولى. وكان اباطرتها: الإمبراطور فرانس جوزيف الأول هابسبورغ لورين (في الفترة من 1867 إلى 1916) والإمبراطورة إليزابيث (من 1867 إلى 1898)، تبعها الإمبراطور تشارلز الأول إمبراطور النمسا (من 1916 إلى 1918). answer: 1918 </s>14"15metrics:16- bleu17model-index:18- name: Arabic-Question-Generation19  results:20  - task:21      name: Question-Generation22      type: automatic-question-generation23    metrics:24    - name: Bleu125      type: bleu26      value: 37.6227    - name: Bleu228      type: bleu29      value: 27.8030    - name: Bleu331      type: bleu32      value: 20.8933    - name: Bleu434      type: bleu35      value: 15.8736    - name: meteor37      type: meteor38      value: 33.1939    - name: rougel40      type: rouge41      value: 43.3742      43 44---45# Arabic Question Generation Model46 47This model is ready to use for **Question Generation** task, simply input the text and answer, the model will generate a question, This model is a fine-tuned version of [AraT5-Base](https://huggingface.co/UBC-NLP/AraT5-base) Model 48 49## Live Demo 50Get the Question from given Context and a Answer : [Arabic QG Model](https://huggingface.co/spaces/MIIB-NLP/Arabic-Question-Generation)51 52## Model in Action 🚀53```python54#Requirements: !pip install transformers55from transformers import AutoTokenizer,AutoModelForSeq2SeqLM56 57model = AutoModelForSeq2SeqLM.from_pretrained("MIIB-NLP/Arabic-question-generation")58tokenizer = AutoTokenizer.from_pretrained("MIIB-NLP/Arabic-question-generation")59 60def get_question(context,answer):61  text="context: " +context + " " + "answer: " + answer + " </s>"62  text_encoding = tokenizer.encode_plus(63      text,return_tensors="pt"64  )65  model.eval()66  generated_ids =  model.generate(67    input_ids=text_encoding['input_ids'],68    attention_mask=text_encoding['attention_mask'],69    max_length=64,70    num_beams=5,71    num_return_sequences=172  )73  return tokenizer.decode(generated_ids[0],skip_special_tokens=True,clean_up_tokenization_spaces=True).replace('question: ',' ')74 75context="الثورة الجزائرية أو ثورة المليون شهيد، اندلعت في 1 نوفمبر 1954 ضد المستعمر الفرنسي ودامت 7 سنوات ونصف. استشهد فيها أكثر من مليون ونصف مليون جزائري"76answer =" 7 سنوات ونصف"77 78get_question(context,answer)79 80#output : question="كم استمرت الثورة الجزائرية؟ " 81 82```83 84## Details of Ara-T585 86The **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* 87 88 89## Contacts90 91**Mihoubi Akram Fawzi**: [Linkedin](https://www.linkedin.com/in/mihoubi-akram/) | [Github](https://github.com/mihoubi-akram) | <mihhakram@gmail.com>92 93**Ibrir Adel**: [Linkedin](https://www.linkedin.com/in/adel-ibrir/) | [Github]() | <adelibrir2015@gmail.com>94 95