Badr AlKhamissi
commited on
Commit
•
bc15e83
1
Parent(s):
dadac8e
added examples
Browse files- README.md +3 -3
- app.py +22 -2
- examples/log.csv +30 -0
- poet_names.json +0 -0
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
title: AraPoet
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.18.0
|
8 |
app_file: app.py
|
|
|
1 |
---
|
2 |
title: AraPoet
|
3 |
+
emoji: ✍️
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: blue
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.18.0
|
8 |
app_file: app.py
|
app.py
CHANGED
@@ -39,7 +39,7 @@ def generate_poem(country, era, meter, theme, lang_type, poet, num_lines, num_po
|
|
39 |
prompt += f"{name}: {feat}; "
|
40 |
prompt += f"Length: {num_lines}; Poem:"
|
41 |
|
42 |
-
num_beams =
|
43 |
top_k = 50
|
44 |
top_p = 0.9
|
45 |
r_penalty = 5.
|
@@ -80,9 +80,21 @@ tokenizer: AutoTokenizer = AutoTokenizer.from_pretrained("bkhmsi/arapoet-mt5", u
|
|
80 |
model: AutoModelForSeq2SeqLM = AutoModelForSeq2SeqLM.from_pretrained("bkhmsi/arapoet-mt5", use_auth_token="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")
|
81 |
model.eval()
|
82 |
|
83 |
-
title = "
|
84 |
with gr.Blocks(title=title) as demo:
|
85 |
inputs = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
with gr.Row():
|
87 |
inputs += [gr.Dropdown(countries, label="Country", value="None")]
|
88 |
inputs += [gr.Dropdown(poet_era, label="Era", value="None")]
|
@@ -99,6 +111,14 @@ with gr.Blocks(title=title) as demo:
|
|
99 |
inputs += [gr.Textbox(label="Title")]
|
100 |
|
101 |
btn = gr.Button("Generate")
|
|
|
102 |
btn.click(generate_poem, inputs, gr.TextArea(label="Generation"))
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
demo.launch()
|
|
|
39 |
prompt += f"{name}: {feat}; "
|
40 |
prompt += f"Length: {num_lines}; Poem:"
|
41 |
|
42 |
+
num_beams = 3
|
43 |
top_k = 50
|
44 |
top_p = 0.9
|
45 |
r_penalty = 5.
|
|
|
80 |
model: AutoModelForSeq2SeqLM = AutoModelForSeq2SeqLM.from_pretrained("bkhmsi/arapoet-mt5", use_auth_token="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")
|
81 |
model.eval()
|
82 |
|
83 |
+
title = ""
|
84 |
with gr.Blocks(title=title) as demo:
|
85 |
inputs = []
|
86 |
+
|
87 |
+
gr.Markdown(
|
88 |
+
"""
|
89 |
+
# AraPoet: Controlled Arabic Poetry Generation
|
90 |
+
|
91 |
+
The model hosted here is a finetuned version of [mT5-large](https://huggingface.co/google/mt5-large) (∼ 1.2B parameters) on the largest repository of Arabic poems, the [ashaar](https://huggingface.co/datasets/arbml/ashaar) dataset.
|
92 |
+
The model can be conditioned on a set of attributes to control the style of the generated poem.
|
93 |
+
Namely: the poet name, country, era, meter, theme, language type, title and the length of the poem.
|
94 |
+
You can start by clicking on one of the examples below or try your own input.
|
95 |
+
"""
|
96 |
+
)
|
97 |
+
|
98 |
with gr.Row():
|
99 |
inputs += [gr.Dropdown(countries, label="Country", value="None")]
|
100 |
inputs += [gr.Dropdown(poet_era, label="Era", value="None")]
|
|
|
111 |
inputs += [gr.Textbox(label="Title")]
|
112 |
|
113 |
btn = gr.Button("Generate")
|
114 |
+
examples = gr.Examples(examples="./examples", inputs=inputs)
|
115 |
btn.click(generate_poem, inputs, gr.TextArea(label="Generation"))
|
116 |
|
117 |
+
|
118 |
+
gr.Markdown(
|
119 |
+
"""
|
120 |
+
Checkout our [AraPoet Preprint](https://github.com/BKHMSI/BKHMSI.github.io/blob/master/archive/resources/AraPoet.pdf) for more details about the model.
|
121 |
+
"""
|
122 |
+
)
|
123 |
+
|
124 |
demo.launch()
|
examples/log.csv
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
country,era,meter,theme,lang_type,poet,num_lines,num_poems,titleNone,None,None,None,فصحى,خالد مصباح مظلوم,10,1,النساء ضحايا أحوالنا
|
2 |
+
None,None,None,None,فصحى,ابن الرومي,10,1,نجَّاكَ يا ابن الحاجِبِ الحاجبُ
|
3 |
+
العراق,العصر الحديث,المتقارب,None,فصيح,أحمد الصافي النجفي ,10,1,None
|
4 |
+
None,None,None,None,فصيح,أبو العلاء المعري,10,1,البارق المتعالي
|
5 |
+
None,None,None,None,فصحى,البحتري,10,1,أخا علة سار الإخاء فأوضعا
|
6 |
+
None,العصر المملوكي,بحر موشح,قصيدة الاناشيد,None,ابن نباته المصري,10,1,حشى من نار صدك ذائبة
|
7 |
+
None,None,None,None,فصيح,ريم سليمان الخش,10,1,مصيرها حلّاجي....
|
8 |
+
None,None,None,None,فصيح,السيد عبد الله سالم,10,1,زمليني
|
9 |
+
None,None,None,None,None,حسن حسني الطويراني,10,1,ابدأ بنفسك فاظهر كنه خافيها
|
10 |
+
None,None,None,None,فصيح,المفتي فتح الله,10,1,مُنِحتَ بَشيرَ الخيرِ بِالخَيرِ والجَدِّ
|
11 |
+
None,None,None,None,فصحى,جبران خليل جبران,10,1,لا تغاري من حسنها الملحود
|
12 |
+
None,None,None,None,فصيح,محمود المشهداني,10,1,والعوْدُ أحمد
|
13 |
+
None,None,None,None,فصيح,ابن الوردي,10,1,قالَ لها الشيخُ واصليني
|
14 |
+
None,None,None,None,فصحى,خليل مطران,10,1,طَويْنَا الحُقُولَ سِرَاعَ الْمَسِيرِ
|
15 |
+
None,العصر العباسي,بحر البسيط,قصيدة قصيره,None,ابو نواس,10,1,لا تحفلن بقول الزاجر اللاحي
|
16 |
+
None,None,None,None,فصحى,أحمد شوقي,10,1,بِأَبي وَروحي الناعِماتِ الغيدا
|
17 |
+
None,None,None,None,فصحى,نزار قباني,10,1,رسالة حُبّ (61) - (70)
|
18 |
+
None,None,None,None,فصحى,الفرزدق,10,1,ألم يأت بالشأم الخليفة أننا
|
19 |
+
None,None,بحر الكامل,None,None,لسان الدين بن الخطيب,10,1, الْحَقُّ يَعْلُو وَالأَبَاطِلُ تَسْفُلُ
|
20 |
+
None,None,None,None,فصحى,عبد الغني النابلسي,10,1,كواكب جرت من السماء
|
21 |
+
None,None,بحر المتقارب,None,None,الشريف العقيلي,10,1, وَسِترٍ لَهُ مَنظَرٌ مونِقٌ
|
22 |
+
None,None,None,None,None,ماء العينين,10,1,قال عبيد الله ما العينين
|
23 |
+
None,None,بحر الخفيف,None,None,جميل صدقي الزهاوي,10,1, كل ما تبتغيه منا الحياة
|
24 |
+
None,None,None,None,فصحى,بشار بن برد,10,1,منَّيْتَنِي بِشْراً وبشرٌ فتًى
|
25 |
+
None,None,None,None,فصحى,صفي الدين الحلي,10,1,لئن ثلمتْ حدّي صُروفُ النّوائبِ
|
26 |
+
None,None,بحر الطويل,None,None,محيي الدين بن عربي,10,1, أمرت فلم أسمع دعوتُ فلم تجب
|
27 |
+
None,None,بحر المنسرح,None,None,الأحنف العكبري,10,1, دعوهُ يبكي لفقد خلانه
|
28 |
+
None,None,None,None,فصحى,قاسم حداد,10,1,كلمات جندي رهن الاعتقال
|
29 |
+
None,None,None,None,None,صلاح الدين الصفدي,10,1,يا سيدا رب العفلا
|
30 |
+
None,None,None,None,فصحى,أبو الهدى الصيادي,10,1,بسم ربي باري الوجود ابتدائي
|
poet_names.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|