Views
No views yet

1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2tokenizer = AutoTokenizer.from_pretrained("UBC-NLP/AraT5-base-title-generation")
3model = AutoModelForSeq2SeqLM.from_pretrained("UBC-NLP/AraT5-base-title-generation")
4
5Document = "تحت رعاية صاحب السمو الملكي الأمير سعود بن نايف بن عبدالعزيز أمير المنطقة الشرقية اختتمت غرفة الشرقية مؤخرا، الثاني من مبادرتها لتأهيل وتدريب أبناء وبنات المملكة ضمن مبادرتها المجانية للعام 2019 حيث قدمت 6 برامج تدريبية نوعية. وثمن رئيس مجلس إدارة الغرفة، عبدالحكيم العمار الخالدي، رعاية سمو أمير المنطقة الشرقية للمبادرة، مؤكدا أن دعم سموه لجميع أنشطة ."
6
7encoding = tokenizer.encode_plus(Document,pad_to_max_length=True, return_tensors="pt")
8input_ids, attention_masks = encoding["input_ids"], encoding["attention_mask"]
9
10
11outputs = model.generate(
12 input_ids=input_ids, attention_mask=attention_masks,
13 max_length=256,
14 do_sample=True,
15 top_k=120,
16 top_p=0.95,
17 early_stopping=True,
18 num_return_sequences=5
19)
20
21for id, output in enumerate(outputs):
22 title = tokenizer.decode(output, skip_special_tokens=True,clean_up_tokenization_spaces=True)
23 print("title#"+str(id), title)title#0 غرفة الشرقية تختتم المرحلة الثانية من مبادرتها لتأهيل وتدريب أبناء وبنات المملكة
title#1 غرفة الشرقية تختتم الثاني من مبادرة تأهيل وتأهيل أبناء وبناتنا
title#2 سعود بن نايف يختتم ثانى مبادراتها لتأهيل وتدريب أبناء وبنات المملكة
title#3 أمير الشرقية يرعى اختتام برنامج برنامج تدريب أبناء وبنات المملكة
title#4 سعود بن نايف يرعى اختتام مبادرة تأهيل وتدريب أبناء وبنات المملكةexclusively for research. For commercial use, please contact the authors via email @ (muhammad.mageed[at]ubc[dot]ca).| Model | Link |
|---|---|
| AraT5-base | https://huggingface.co/UBC-NLP/AraT5-base |
| AraT5-msa-base | https://huggingface.co/UBC-NLP/AraT5-msa-base |
| AraT5-tweet-base | https://huggingface.co/UBC-NLP/AraT5-tweet-base |
| AraT5-msa-small | https://huggingface.co/UBC-NLP/AraT5-msa-small |
| AraT5-tweet-small | https://huggingface.co/UBC-NLP/AraT5-tweet-small |
1@inproceedings{nagoudi-etal-2022-arat5,
2 title = "{A}ra{T}5: Text-to-Text Transformers for {A}rabic Language Generation",
3 author = "Nagoudi, El Moatez Billah and
4 Elmadany, AbdelRahim and
5 Abdul-Mageed, Muhammad",
6 booktitle = "Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
7 month = may,
8 year = "2022",
9 address = "Dublin, Ireland",
10 publisher = "Association for Computational Linguistics",
11 url = "https://aclanthology.org/2022.acl-long.47",
12 pages = "628--647",
13 abstract = "Transfer learning with a unified Transformer framework (T5) that converts all language problems into a text-to-text format was recently proposed as a simple and effective transfer learning approach. Although a multilingual version of the T5 model (mT5) was also introduced, it is not clear how well it can fare on non-English tasks involving diverse data. To investigate this question, we apply mT5 on a language with a wide variety of dialects{--}Arabic. For evaluation, we introduce a novel benchmark for ARabic language GENeration (ARGEN), covering seven important tasks. For model comparison, we pre-train three powerful Arabic T5-style models and evaluate them on ARGEN. Although pre-trained with {\textasciitilde}49 less data, our new models perform significantly better than mT5 on all ARGEN tasks (in 52 out of 59 test sets) and set several new SOTAs. Our models also establish new SOTA on the recently-proposed, large Arabic language understanding evaluation benchmark ARLUE (Abdul-Mageed et al., 2021). Our new models are publicly available. We also link to ARGEN datasets through our repository: https://github.com/UBC-NLP/araT5.",
14}