Prompt-guided LLM agent for end-to-end ontology learning
Yaroslav Teplyi, Dmytro DosynTurning the vast knowledge of large language models (LLMs) into logical, machine-interpretable ontologies poses a difficult task. Conventional single-prompt strategies often generated ambiguous or mutually inconsistent triples could not be merged safely with reference knowledge bases. The present work therefore aimed to design and empirically verify an entirely automated workflow that converts raw text into schema–compliant RDF/OWL statements without manual intervention. The resulting agent combined four stages – schema discovery, instance extraction, self-repair validation, and ontology alignment – each expressed as structured prompts executed by an LLM. A validator inspected every candidate assertion against the extracted domain-range constraints; any violation triggered an iterative analyseerrors / fix-schema / fix-instances loop until consistency was reached. The workflow was instantiated with three families of LLMs – GPT-4.1-mini, LLaMA-3.3-70b, and Grok-3-mini – chosen to represent high-end proprietary, open-weights, and cost-efficient small models. Quality was measured on the synthetic Measure of Information in Nodes and Edges (MINE) benchmark and on two real scholarly texts: ten English CEUR-WS workshop volumes and ten Ukrainian issues of the Journal of Lviv Polytechnic National University “Information Systems and Networks”. On MINE the agent paired with LLaMA-3.3-70b achieved 67.5% fact recall, surpassing the KGGen pipeline (66.07%) while still enforcing schema coherence; GPT-4.1-mini and Grok-3-mini reached 59.8% and 52.4%, respectively. When applied to the bilingual texts, all models reproduced the canonical author–paper–journal relation, proposed up to 39 new classes and 29 new relations, and instantiated more than 800 individuals per dataset with only minor post-repair inconsistencies. Extracted labels remained in English even for Ukrainian inputs. While GPT-4.1-mini and LLaMA-3.3-70b generated broader and valid schema yet most of the schema remained uninitiated, when Grok-3-mini produced concise and fully populated schema with instances. The practical outcome is a pipeline that can be used on digital libraries or domain portals to expand existing knowledge graphs continuously and with minimal human effort, thereby lowering the cost for ontology maintenance and enrichment
References
[1] Al-Aswadi, F.N., Chan, H.Y., & Gan, K.H. (2020). Automatic ontology construction from text: A review from shallow to deep learning trend. Artificial Intelligence Review, 53, 3901-3928. doi: 10.1007/s10462-019-09782-9.
[2] Babaei Giglou, H., D’Souza, J., & Auer, S. (2023). LLMs4OL: Large language models for ontology learning. In T.R. Payne, V. Presutti, G. Qi, M. Poveda-Villalón, G. Stoilos, L. Hollink, Z. Kaoudi, G. Cheng & J. Li (Eds.), The Semantic Web – ISWC 2023 (pp. 408-427). Cham: Springer. doi: 10.1007/978-3-031-47240-4_22.
[3] Bakker, R.M., Di Scala, D.L., & de Boer, M.H. (2024). Ontology learning from text: An analysis on LLM performance. In Proceedings of the 3rd NLP4KGC international workshop on natural language processing for knowledge graph creation in conjunction with SEMANTiCS 2024 conference (paper 5). Amsterdam: CEUR-WS.
[4] Belhoucine, K., & Mourchid, M. (2018). A survey of ontology learning from text. In Proceedings of the twelfth international conference on advances in semantic processing (SEMAPRO 2018) (pp. 14-21). Athens: IARIA.
[5] Browarnik, O., & Maimon, O. (2015). Ontology learning from text: Why the ontology learning layer cake is not viable. International Journal of Signs and Semiotic Systems, 4. doi: 10.4018/IJSSS.2015070101.
[6] Caufield, J.H., Hegde, H., Emonet, V., Harris, N.L., Joachimiak, M.P., Matentzoglu, N., Kim, H., Moxon, S., Reese, J.T., & Haendel, M.A. (2024). Structured prompt interrogation and recursive extraction of semantics (SPIRES): A method for populating knowledge bases using zero-shot learning. Bioinformatics, 40, article number btae104. doi: 10.1093/ bioinformatics/btae104.
[7] Chen, B., Yi, F., & Varró, D. (2023). Prompting or fine-tuning? A comparative study of large language models for taxonomy construction. In 2023 ACM/IEEE international conference on model driven engineering languages and systems companion (MODELS-C) (pp. 588-596). Västerås: IEEE. doi: 10.1109/MODELS-C59198.2023.00097.
[8] Chen, K., Lin, K., & Klein, D. (2021). Constructing taxonomies from pretrained language models. In Proceedings of the 2021 conference of the North American chapter of the Association for Computational Linguistics: Human language technologies (pp. 4687-4700). Stroudsburg: ACL. doi: 10.18653/v1/2021.naacl-main.373.
[9] Dong, Z., Wang, M., Dai, L., Li, J., Liu, X., & Nong, R. (2025). Cross-document contextual coreference resolution in knowledge graphs. ArXiv. doi: 10.48550/arXiv.2504.05767.
[10] Funk, M., Hosemann, S., Jung, J.C., & Lutz, C. (2023). Towards ontology construction with language models. In Proceedings of the KBC-LM’23: Knowledge base construction from pre-trained language models workshop at ISWC 2023 (paper 16). Amsterdam: CEUR-WS.
[11] He, Y., Chen, J., Antonyrajah, D., & Horrocks, I. (2022). BERTMap: A BERT-Based ontology alignment system. Proceedings of the AAAI Conference on Artificial Intelligence, 36(5), 5684-5691. doi: 10.1609/aaai.v36i5.20510.
[12] Jain, L., & Espinosa Anke, L. (2022). Distilling hypernymy relations from language models: On the effectiveness of zero-shot taxonomy induction. In Proceedings of the 11th joint conference on lexical and computational semantics (pp. 151-156). Seattle: ACL. doi: 10.18653/v1/2022.starsem-1.13.
[13] Ji, S., Pan, S., Cambria, E., Marttinen, P., & Yu, P.S. (2021). A survey on knowledge graphs: Representation, acquisition, and applications. IEEE Transactions on Neural Networks and Learning Systems, 33, 494-514. doi: 10.1109/ TNNLS.2021.3070843.
[14] Karamanolakis, G., Ma, J., & Dong, X.L. (2020). Txtract: Taxonomy-aware knowledge extraction for thousands of product categories. In Proceedings of the 58th annual meeting of the Association for Computational Linguistics (pp. 8489-8502). Stroudsburg: ACL. doi: 10.18653/v1/2020.acl-main.751.
[15] Lo, A., Jiang, A.Q., Li, W., & Jamnik, M. (2025). End-to-end ontology learning with large language models. In Proceedings of the 38th international conference on neural information processing systems (NIPS ’24) (article number 2767). New York: Red Hook. doi: 10.5555/3737916.3740683.
[16] Mihindukulasooriya, N., Tiwari, S., Enguix, C.F., & Lata, K. (2023). Text2KGBench: A benchmark for ontology-driven knowledge graph generation from text. In T.R. Payne, V. Presutti, G. Qi, M. Poveda-Villalón, G. Stoilos, L. Hollink, Z. Kaoudi, G. Cheng & J. Li. (Eds.), The Semantic Web – ISWC 2023 (pp. 247-265). Cham: Springer. doi: 10.1007/978-3031-47243-5_14.
[17] Mo, B., Yu, K., Kazdan, J., Mpala, P., Yu, L., Cundy, C., Kanatsoulis, C., & Koyejo, S. (2025). KGGen: Extracting knowledge graphs from plain text with language models. ArXiv. doi: 10.48550/arXiv.2502.09956.
[18] Monarch Initiative. (n.d.). OntoGPT: A prompt-based ontology extraction tool. Retrieved from https://monarchinitiative.github.io/ontogpt.
[19] Shang, C., Dash, S., Chowdhury, M.F.M., Mihindukulasooriya, N., & Gliozzo, A. (2020). Taxonomy construction of unseen domains via graph-based cross-domain knowledge transfer. In Proceedings of the 58th annual meeting of the Association for Computational Linguistics (pp. 2198-2208). Stroudsburg: ACL. doi: 10.18653/v1/2020.aclmain.199.
[20] Sokol, O. (2025). Optimising productivity and automating software development: Innovative memory system approaches in large language models. Technologies and Engineering, 26(1), 36-44. doi: 10.30857/2786-5371.2025.1.3.
[21] Wqtróbski, J. (2020). Ontology learning methods from text – an extensive knowledge-based approach. Procedia Computer Science, 176, 3356-3368. doi: 10.1016/j.procs.2020.09.061.
[22] Wong, W., Liu, W., & Bennamoun, M. (2012). Ontology learning from text: A look back and into the future. ACM Computing Surveys, 44(4), 1-36. doi: 10.1145/2333112.2333115.
[23] Yuan, S., He, J., Wang, M., Zhou, H., & Ren, Y. (2022). A review for ontology construction from unstructured texts by using deep learning. In Proceedings of the international conference on internet of things and machine learning (IoTML 2021) (article number 121741D). Shanghai: SPIE. doi: 10.1117/12.2628713.
[24] Zeng, Q., Bai, Y., Tan, Z., Feng, S., Liang, Z., Zhang, Z., & Jiang, M. (2024). Chain-of-layer: Iteratively prompting large language models for taxonomy induction from limited examples. In Proceedings of the 33rd ACM international conference on information and knowledge management (pp. 3093-3102). Arlington: ACM. doi: 10.1145/3627673.3679608.
[25] Zhong, L., Wu, J., Li, Q., Peng, H., & Wu, X. (2023). A comprehensive survey on automatic knowledge graph construction. ACM Computing Surveys, 56, article number 94. doi: 10.1145/3618295.