Design and Development of a Knowledge-Graph based System to Enhance Large Language Models in Retrieval-Augmented Generation Scenarios

Cristina Martin Nieto. (2025). Design and Development of a Knowledge-Graph based System to Enhance Large Language Models in Retrieval-Augmented Generation Scenarios. Trabajo Fin de Titulación (TFG). Universidad Politécnica de Madrid, ETSI Telecomunicación.

Abstract:
This bachelor thesis addresses some limitations of Large Language Models (LLMs), such as hallucinations (generation of non-factual content) and the difficulty of updating their knowledge, by exploring the use of knowledge bases. To mitigate these problems, the project proposes the design and development of a system based on Knowledge Graphs (KGs) to improve LLMs in Retrieval-Augmented Generation (RAG) scenarios. This approach aligns with the ACKnowledge project, which seeks accu- rate, transparent, and auditable virtual assistants. The solution implements a modular and scalable RAG-based architecture that integrates LLMs with structured knowledge sources, both internal and external. The system processes natural language questions through a hierarchical retrieval flow, prioritizing structured KGs. A local Neo4j database supplied by an Offline Loader is used to transform unstructured text into KGs. In addition, it connects to external and open knowledge sources such as Wikidata and DBpedia to complement the local database. If no structured source provides an answer, the system falls back on an LLM as a backup. The system was evaluated using RAG-specific metrics such as factual correctness (FC) and semantic similarity (SS). The results demonstrated a consistent improvement in the quality of responses by integrating more knowledge sources. A case study in the university domain validated the system’s performance. In summary, this project combines the generative capacity of LLMs with the reliability and traceability of KGs to develop more explainable and knowledge-centric Artificial Intel- ligence. The results validate the feasibility of a hybrid architecture to improve accuracy, robustness, and transparency in response generation.