Large language models can better understand knowledge graphs than we thought

Xinbang Dai, Yuncheng Hua, Tongtong Wu, Yang Sheng, Qiu Ji, Guilin Qi · DOI

TL;DR

This paper investigates how Large Language Models (LLMs) best process and interpret knowledge graph (KG) information when integrated via prompts. They discover that LLMs generally perform better with linearized triples than with natural language text, and that larger LLMs are more susceptible to noisy or incomplete KG data.

What Problem Does This Paper Address?

Integrating factual knowledge from knowledge graphs (KGs) into Large Language Models (LLMs) can significantly improve their performance, especially in reducing hallucinations and enhancing factual accuracy. However, the process of injecting this KG information into LLMs, particularly through prompt engineering, is complex and not fully understood. Researchers often rely on trial-and-error to find effective prompt strategies. A key challenge is understanding how LLMs interpret KG information presented in different formats (e.g., linearized triples vs. natural language) and organizations within prompts, and how this impacts their performance on fact-intensive tasks. This paper aims to bridge this gap by empirically studying LLMs' comprehension of various KG prompt formats and organizations.

Methods

The authors employ a multi-faceted experimental approach to understand LLM comprehension of KGs:

  • Triple-to-Text Pipeline: This pipeline tests LLMs' understanding of KGs by gradually converting KG subgraphs into natural language (NL) text generated by the model. This allows for evaluation across different scales and input formats.
  • Text-to-Triple Pipeline: To address potential quality issues in model-generated NL text, this pipeline uses manually written NL text and manually annotated KG subgraphs. This allows for a more controlled comparison between NL text and KG input.
  • Attention Distribution Analysis: The authors analyze the attention distribution of LLMs to understand why certain input formats are preferred. This reveals where LLMs focus their attention when processing KG information.
  • Subgraph Expansion: To study the impact of KG subgraph size, they use methods like "Core Reasoning Path Generation" and "Controlled Neighbor Node Search" to control the scale of the KG subgraph provided to the LLM.
  • Prompt Strategies: They design and evaluate various prompt strategies for linearized triples, including grouping, ranking, and scoring based on question relevance, to see how organization impacts LLM performance.
  • Robustness Evaluation: They systematically corrupt KG subgraphs by replacing or deleting nodes to assess LLM robustness to noisy or incomplete knowledge.

Datasets

The study utilizes several KGQA (Knowledge Graph Question Answering) datasets derived from Wikidata:

  • QALD-7: A smaller dataset with 64 questions after filtering.
  • LC-QuAD 2.0: A larger dataset from which 2000 questions were randomly selected.
  • KQAPro: Another large dataset from which 2000 questions were randomly selected.

Additionally, for the Text-to-Triple experiments, they use:

  • DocRED: A large-scale document-level relation extraction dataset with human-written documents and manually annotated triples.
  • ChemDisGene: A dataset of biomedical paper abstracts with manually curated triples.

Key Insights and Ideas

  • Linearized Triples Trump Natural Language: For fact-intensive questions, LLMs consistently perform better when provided with linearized triples rather than fluent natural language text. This suggests that the structured, explicit nature of triples is more directly interpretable by LLMs for factual recall.
  • Order Doesn't Always Matter (for Triples): Unordered linearized triples are often as effective, if not more so, than sorted ones. This implies that the inherent structure of the triple itself is more critical than its sequential order within a prompt.
  • Attention Reveals Preference: LLMs show a stronger attention bias towards linearized triples, even when both triple and NL formats are provided. This supports the idea that LLMs find the explicit relational information in triples more salient for answering questions.
  • Larger Models are More Fragile: Surprisingly, larger LLMs (with more parameters) are more susceptible to performance degradation when faced with noisy or incomplete KG data. This suggests a trade-off between model scale and robustness to external knowledge.
  • Noise is Worse Than Incompleteness: Randomly replacing nodes (introducing incorrect facts) has a more significant negative impact on LLM performance than randomly deleting nodes (creating incompleteness). This highlights the sensitivity of LLMs to factual inaccuracies.

Key Results

  • In the Triple-to-Text pipeline, unordered linearized triples consistently outperformed NL text across various LLMs and datasets, especially for multi-hop questions. For example, on LC-QuAD 2.0 and KQAPro, the performance gap between linearized triples and NL text widened as question complexity increased.
  • Attention analysis showed that LLMs consistently paid a higher attention ratio to linearized triples, even when NL text was also provided. For instance, in Table 2, average attention proportions for linearized triples were generally higher than for NL text across different LLMs and datasets.
  • In robustness experiments (Table 5), ChatGPT exhibited greater performance degradation due to node replacement and deletion compared to smaller Vicuna models. For example, with a 30% replacement ratio, ChatGPT's performance dropped significantly more than Vicuna 7B or 13B.

Limitations and Future Work

  • LLM Preferences Vary: The study found that different LLM series exhibit unique preferences for prompt strategies (e.g., ChatGPT favoring scoring, Vicuna favoring ranking). This suggests a need for more universal prompting techniques that work across a wider range of LLMs.
  • Larger LLMs' Susceptibility: The finding that larger LLMs are more susceptible to noisy KG data is a significant limitation. Future work should explore strategies to improve the robustness of these larger models.
  • Domain-Specific Knowledge: The paper notes a performance decline on domain-specific KGs compared to general KGs, likely due to LLMs' limited exposure to specialized knowledge during pre-training. Future research could focus on better integrating domain-specific knowledge.
  • Universal Prompting: The authors emphasize the need for further research into designing prompt strategies that are universally applicable across different LLMs.

Summary updated

BibTeX
@article{dai2025large,
  author = {Xinbang Dai and Yuncheng Hua and Tongtong Wu and Yang Sheng and Qiu Ji and Guilin Qi},
  title = {{Large language models can better understand knowledge graphs than we thought}},
  journal = {Knowledge-Based Systems},
  year = {2025},
  doi = {10.1016/j.knosys.2025.113060},
}
Figure