Generating Knowledge Graphs from Large Language Models: A Comparative Study of GPT-4, LLaMA 2, and BERT

  • 2024-12-10 11:05:26
  • Ahan Bhatt, Nandan Vaghela, Kush Dudhia
  • 0

Abstract

Knowledge Graphs (KGs) are essential for the functionality of GraphRAGs, aform of Retrieval-Augmented Generative Systems (RAGs) that excel in tasksrequiring structured reasoning and semantic understanding. However, creatingKGs for GraphRAGs remains a significant challenge due to accuracy andscalability limitations of traditional methods. This paper introduces a novelapproach leveraging large language models (LLMs) like GPT-4, LLaMA 2 (13B), andBERT to generate KGs directly from unstructured data, bypassing traditionalpipelines. Using metrics such as Precision, Recall, F1-Score, Graph EditDistance, and Semantic Similarity, we evaluate the models' ability to generatehigh-quality KGs. Results demonstrate that GPT-4 achieves superior semanticfidelity and structural accuracy, LLaMA 2 excels in lightweight,domain-specific graphs, and BERT provides insights into challenges inentity-relationship modeling. This study underscores the potential of LLMs tostreamline KG creation and enhance GraphRAG accessibility for real-worldapplications, while setting a foundation for future advancements.