Articles

Ontology-Grounded RAG with SPARQL and Local Language Models for Technical Documentation

Authors

  • Julián Rafael Coronel Andrade University of Azuay image/svg+xml
  • Edwin Alexander Siguenza Siguenza University of Azuay image/svg+xml
  • Andrew Sebastian Cantos Vasquez University of Azuay image/svg+xml
  • Pablo Sebastián Vélez Mejía University of Azuay image/svg+xml
  • Marcos Orellana Universidad del Azuay

Abstract

This paper presents LIDI-AI, a Retrieval-Augmented Generation (RAG) system whose knowledge base consists of technical documentation for the LIDI-AI Research Assistant, a web-based data analysis application developed at Universidad del Azuay. The runtime architecture integrates two complementary knowledge sources: an OWL 2 ontology (artifact version 2.0) with six classes and twenty-five properties (nine object and sixteen datatype properties) that models the five-stage pipeline, the accepted file formats, the statistical analysis types, and the system errors, and a SPARQL 1.1 query layer for structured intent resolution. A Prolog knowledge base built on an Object-Attribute-Value (OAV) representation, comprising 172 facts, 17 inference rules, and three diagnostic engines, is formally specified and validated as a symbolic reasoning layer, although it is not yet callable from the Python orchestrator at runtime. A lexical retrieval module selects ontology fragments as grounded context for a locally hosted language model, specifically Llama-3.2-3B deployed via the Ollama framework with Q4_K_M quantization. Evaluation on ten queries from real users shows that seven were resolved with high precision via SPARQL-grounded retrieval, two were resolved via lexical fallback with ontology traceability, and one out-of-domain query received an explicit knowledge-limit acknowledgment, yielding an appropriate response rate with zero hallucinations.

Keywords

intelligent assistant knowledge representation local language models SPARQL structured queries symbolic reasoning

How to Cite

Coronel Andrade, J. R., Siguenza Siguenza, E. A., Cantos Vasquez, A. S., Vélez Mejía, P. S., & Orellana, M. (2026). Ontology-Grounded RAG with SPARQL and Local Language Models for Technical Documentation. Revista Tecnológica - ESPOL, 38(E1), 84-99. https://doi.org/10.37815/rte.v38nE1.1603
BibTeX

Statistics

References

AlAgha, I. (2015). Using Linguistic Analysis to Translate Arabic Natural Language Queries to SPARQL. International Journal of Web & Semantic Technology, 6(3), 25–39. https://doi.org/10.5121/ijwest.2015.6303

Almeida, J. P. A., Guizzardi, G., Sales, T. P., & Fonseca, C. M. (2026). gUFO: A Gentle Foundational Ontology for Semantic Web Knowledge Graphs. arXiv preprint. https://doi.org/10.48550/arXiv.2603.20948

Anuyah, S., Kaushik, M. M., Dwarampudi, K., Shiradkar, R., Durresi, A., & Chakraborty, S. (2025). Automated Knowledge Graph Construction using Large Language Models and Sentence Complexity Modelling. https://doi.org/10.18653/v1/2025.emnlp-main.783

Brown, A., Roman, M., & Devereux, B. (2025). A Systematic Literature Review of Retrieval-Augmented Generation: Techniques, Metrics, and Challenges. Big Data and Cognitive Computing, 9(12), 320. https://doi.org/10.3390/bdcc9120320

Di, Z., Zhang, C., Lv, H., Cui, L., & Liu, L. (2025). LoRP: LLM-based Logical Reasoning via Prolog. Knowledge-Based Systems, 327, 114140. https://doi.org/10.1016/j.knosys.2025.114140

García-Montero, P. S., Orellana, M., & Zambrano-Martinez, J. L. (2025). Enriching Dataset Metadata with LLMs to Unlock Semantic Meaning. In Conference on Information and Communication Technologies of Ecuador (pp. 63 –77). Cham: Springer Nature Switzerland. https://doi.org/10.1007/978-3-032-08366-1_5

Garg, M., Wang, L.-C., Ghanchi, B., Dumpala, S., Kakde, S., & Chen, Y. C. (2025). Biomedical Literature Q&A System Using Retrieval-Augmented Generation (RAG).

Glimm, B., Horrocks, I., Motik, B., Stoilos, G., & Wang, Z. (2014). HermiT: An OWL 2 Reasoner. Journal of Automated Reasoning, 53(3). https://doi.org/10.1007/s10817-014-9305-1

Grattafiori, A., Dubey, A., Jauhri, A., Pandey, A., Kadian, A., Al-Dahle, A., Letman, A., Mathur, A., Schelten, A., Vaughan, A., Yang, A., Fan, A., Goyal, A., Hartshorn, A., Yang, A., Mitra, A., Sravankumar, A., Korenev, A., Hinsvark, A., … Ma, Z. (2024). The Llama 3 Herd of Models. https://arxiv.org/abs/2407.21783

Gruber, T. R. (1993). A translation approach to portable ontology specifications. Knowledge Acquisition, 5(2). https://doi.org/10.1006/knac.1993.1008

Harris, S., & Seaborne, A. (2013). SPARQL 1.1 Query Language. W3C Recommendation.

Hogan, A., Blomqvist, E., Cochez, M., D’amato, C., Melo, G. De, Gutierrez, C., Kirrane, S., Gayo, J. E. L., Navigli, R., Neumaier, S., Ngomo, A.-C. N., Polleres, A., Rashid, S. M., Rula, A., Schmelzeisen, L., Sequeda, J., Staab, S., & Zimmermann, A. (2021). Knowledge Graphs. ACM Computing Surveys, 54(4), 1 –37. https://doi.org/10.1145/3447772

Ji, Z., Lee, N., Frieske, R., Yu, T., Su, D., Xu, Y., Ishii, E., Bang, Y. J., Madotto, A., & Fung, P. (2023). Survey of Hallucination in Natural Language Generation. En ACM Computing Surveys, 55(12). https://doi.org/10.1145/3571730

Kabbaj, A., Frasson, C., Kaltenbach, M., & Djamen, J.-Y. (1994). A conceptual and contextual object-oriented logic programming: The PROLOG++ language (pp. 251-274). https://doi.org/10.1007/3-540-58328-9_17

Kim, S., Song, H., Seo, H., & Kim, H. (2025). Optimizing Retrieval Strategies for Financial Question Answering Documents in Retrieval-Augmented Generation Systems.

Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Küttler, H., Lewis, M., Yih, W. T., Rocktäschel, T., Riedel, S., & Kiela, D. (2020). Retrieval-augmented generation for knowledge-intensive NLP tasks. Advances in Neural Information Processing Systems, 2020-December.

Liu, Y., Cao, Y., Lin, X., Shang, Y., Wang, S., & Pan, S. (2025). Enhancing Large Language Model for Knowledge Graph Completion via Structure-Aware Alignment-Tuning. Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing, 20981–20995. https://doi.org/10.18653/v1/2025.emnlp-main.1061

Mishra, D. S., Agarwal, A., Swathi, B. P., & Akshay, K. C. (2022). Natural language query formalization to SPARQL for querying knowledge bases using Rasa. Progress in Artificial Intelligence, 11(3), 193–206. https://doi.org/10.1007/s13748-021-00271-1

Musen, M. A. (2015). The protégé project. AI Matters, 1(4), 4–12. https://doi.org/10.1145/2757001.2757003

Noy, N. F., & McGuinness, D. L. (2001). Ontology Development 101: A Guide to Creating Your First Ontology. En Stanford Knowledge Systems Laboratory.

https://protege.stanford.edu/publications/ontology_development/ontology101.pdf

Paltin Chica, D. L., Mejía Mendieta, J. D., Orellana, M., & Zambrano-Martinez, J. L. (2025). Semantic Modeling of ECU 911 Emergencies Using NLP and Ontologies. Revista Tecnológica - Espol, 37(E1), 112–125. https://doi.org/10.37815/rte.v37nE1.1351

Procko, T. T., & Ochoa, O. (2024). Graph Retrieval-Augmented Generation for Large Language Models: A Survey. Proceedings - 2024 Conference on AI, Science, Engineering, and Technology, AIxSET 2024. https://doi.org/10.1109/AIxSET62544.2024.00030

Rajesh, V., Jodhpurkar, O., Anbuselvan, P., Singh, M., Jallepali, A., Godbole, S., Sharma, P. K., & Shrivastava, H. (2025). Production-Grade Local LLM Inference on Apple Silicon: A Comparative Study of MLX, MLC-LLM, Ollama, llama.cpp, and PyTorch MPS.

RDFLib Team. (2026). rdflib: A Python library for working with RDF. RDFLib. https://rdflib.readthedocs.io/en/stable/

Sheth, A., Gaur, M., Roy, K., & Faldu, K. (2021). Knowledge-Intensive Language Understanding for Explainable AI. IEEE Internet Computing, 25(5). https://doi.org/10.1109/MIC.2021.3101919

Vogt, L., Farfar, K. E., Karanth, P., Konrad, M., Oelen, A., Prinz, M., & Stroemert, P. (2026). Rosetta Statements: Simplifying FAIR Knowledge Graph Construction with a User-Centered Approach. https://doi.org/10.1093/database/baag030

Wampler, D., Nielson, D., & Seddighi, A. (2025). Engineering the RAG Stack: A Comprehensive Review of the Architecture and Trust Frameworks for Retrieval-Augmented Generation Systems. arXiv preprint. https://doi.org/10.48550/arXiv.2601.05264

Wielemaker, J., Schrijvers, T., Triska, M., & Lager, T. (2012). SWI-Prolog. Theory and Practice of Logic Programming, 12(1–2), 67–96. https://doi.org/10.1017/S1471068411000494

World Wide Web Consortium. (2012). OWL 2 Web Ontology Language document overview. World Wide Web Consortium.

Zheng, C., Chen, X., Xu, R., & Chang, B. (2022). A Double-Graph Based Framework for Frame Semantic Parsing. https://doi.org/10.18653/v1/2022.naacl-main.368