Elamur Research⌕
☰
home / papers / 2023 / Ashaar: Automatic Analysis and Generation of Arabic Poetry Using Deep Learning Approaches

Ashaar: Automatic Analysis and Generation of Arabic Poetry Using Deep Learning Approaches

Summary

Classical Arabic poetry follows strict metrical rules: the 16 meters codified from al-Farahidi's Arud system. These rules depend on diacritics, so analysing a poem usually requires a trained expert. Ashaar is an open framework that automates much of this work. It chains classifiers for meter, theme and era with a diacritization model, then combines the diacritized text with the predicted meter to derive the Arudi form of each verse. For generation, the authors pretrain a character-level GPT-2 that keeps diacritics in its vocabulary. It continues a poem conditioned on meter, qafiyah (end rhyme) and theme. The release includes four Hugging Face datasets and five pretrained models. To check rhythm, generated poems are passed back through the authors' own meter classifier. The small character model reaches 64.4% poem-level meter accuracy, beating a BPE-based earlier system at 56.7%. A zero-shot probe shows the unconditional generator picked up partial diacritization skill without any supervision for it. The work offers a reusable toolkit for a rule-heavy literary domain where form must be modelled, not just content.

Key points

  • Released datasets: Ashaar dataset (verses labelled with meter, theme, era, etc.), Ashaar diacritized, Ashaar arudi (gold Arudi representations of verses) and Ashaar tafeelah (all permissible tafeelat per meter). The models cover era, theme and meter classification, diacritization and conditional generation.
  • The generator is a default GPT-2 architecture with 10 layers and character tokenization. Training ran for 450,000 steps, using a batch size of 16, a context length of 512 and a 121-symbol vocabulary (characters, diacritics and reserved control tokens).
  • Generation data was filtered by dropping:
    • poems with an odd number of verses,
    • poems containing verses shorter than 5 characters,
    • poems whose meter falls outside the 16 classes.
  • Rhythm evaluation used 15 meters, 10 verses per poem and 100 repetitions per meter, giving 1,500 poems. Each poem's meter was decided by majority vote over its verses. Results:
    • Accuracy: 64.40 (versus 56.70 for Abboushi and Azzeh, 2023).
    • Top-3: 69.40; Top-5: 71.13.
    • Half of the meters exceeded 90%; popular meters fared best.
  • Zero-shot diacritization by the unconditional model, measured against the supervised diacritizer as reference, gave DER of about 43–50% and WER of about 89–91%. Error rose as sampling widened from 2 to 7.

Interesting ideas

  • I1. The generator is scored by an independent, stronger classifier, with verse-level predictions pooled by majority vote into a poem-level verdict. This gives a cheap, automatic check of whether output has the required form. — For Mova (back): Generated sentences could be re-parsed and re-framed, and passing should require that the recovered frames match the source graph by agreement across clauses, not by surface overlap.
  • I2. Analysis is staged so that a hard structural reading (Arudi form) is computed only after diacritics and meter are fixed. Each intermediate layer is explicit and can be inspected. — For Mova (tokens): Morphology and lemma decisions could likewise be committed as an explicit layer before deriving structural features, so any parse error can be traced to a specific upstream token decision.
  • I3. A rule resource (all legal tafeelat per meter) is published alongside the learned models, so neural predictions can be checked against a finite inventory of allowed patterns. — For Mova (world): Compiled knowledge such as VerbNet classes or measure units can serve as a closed list of allowed patterns, so impossible frame or value predictions get flagged explainably.
  • I4. A model trained only to generate text is probed for a skill it was never supervised on (diacritization), using a supervised model as reference. This reveals what structure it absorbed implicitly. — For Mova (learn): Transformer parsers or LLM teachers could be probed for untrained skills against existing witnesses, with negative controls to tell real competence from chance.
  • I5. Character-level tokens are chosen over BPE because diacritics fragment subword statistics, and the smaller character model still won on form accuracy. — For Mova (tokens): Rare or noisy orthographic variants (archaic spellings, OCR text) could be handled by a character-level fallback path instead of forcing them through a word or subword vocabulary.

Our summary of the paper, in our own words — not its text. The work belongs to its authors; read it at the links above.

Fields: Linguistics & languages

Cited by

5 papers of our library cite it (of the 140884 whose bibliographies we read); 1 of them have a page here, 4 not yet.

Cite

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.48550/arxiv.2307.06218 · arXiv 2307.06218

@misc{alyafeai2023ashaar,
  title = {{Ashaar: Automatic Analysis and Generation of Arabic Poetry Using Deep Learning Approaches}},
  author = {Alyafeai, Zaid and Al-Shaibani, Maged S. and Ahmed, Moataz},
  year = {2023},
  doi = {10.48550/arxiv.2307.06218},
  eprint = {2307.06218},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.2307.06218}
}

References

47 references, 2 of them with a card of ours. ↗ leads to the work, «find» searches for one we have no id for yet.

  1. Ahmedabdel-aal/arabic-poem-generator: A pytorch rnn model to generate arabic poems. https://github.com/AhmedAbdel-Aal/ Arabic-poem-Generator. (Accessed on 03/17/2023). ↗
  2. Gheith Abandah and Asma Abdel-Karim. 2020. Accurate and fast recurrent neural network solution for the automatic diacritization of arabic text. Jordanian Journal of Computers and Information Technology, 6(2). find
  3. Gheith A Abandah, Mohammed Z Khedher, Mohammad R Abdel-Majeed, Hamdi M Mansour, Salma F Hulliel, and Lara M Bisharat. 2020. Classifying and diacritizing arabic poems using deep recurrent neural networks. Journal of King Saud University-Computer and Information Sciences. find
  4. Mourad Abbas, Mohamed Lichouri, and Ahmed Zeg-gada. 2019. Classification of arabic poems: from the 5th to the 5th century. In International Conference on Image Analysis and Processing, pages 179–186. Springer. find
  5. Omar Abboushi and Mohammad Azzeh. 2023. Toward fluent arabic poem generation based on fine-tuning aragpt2 transformer. Arabian Journal for Science and Engineering, pages 1–13. find
  6. Belal Abuata and Asma Al-Omari. 2018. A rule-based algorithm for the detection of arud meter in classical arabic poetry. International Arab Journal of Information Technology, 15(4):1–5. find
  7. Munef Abdullah Ahmed and Stefan Trausan-Matu. 2017. A program for analyzing classical arabic poetry for teaching purposes. Rom. J. Hum.-Comput. Interact, 10(4):331–344. find
  8. Mohammed Al-Sarem, Faisal Saeed, Abdullah Alsaeedi, Wadii Boulila, and Tawfik Al-Hadhrami. 2020. Ensemble methods for instance-based arabic language authorship attribution. IEEE Access, 8:17331–17345. find
  9. Maged S Al-Shaibani, Zaid Alyafeai, and Irfan Ahmad. 2020a. Meter classification of arabic poems using deep bidirectional recurrent neural networks. Pattern Recognition Letters, 136:1–7. find
  10. Maged S Al-Shaibani, Zaid Alyafeai, and Irfan Ahmad. 2020b. Metrec: A dataset for meter classification of arabic poetry. Data in Brief, 33:106497. find
  11. Maytham Alabbas, Zainab A Khalaf, and Khashan M Khashan. 2014. Basrah: an automatic system to identify the meter of arabic poetry. Natural Language Engineering, 20(1):131–149. find
  12. Mohammad M Albaddawi and Gheith A Abandah. 2021. Pattern and poet recognition of arabic poems using bilstm networks. In 2021 IEEE Jordan International Joint Conference on Electrical Engineering and Information Technology (JEEIT), pages 72–77. IEEE. find
  13. Abdulrahman Almuhareb. 2016. Arabic poetry focused crawling using svm and keywords. In 2016 4th Saudi International Conference on Information Technology (Big Data Analysis)(KACSTIT), pages 1–4. IEEE. find
  14. Abdulrahman Almuhareb, Ibrahim Alkharashi, Lama AL Saud, and Haya Altuwaijri. 2013. Recognition of classical arabic poems. In Proceedings of the Workshop on Computational Linguistics for Literature, pages 9–16. find
  15. Abdulrahman Almuhareb, Waleed A Almutairi, Haya Al-Tuwaijri, Abdulelah Almubarak, and Marwa Khan. 2015. Recognition of modern arabic poems. J. Softw., 10(4):454–464. find
  16. Mohammad A Alnagdawi, Hasan Rashideh, and Ala Fahed Aburumman. 2013. Finding arabic poem meter using context free grammar. find
  17. Fahd Alqasemi, AL-Hagree Salah, Nail Adeeb Ali Abdu, Baligh Al-Helali, and Ghaleb Al-Gaphari. 2021. Arabic poetry meter categorization using machine learning based on customized feature extraction. In 2021 International Conference on Intelligent Technology, System and Service for Internet of Everything (ITSS-IoE), pages 1–4. IEEE. find
  18. Ouais Alsharif, Deema Alshamaa, and Nada Ghneim. 2013. Emotion classification in arabic poetry using machine learning. International Journal of Computer Applications, 65(16). find
  19. MA Ismail, M Eladawy, Hesham Keshk, and S Saleh. 2010. Expert system for testing the harmony of arabic poetry. Journal of Engineering Sciences, 1:401– 411. find
  20. E Khan. 2014. Using arabic poetry system for steganography. Asian Journal of Computer Science and Information Technology, 4(6):55–61. find
  21. Malik H Altakrori, Farkhund Iqbal, Benjamin CM Fung, Steven HH Ding, and Abdallah Tubaishat. 2018. Arabic authorship attribution: An extensive study on twitter posts. ACM Transactions on Asian and Low-Resource Language Information Processing (TAL-LIP), 18(1):1–51. find
  22. Mohammad S Khorsheed and Abdulmohsen O Al-Thubaity. 2013. Comparative evaluation of text classification techniques using a large diverse arabic dataset. Language resources and evaluation, 47(2):513–538. find
  23. Alaa Saleh Altheneyan and Mohamed El Bachir Menai. 2014. Naïve bayes classifiers for authorship attribution of arabic texts. Journal of King Saud University-Computer and Information Sciences, 26(4):473–484. find
  24. Mokthar Ali Hasan Madhfar and Ali Mustafa Qamar. 2020. Effective deep learning models for automatic diacritization of arabic text. IEEE Access, 9:273– 288. find
  25. Wissam Antoun, Fady Baly, and Hazem Hajj. 2020. Aragpt2: Pre-trained transformer for arabic language generation. arXiv preprint arXiv:2012.15520. ↗
  26. Mohamed El Ghaly Beheitt and Moez Ben Haj Hmida. 2022. Automatic arabic poem generation with gpt-2. In ICAART (2), pages 366–374. find
  27. Abdelmalek Berkani, Adrian Holzer, and Kilian Stoffel. 2020. Pattern matching in meter detection of arabic classical poetry. In 2020 IEEE/ACS 17th International Conference on Computer Systems and Applications (AICCSA), pages 1–8. IEEE. find
  28. Piotr Bojanowski, Edouard Grave, Armand Joulin, and Tomas Mikolov. 2017. Enriching word vectors with subword information. Transactions of the association for computational linguistics, 5:135–146. ↗
  29. Ibrahim Abu El-Khair. 2016. 1.5 billion words arabic corpus. arXiv preprint arXiv:1611.04033. ↗
  30. Nehal Elkaref, Mervat Abu-Elkheir, Maryam ElOraby, and Mohamed Abdelgaber. 2022. Generating classical arabic poetry using pre-trained models. In Proceedings of the The Seventh Arabic Natural Language Processing Workshop (WANLP), pages 53–62. find
  31. Ali Fadel, Ibraheem Tuffaha, Mahmoud Al-Ayyoub, et al. 2019. Arabic text diacritization using deep neural networks. In 2019 2nd international conference on computer applications & information security (IC-CAIS), pages 1–7. IEEE. find our card
  32. Mohammad Gharbat, Heba Saadeh, and Reem Q Al Fayez. 2019. Discovering the applicability of classification algorithms with arabic poetry. In 2019 IEEE Jordan International Joint Conference on Electrical Engineering and Information Technology (JEEIT), pages 453–458. IEEE. find
  33. Maha Hajja, Ahmad Yahya, and Adnan Yahya. 2019. Authorship attribution of arabic articles. In International Conference on Arabic Language Processing, pages 194–208. Springer. find
  34. Joan Mathilde Maling. 1973. The theory of classical Arabic metrics. Ph.D. thesis, Massachusetts Institute of Technology. find
  35. Hashim Saleh Manna and Zamri Arifin. 2021. Metrics in arabic poetry. find
  36. IA Mohammad. 2009. Naive bayes for classical arabic poetry classification. Al-Nahrain Journal of Science, 12(4):217–225. find
  37. Ahmed Ibrahim Ahmed Omer and Michael Philip Oakes. 2017. Arud, the metrical system of arabic poetry, as a feature set for authorship attribution. In 2017 IEEE/ACS 14th International Conference on Computer Systems and Applications (AICCSA), pages 431–436. IEEE. find
  38. Mariam Orabi, Hozayfa El Rifai, and Ashraf Elnagar. 2020. Classical arabic poetry: Classification based on era. In 2020 IEEE/ACS 17th International Conference on Computer Systems and Applications (AICCSA), pages 1–6. IEEE. find
  39. Bruno Paoli. 2001. Meters and formulas: The case of ancient arabic poetry. Belgian journal of linguistics, 15(1):113–136. find
  40. Sascha Rothe, Shashi Narayan, and Aliaksei Severyn. 2020. Leveraging pre-trained checkpoints for sequence generation tasks. Transactions of the Association for Computational Linguistics, 8:264–280. find our card
  41. Al-Zahrani Abdul Kareem Saleh and Moustafa Elshafei. 2012. Arabic poetry meter identification system and method. US Patent 8,219,386. find
  42. Sameerah Talafha and Banafsheh Rekabdar. 2019. Arabic poem generation with hierarchical recurrent attentional network. In 2019 IEEE 13th International Conference on Semantic Computing (ICSC), pages 316–323. IEEE. find
  43. Ben Wang and Aran Komatsuzaki. 2021. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/ kingoflolz/mesh-transformer-jax. ↗
  44. Waleed A Yousef, Omar M Ibrahime, Taha M Madbouly, and Moustafa A Mahmoud. 2019. Learning meters of arabic and english poems with recurrent neural networks: a step forward for language understanding and synthesis. arXiv preprint arXiv:1905.05700. ↗
  45. Taha Zerrouki and Amar Balla. 2017. Tashkeela: Novel corpus of arabic vocalized texts, data for auto-diacritization systems. Data in brief, 11:147–151. find
  46. Sherif Zeyada, Mohamed Eladawy, Manal Ismail, and Hesham Keshk. 2020. A proposed system for the identification of modem arabic poetry meters (imap). In 2020 15th International Conference on Computer Engineering and Systems (ICCES), pages 1–5. IEEE. find
  47. Mukhlisa Ziyovuddinova. 2021. Arud system in view of metric theory. The American Journal of Applied sciences, 3(05):234–239. find

↑ back to top

This page in Markdown → https://md.research.elamur.ai/free/en/papers/alyafeai-2023-ashaar-automatic-analysis-generation-arabic/