Usage
from transformers import pipelinepipe = pipeline("text-generation", model="Youssefx64/Qareed-Qwen2.5-1.5B-Poet-v2", device_map="auto")SYSTEM = "أنت «قريض»، شاعر عربي متمكّن من اللغة والعروض والقافية. تكتب شعرًا عربيًا فصيحًا، وتلتزم بعدد الأبيات وبالقافية المطلوبة إن وُجدت، دون شرح أو تعليق."msgs = [{"role": "system", "content": SYSTEM}, {"role": "user", "content": "اكتب بيتين في الشوق على قافية حرف الراء."}]print(pipe(msgs, max_new_tokens=120, do_sample=True, temperature=0.8)[0]["generated_text"][-1]["content"])
Prompts can ask for: a number of baits (1-4), a theme (e.g. الحزن، الغزل، المدح، الرثاء، الشوق، الفراق، العتاب، الهجاء، الدين، حب الوطن), an era, and a rhyme letter ("على قافية حرف الراء").
Training
- Data:
arbml/Ashaar_dataset (Ashaar, arXiv:2307.06218), cleaned and deduplicated; colloquial poems removed; poem-level train/validation split with a bait-level leakage check.
- Samples: windows of 1-4 consecutive baits, always single-rhyme; theme prompts only when the window text matches theme keywords (weak, heuristic labels); about half of the prompts request the rhyme letter.
- Method: QLoRA (NF4), LoRA r=32 alpha=64 on all linear layers, loss on the answer only, 17904 training samples, 1 epoch.
- Diacritics stripped. Meter (wazn) is not modeled or controlled.
Evaluation (automatic heuristics on held-out poems, not human ratings)
60 prompts per set, sampled at temperature 0.7
Table with columns: set, metric, BASE, V1, TUNED| set | metric | BASE | V1 | TUNED |
|---|
| rhyme | count_match | 0.42 | 1.00 | 1.00 |
| rhyme | rhyme_hit | 0.00 | 0.07 | 0.45 |
| rhyme | rhyme_consistency | 0.46 | 0.73 | 0.76 |
| rhyme | theme_hit | 1.00 | 0.00 | 1.00 |
| rhyme | copy_rate | 0.00 | 0.00 | 0.00 |
| rhyme | no_latin | 0.98 | 1.00 | 1.00 |
| theme | count_match | 0.20 | 1.00 | 1.00 |
| theme | rhyme_consistency | 0.43 | 0.68 | 0.68 |
| theme | theme_hit | 0.62 | 0.82 | 0.90 |
| theme | copy_rate | 0.00 | 0.00 | 0.00 |
| theme | no_latin | 0.95 | 1.00 | 0.97 |
| plain | count_match | 0.47 | 1.00 | 1.00 |
| plain | rhyme_consistency | 0.44 | 0.67 | 0.71 |
| plain | copy_rate | 0.00 | 0.00 | 0.00 |
| plain | no_latin | 0.98 | 0.98 | 1.00 |
rhyme_hit: every bait ends with the requested letter (surface rhyme letter; a final alef/maqsura is skipped). theme_hit: the output contains a keyword of the theme. copy_rate: share of generated baits found verbatim in the training set.
Limitations
- Meter (wazn) is not controlled or verified; rhyme means the surface rhyme letter only.
- Theme labels come from the source websites and are noisy; the keyword filter is a heuristic.
- The source text lost the letter alef-with-hamza-below; common words were patched but some words may still be wrong.
- May reproduce lines from the training data (see copy_rate). Outputs need human review.