update model card
Browse files
README.md
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: ar
|
3 |
+
datasets:
|
4 |
+
- Arabic Poetry Dataset (6th - 21st century)
|
5 |
+
metrics:
|
6 |
+
- perplexity
|
7 |
+
tags:
|
8 |
+
- text-generation
|
9 |
+
- poetry
|
10 |
+
license: apache-2.0
|
11 |
+
widget:
|
12 |
+
- text: "أراك عصي الدمع"
|
13 |
+
model-index:
|
14 |
+
- name: elgeish Arabic GPT2 Medium
|
15 |
+
results:
|
16 |
+
- task:
|
17 |
+
name: Text Generation
|
18 |
+
type: text-generation
|
19 |
+
dataset:
|
20 |
+
name: Arabic Poetry Dataset (6th - 21st century)
|
21 |
+
type: poetry
|
22 |
+
args: ar
|
23 |
+
metrics:
|
24 |
+
- name: Validation Perplexity
|
25 |
+
type: perplexity
|
26 |
+
value: 282.09
|
27 |
+
---
|
28 |
+
|
29 |
+
# GPT2-Medium-Arabic-Poetry
|
30 |
+
|
31 |
+
Fine-tuned [aubmindlab/aragpt2-medium](https://huggingface.co/aubmindlab/aragpt2-medium) on
|
32 |
+
the [Arabic Poetry Dataset (6th - 21st century)](https://www.kaggle.com/fahd09/arabic-poetry-dataset-478-2017)
|
33 |
+
using 41,922 lines of poetry as the train split and 9,007 (by poets not in the train split) for validation.
|
34 |
+
|
35 |
+
## Usage
|
36 |
+
|
37 |
+
```python
|
38 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, set_seed
|
39 |
+
|
40 |
+
set_seed(42)
|
41 |
+
model_name = "elgeish/gpt2-medium-arabic-poetry"
|
42 |
+
model = AutoModelForCausalLM.from_pretrained(model_name).to("cuda")
|
43 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
44 |
+
prompt = "للوهلة الأولى قرأت في عينيه"
|
45 |
+
input_ids = tokenizer.encode(prompt, return_tensors="pt")
|
46 |
+
samples = model.generate(
|
47 |
+
input_ids.to("cuda"),
|
48 |
+
do_sample=True,
|
49 |
+
early_stopping=True,
|
50 |
+
max_length=32,
|
51 |
+
min_length=16,
|
52 |
+
num_return_sequences=3,
|
53 |
+
pad_token_id=50256,
|
54 |
+
repetition_penalty=1.5,
|
55 |
+
top_k=32,
|
56 |
+
top_p=0.95,
|
57 |
+
)
|
58 |
+
|
59 |
+
for sample in samples:
|
60 |
+
print(tokenizer.decode(sample.tolist()))
|
61 |
+
print("--")
|
62 |
+
```
|
63 |
+
|
64 |
+
Here's the output:
|
65 |
+
|
66 |
+
```
|
67 |
+
للوهلة الأولى قرأت في عينيه عن تلك النسم لم تذكر شيءا فلربما نامت علي كتفيها العصافير وتناثرت اوراق التوت عليها وغابت الوردة من
|
68 |
+
--
|
69 |
+
للوهلة الأولى قرأت في عينيه اية نشوة من ناره وهي تنظر الي المستقبل بعيون خلاقة ورسمت خطوطه العريضة علي جبينك العاري رسمت الخطوط الحمر فوق شعرك
|
70 |
+
--
|
71 |
+
للوهلة الأولى قرأت في عينيه كل ما كان وما سيكون غدا اذا لم تكن امراة ستكبر كثيرا علي الورق الابيض او لا تري مثلا خطوطا رفيعة فوق صفحة الماء
|
72 |
+
--
|
73 |
+
```
|