elmadany commited on
Commit
fd5de88
1 Parent(s): 2f5a95e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +37 -0
README.md CHANGED
@@ -6,7 +6,44 @@ We introduce the News Title Generation (NGT) task as a new task for Arabic langu
6
  We fine-tune ARGEN<sub>NTG</sub> on [**AraT5-base**](https://huggingface.co/UBC-NLP/AraT5-base), more details described in our [**AraT5: Text-to-Text Transformers for Arabic Language Understanding and Generation**](https://arxiv.org/abs/2109.12068)
7
 
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  # AraT5 Models Checkpoints
11
 
12
  AraT5 Pytorch and TensorFlow checkpoints are available on the Huggingface website for direct download and use ```exclusively for research```. ```For commercial use, please contact the authors via email @ (muhammad.mageed[at]ubc[dot]ca).```
 
6
  We fine-tune ARGEN<sub>NTG</sub> on [**AraT5-base**](https://huggingface.co/UBC-NLP/AraT5-base), more details described in our [**AraT5: Text-to-Text Transformers for Arabic Language Understanding and Generation**](https://arxiv.org/abs/2109.12068)
7
 
8
 
9
+ # How to use
10
+ ``` bash
11
+ !pip install transformers sentencepiece
12
+ ```
13
+
14
+ ```python
15
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
16
+ tokenizer = AutoTokenizer.from_pretrained("UBC-NLP/AraT5-base-title-generation")
17
+ model = AutoModelForSeq2SeqLM.from_pretrained("UBC-NLP/AraT5-base-title-generation")
18
+
19
+ Document = "تحت رعاية صاحب السمو الملكي الأمير سعود بن نايف بن عبدالعزيز أمير المنطقة الشرقية اختتمت غرفة الشرقية مؤخرا، الثاني من مبادرتها لتأهيل وتدريب أبناء وبنات المملكة ضمن مبادرتها المجانية للعام 2019 حيث قدمت 6 برامج تدريبية نوعية. وثمن رئيس مجلس إدارة الغرفة، عبدالحكيم العمار الخالدي، رعاية سمو أمير المنطقة الشرقية للمبادرة، مؤكدا أن دعم سموه لجميع أنشطة ."
20
+
21
+ encoding = tokenizer.encode_plus(Document,pad_to_max_length=True, return_tensors="pt")
22
+ input_ids, attention_masks = encoding["input_ids"], encoding["attention_mask"]
23
+
24
 
25
+ outputs = model.generate(
26
+ input_ids=input_ids, attention_mask=attention_masks,
27
+ max_length=256,
28
+ do_sample=True,
29
+ top_k=120,
30
+ top_p=0.95,
31
+ early_stopping=True,
32
+ num_return_sequences=5
33
+ )
34
+
35
+ for id, output in enumerate(outputs):
36
+ title = tokenizer.decode(output, skip_special_tokens=True,clean_up_tokenization_spaces=True)
37
+ print("title#"+str(id), title)
38
+ ```
39
+ **The output**
40
+ ```
41
+ title#0 غرفة الشرقية تختتم المرحلة الثانية من مبادرتها لتأهيل وتدريب أبناء وبنات المملكة
42
+ title#1 غرفة الشرقية تختتم الثاني من مبادرة تأهيل وتأهيل أبناء وبناتنا
43
+ title#2 سعود بن نايف يختتم ثانى مبادراتها لتأهيل وتدريب أبناء وبنات المملكة
44
+ title#3 أمير الشرقية يرعى اختتام برنامج برنامج تدريب أبناء وبنات المملكة
45
+ title#4 سعود بن نايف يرعى اختتام مبادرة تأهيل وتدريب أبناء وبنات المملكة
46
+ ```
47
  # AraT5 Models Checkpoints
48
 
49
  AraT5 Pytorch and TensorFlow checkpoints are available on the Huggingface website for direct download and use ```exclusively for research```. ```For commercial use, please contact the authors via email @ (muhammad.mageed[at]ubc[dot]ca).```