Knowledge graphs and vectorization as means for injecting knowledge into large language models

Thesis title: Znalostní grafy a vektorizace jako prostředky injekce znalostí do velkých jazykových modelů
Author: Holota, Jan
Thesis type: Diplomová práce
Supervisor: Zeman, Václav
Opponents: Svátek, Vojtěch
Thesis language: Česky
Abstract:
Tato diplomová práce se zaměřuje na porovnání dvou přístupů pro úlohu Retrieval Augmented Generation, která pomáhá s využitím velkých jazykových modelů pro dotazování se na údaje faktografického typu, a to nejen v interních dokumentech. Jedním z přístupů je využití prosté vektorizace plného textu dokumentů. Tento přístup je v praxi běžný, ovšem dle výsledků této práce vykazuje některé nepříznivé vlastnosti, jako je například přílišná tendence halucinovat v důsledku nerelevantního poskytnutého kontextu. V těchto systémech je také obtížné provést disambiguaci pojmenovaných entit, o nichž se v otázce hovoří. Druhým přístupem je využití znalostních grafů. V této práci jsou znalostní grafy využívány jako znalostní báze, přičemž jsou modelu předkládány RDF triply. Tento přístup zajišťuje možnost implementace disambiguačního modulu, který dokáže fungovat jak v manuálním módu vyžadujícím spolupráci uživatele, tak i v automatickém módu. To zajišťuje vyšší důvěryhodnost celého systému, protože dokáže poměrně dobře rozpoznat potřebnou pojmenovanou entitu a odpovídat pouze na základě informací o této entitě (úspěšnost disambiguace 86,4 % v manuálním a 73,2 % v automatickém módu). V této práci byl systém založený na prosté vektorizaci plných textů implementován jednak pomocí SOTA frameworku Langchain, a dále pomocí autorovy vlastní implementace vytvořené na základě rešerše řešení naivního RAG. Systém na základě znalostních grafů byl navržen autorem a implementován ve dvou formách - automatická a manuální disambiguace. Pro srovnání obou systémů byl vytvořen dataset čítající 1090 otázek, které byly založeny na stejném informačním základu – datech z článků Wikipedie a ze znalostního grafu Wikidata. Bylo pečlivě zohledněno, aby se odpověď na každou otázku v obou zdrojích skutečně vyskytovala. Následně bylo ručně vyhodnoceno několik různých kritérií, která byla stanovena autorem práce. Bylo zjištěno, že s využitím triplů lze úspěšnost vyhledání relevantního kontextu zvýšit oproti vektorizaci plných textů o přibližně 25 %. Také je nutné uvést, že procento správných a relevantních tvrzení v odpovědích na otázky ze všech tvrzení v odpovědích činilo u grafově založených řešení 82,7 % a 84 %, zatímco u prosté vektorizace textu tomu bylo jen 42,4 % a 53 %. Přístup s využitím znalostních grafů také vykazoval značně vyšší důvěryhodnost odpovědí, neboť převážná většina (87 % a 88,7 %) tvrzení byla podložena kontextem, zatímco u přístupu založeného na plných textech tomu tak bylo jen v 35,4 % a 54,3 % v závislosti na použité architektuře.
Keywords: RAG; disambiguace; velký jazykový model; znalostní graf
Thesis title: Knowledge graphs and vectorization as means for injecting knowledge into large language models
Author: Holota, Jan
Thesis type: Diploma thesis
Supervisor: Zeman, Václav
Opponents: Svátek, Vojtěch
Thesis language: Česky
Abstract:
This thesis focuses on comparing two approaches for the task of Retrieval-Augmented Generation (RAG), which facilitates querying factual data using large language models—not only within internal documents. One of the approaches involves the simple vectorization of full-text documents. This method is common in practice; however, according to the findings of this thesis, it exhibits certain unfavorable characteristics, such as a high tendency to hallucinate due to the provision of irrelevant context. These systems also struggle with named entity disambiguation when the question involves ambiguous entities. The second approach involves the use of knowledge graphs. In this work, knowledge graphs are utilized as knowledge bases, with RDF triples presented to the model. This method allows for the implementation of a disambiguation module that can operate in both manual and automatic modes. This results in higher reliability of the system, as it can effectively recognize the required named entity and respond solely based on information related to that entity—achieving a disambiguation success rate of 86.4 % in manual mode and 73.2 % in automatic mode. The system based on simple vectorization of full texts was implemented using both the SOTA Langchain framework and a custom implementation developed by the author, based on research into naive RAG solutions. The knowledge graph-based system was designed by the author and implemented in two variants—manual and automatic disambiguation. To compare the two systems, a dataset of 1,090 questions was created, all based on the same informational foundation—data from Wikipedia articles and the Wikidata knowledge graph. It was carefully ensured that the answer to each question was actually present in both sources. Several evaluation criteria, defined by the author, were manually assessed. It was found that the use of triples increased the success rate of retrieving relevant context by approximately 25 % compared to full-text vectorization. Additionally, the percentage of correct and relevant statements in the answers—out of all statements made—was 82.7 % and 84 % for the graph-based solutions, whereas for the text vectorization approach, it was only 42.4 % and 53 %. The knowledge graph-based approach also showed significantly higher trustworthiness of answers, as the vast majority (87 % and 88.7 %) of statements were supported by context, compared to only 35.4 % and 54.3 % for the full-text approach, depending on the architecture used.
Keywords: RAG; knowledge graph; disambiguation; large language model

Information about study

Study programme: Znalostní a webové technologie
Type of study programme: Magisterský studijní program
Assigned degree: Ing.
Institutions assigning academic degree: Vysoká škola ekonomická v Praze
Faculty: Faculty of Informatics and Statistics
Department: Department of Information and Knowledge Engineering

Information on submission and defense

Date of assignment: 12. 3. 2024
Date of submission: 4. 5. 2025
Date of defense: 2025

Files for download

The files will be available after the defense of the thesis.

    Last update: