Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- ar
|
4 |
+
metrics:
|
5 |
+
- Accuracy
|
6 |
+
- F1_score
|
7 |
+
- BLEU
|
8 |
+
library_name: transformers
|
9 |
+
pipeline_tag: text2text-generation
|
10 |
+
tags:
|
11 |
+
- t5
|
12 |
+
- text2text-generation
|
13 |
+
- seq2seq
|
14 |
+
- Classification and Generation
|
15 |
+
- Classification
|
16 |
+
- Generation
|
17 |
+
- ArabicT5
|
18 |
+
- Text Classification
|
19 |
+
- Text2Text Generation
|
20 |
+
widget:
|
21 |
+
- example_title: "الرياضة"
|
22 |
+
- text: >
|
23 |
+
خسارة مدوية لليفربول امام تولوز وفوز كبير لبيتيس
|
24 |
+
---
|
25 |
+
|
26 |
+
# ArabicT5: Classification and Generation of Arabic News
|
27 |
+
- The model is under trial
|
28 |
+
|
29 |
+
# The number in the generated text represents the category of the news, as shown below:
|
30 |
+
category_mapping = {
|
31 |
+
|
32 |
+
'Political':1,
|
33 |
+
'Economy':2,
|
34 |
+
'Health':3,
|
35 |
+
'Sport':4,
|
36 |
+
'Culture':5,
|
37 |
+
'Technology':6,
|
38 |
+
'Art':7,
|
39 |
+
'Accidents':8
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
# Example usage
|
44 |
+
```python
|
45 |
+
|
46 |
+
from transformers import T5ForConditionalGeneration, T5Tokenizer, pipeline
|
47 |
+
|
48 |
+
model_name="Hezam/ArabicT5-news-classification-generation-45GB-base"
|
49 |
+
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
50 |
+
tokenizer = T5Tokenizer.from_pretrained(model_name)
|
51 |
+
generation_pipeline = pipeline("text2text-generation",model=model,tokenizer=tokenizer)
|
52 |
+
|
53 |
+
text = " خسارة مدوية لليفربول امام تولوز وفوز كبير لبيتيس"
|
54 |
+
|
55 |
+
output= generation_pipeline(text,
|
56 |
+
num_beams=10,
|
57 |
+
max_length=512,
|
58 |
+
top_p=0.9,
|
59 |
+
repetition_penalty = 3.0,
|
60 |
+
no_repeat_ngram_size = 3)[0]["generated_text"]
|
61 |
+
|
62 |
+
print(output)
|