GPT4Graph: Can Large Language Models Understand Graph Structured Data ? An Empirical Evaluation and Benchmarking

Jiayan Guo, Lun Du, Hengyu LiuarXiv 2023 · DOI

TL;DR

This paper empirically evaluates how well Large Language Models (LLMs) like GPT-4 can understand and process graph-structured data, a crucial component for Artificial General Intelligence (AGI). The authors introduce a novel framework and a comprehensive benchmark across ten diverse tasks, revealing both the potential and significant limitations of current LLMs in this domain, highlighting the need for further research.

What Problem Does This Paper Address?

While LLMs have shown remarkable success in natural language processing, their ability to understand and reason over graph-structured data—which is ubiquitous in fields like social networks, drug discovery, and recommender systems—remains largely unexplored. Graphs, with their complex interdependencies between entities (nodes) and relationships (edges), present a unique challenge compared to the sequential text LLMs are trained on. Existing research has primarily focused on tabular data, leaving a gap in understanding LLM performance on the more intricate structure of graphs. This paper aims to bridge this gap by systematically evaluating LLMs on a broad spectrum of graph-related tasks.

Methods

The authors propose a framework that integrates LLMs with graph-structured data. This involves converting graph data into a "graph description language" (GDL) that LLMs can process. A "prompt handler" then combines this GDL with user queries to form the input for the LLM. The paper explores two primary prompting strategies:

  • Manual Prompting: This involves using familiar graph representations (like edge lists or adjacency lists) as input, along with explicit format explanations and role-prompting to guide the LLM.
  • Self-Prompting: This technique allows the LLM to generate its own prompts to better understand or summarize the graph context, especially when the initial input is insufficient or contains irrelevant information. Strategies include context summarization and format explanation.

The research also investigates the impact of input design, including the placement of external knowledge (e.g., questions, examples) relative to the graph input.

Datasets

The paper utilizes several datasets for evaluation:

  • Structure Understanding Tasks:
    • obgn-arxiv: A citation network dataset from the Open Graph Benchmark (OGB).
  • Aminer: Another citation network dataset.
  • Semantic Understanding Tasks:
    • Wiki: A dataset based on Wikipedia articles, adapted for graph-based tasks.
  • MetaQA: A dataset designed for multi-hop question answering over movie knowledge graphs.
  • OGBG-MOLHIV and OGBG-MOLPCBA: Datasets from OGB for graph classification tasks (predicting molecule properties).

The authors establish a benchmark comprising ten common graph-related tasks, covering both structural and semantic understanding.

Key Insights and Ideas

  • LLMs have nascent graph understanding capabilities: While not perfect, LLMs can perform basic graph tasks, indicating their potential.
  • Input design is critical: The way graph data and queries are presented to the LLM significantly impacts performance. This includes the format of the graph representation and the inclusion of external context.
  • Role prompting enhances performance: Explicitly guiding the LLM to adopt a specific role (e.g., "graph master") improves its ability to understand graph structures and relationships.
  • Examples can be a double-edged sword: While examples can help, sometimes omitting them and relying on zero-shot learning yields better results, possibly because LLMs can infer more from the inherent graph structure itself without being misled by potentially noisy or incomplete examples.
  • External knowledge placement matters: Positioning external context before the graph input generally leads to better performance, providing the LLM with a clearer understanding of the task.
  • Self-prompting is a promising avenue: LLMs can be leveraged to improve their own understanding of graph data by generating clarifying context or summaries.

Key Results

The empirical results reveal a mixed picture:

  • Structure Understanding: LLMs showed varying performance across tasks like size detection, degree detection, and attribute retrieval. For instance, on OGBN-ARXIV, accuracy varied significantly depending on the input format (Adjacency List, Edge List, GML, GraphML) and prompting strategy. For example, "1-shot" settings generally performed better than "0-shot."
  • Semantic Understanding:
    • KGQA and GQL Generation: LLMs achieved impressive scores on MetaQA datasets (up to 98.80 on MetaQA-2hop), often surpassing SOTA models with specific prompt strategies like "one-shot Cypher Generation" reaching 99.00.
  • Node Classification: The "one-shot + 2-hop neighborhood context summarization" model achieved the highest accuracy (60.00) on OGBN-ARXIV, suggesting that broader context is beneficial.
  • Graph Classification: Self-augmentation techniques (like self-format explanation and self-summarization) were found to be effective in improving performance.

Limitations and Future Work

  • Limitations: The paper acknowledges that LLMs still have a "substantial need for further development" to match specialized graph-oriented models. The complexity of graph data and the challenge of designing effective input formats and prompts are highlighted. The effectiveness of certain strategies, like "change-order" and "zero-shot-cot," was inconsistent across tasks.
  • Future Work: The authors suggest several directions:
  • Further research into input design and role-prompting techniques.
  • Investigating why examples are less effective for graph understanding and exploring alternative strategies.
  • Exploring the optimal placement of external knowledge.
  • Developing new approaches for graph augmentation to improve semantic understanding.
  • Integrating graph-based information more deeply into LLMs and applying them to broader areas like graph theory and network science.
  • Exploring the use of LLMs to control external tools for enhanced graph reasoning.

Summary updated

BibTeX
@misc{guo2023gpt,
  author = {Jiayan Guo and Lun Du and Hengyu Liu},
  title = {{GPT4Graph: Can Large Language Models Understand Graph Structured Data ? An Empirical Evaluation and Benchmarking}},
  year = {2023},
  eprint = {2305.15066},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.15066},
}
Figure