Hadith Topic Modeling Based on Theme Similarity with the BERTopic Algorithm

Main Article Content

Irma Dwiyanti
Gevira Zahra Shofa
Muhammad Alfiyan Nurwahibulloh Rohayana
Muhammad Ahsani Taqwim
Idfa Billati Hiya Ahsan

Abstract

This study aims to develop a hadith topic modeling system based on thematic similarity using the BERTopic algorithm to support more structured and efficient Islamic studies. The research method uses a data exploration-based approach with the BERTopic algorithm that combines BERT semantic representation, UMAP dimensionality reduction, and HDBSCAN clustering. The dataset used is sourced from Kaggle containing thousands of hadith texts in English from various books, which are processed through the stages of data pre-processing, embedding transformation, and evaluation using topic coherence metrics and interactive visualization. The results show that BERTopic successfully identified 292 topics with clear visualization through the Intertopic Distance Map and Topic Similarity Heatmap; however, approximately 55.4% of documents are categorized as outliers due to high semantic variation and limited context. Despite the challenges in handling outlier documents, this study proves that BERTopic is effective in clustering hadith based on thematic similarity and producing semantically coherent topics. The resulting model can be the basis for the development of a hadith recommendation system, classification of da'wah content, and a theme-based religious learning curriculum, as well as opening up opportunities for the application of NLP technology in Islamic studies more broadly.

Downloads

Download data is not yet available.

Article Details

Section

Articles

How to Cite

Hadith Topic Modeling Based on Theme Similarity with the BERTopic Algorithm. (2026). Khazanah Journal of Religion and Technology, 4(1), 20-26. https://doi.org/10.66948/kjrt.41.53

References

[1] R. Aban, “Sunnah (Hadith) Dataset.” 2022.

[2] DM Blei, AY Ng, and MI Jordan, “Latent Dirichlet Allocation,” J. Mach. Learn. Res. , vol. 3, pp. 993–1022, 2003.

[3] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova, “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding,” ArXiv Prepr. , 2018.

[4] M. Grootendorst, “BERTopic: Neural topic modeling with a class-based TF-IDF procedure,” ArXiv Prepr. , 2022.

[5] S. Al-Shargi, “LDA Topic Modeling of the Holy Quran Text.” Nov. 2024. [Online]. Available: https://medium.com/@alshargi.usa/lda-topic-modeling-of-the-holy-quran-text-b43d3d7348c9

[6] D. Kumar, “Topic Modeling with BERTopic: A Comprehensive Analysis of Modern NLP Applications,” Int. J. Mach. Learn. Comput. , vol. 15, no. 1, pp. 12–20, Jan. 2025.

[7] A. Hassan, M. Ibrahim, and S. Khalil, “Hadith Classification using Machine Learning Techniques According to its Reliability,” Int. J. Adv. Comput. Sci. Appl. , vol. 10, no. 12, pp. 256–264, 2019.

[8] K. Al-Rashid, H. Mohammad, and F. Ahmed, “Text categorization in Quran and Hadith: Overcoming the interrelation challenges using machine learning and term weighting,” J. King Saud Univ. - Comput. Inf. Sci. , vol. 32, no. 8, pp. 914–923, Oct. 2020, doi: 10.1016/j.jksuci.2019.04.003.

[9] IK Alshammari, E. Atwell, and MA Alsalka, “Topic Modeling for Hadith Corpus: A Comparison of Latent Dirichlet Allocation (LDA), Non-Negative Matrix Factorization (NMF), and BERTopic with AraBERT, XLM-R, MARBERT, and CAMeLBERT,” Int. J. Islam. Appl. Comput. Sci. Technol. , vol. 11, no. 4, pp. 9–16, Dec. 2023.

[10] N. Alqahtani, F. Alotaibi, and M. Alsaeed, “Employing a Multilingual Transformer Model for Segmenting Unpunctuated Arabic Text,” Appl. Sci. , vol. 12, no. 20, p. 10559, Oct. 2022, doi: 10.3390/app122010559.

[11] L. Abdullah, K. Yaseen, and H. Naji, “AraBERT transformer model for Arabic comments and reviews analysis,” Neural Comput. Appl. , vol. 34, no. 8, pp. 6271–6285, Mar. 2022, doi: 10.1007/s00521-021-06782-4.

[12] S. Aftar, L. Gagliardelli, AE Ganadi, F. Ruozzi, and S. Bergamaschi, “RoBERT2VecTM: A Novel Approach for Topic Extraction in Islamic Studies,” in Findings of the Association for Computational Linguistics: EMNLP 2024 , 2024. doi: 10.18653/v1/2024.findings-emnlp.534.

[13] A. Abuzayed and H. Al-Khalifa, “BERT for Arabic Topic Modeling: An Experimental Study on BERTopic Technique,” Procedia Comput. Sci. , vol. 189, pp. 191–194, 2021, doi: 10.1016/j.procs.2021.05.096.

[14] T. Zerrouki, A. Balla, and A. Lakhouaja, “Arabic natural language processing for Qur'anic research: a systematic review,” vol. 56, no. 2, pp. 1175–1207, Feb. 2023, doi: 10.1007/s10462-022-10313-2.

[15] K. Jamshaid, H. Farooq, and MT Siddique, “Topic Modeling of Quranic Verses using Latent Dirichlet Allocation with English Language: Topic Modeling using LDA,” VFAST Trans. Softw. Eng. , vol. 12, no. 4, pp. 239–251, Dec. 2024, doi: 10.21015/vtse.v12i4.1946.

[16] AMA Egov and T. Grok, “The Development of Topic Modeling for Hadith Studies,” J. Islam. Stud. , vol. 2021, 2021.

[17] MA Mosa, "An Exhaustive Literature Review of Hadith Text Mining," ACM Trans. Asian Low-Resort. Lang. Inf. Process. , vol. 22, no. 7, pp. 1–25, Jul. 2023, doi: 10.1145/3588315.

[18] Herwinsyah and others, “Topic Modeling in the Qur'an Using the BERTopic Library on the BERT Language Model,” vol. 14, no. 2, 2023.

[19] F. Alotaibi, M. Alharbi, and S. Alnasser, “ArabianGPT: Native Arabic GPT-based Large Language Model,” ArXiv Prepr. ArXiv240215313, Feb. 2024.

[20] R. Baly, G. Hajj, and W. El-Hajj, “Benchmarking Transformer-based Language Models for Arabic Sentiment and Sarcasm Detection,” in Proceedings of the 6th Arabic Natural Language Processing Workshop , Association for Computational Linguistics, Apr. 2021, pp. 104–114.