Generalization Principles for Inference over Text-Attributed Graphs with Large Language Models

Haoyu Peter Wang, Shikun Liu, Rongzhe Wei, Pan LiICML 2025

TL;DR

LLM-BP is a novel, training-free framework that brings robust zero-shot reasoning to Text-Attributed Graphs (TAGs). By combining task-adaptive embeddings with a classic Belief Propagation algorithm—guided by an LLM "agent" to estimate graph structure—it significantly outperforms existing graph-learning methods across diverse domains without requiring any fine-tuning.

The Challenge with Text-Attributed Graphs

Text-Attributed Graphs (TAGs), such as citation networks or e-commerce platforms, combine rich textual data with complex structural relationships. While Large Language Models (LLMs) excel at zero-shot text reasoning, they struggle when applied to graphs due to two main hurdles:

  1. Context Constraints: Standard LLM context windows cannot accommodate large, complex node neighborhoods.
  2. Domain Misalignment: Existing "graph-adapter" methods use projectors to map graph data into the LLM token space. However, these adapters are often trained on specific datasets (like academic papers) and overfit. When applied to a new domain (like financial records), they fail to generalize, sometimes performing worse than simple text encoders.

To address this, the authors move away from heuristic "black-box" adapters and propose a framework built on first-principles generalization.

The LLM-BP Framework

The authors introduce LLM-BP, a framework structured around two core principles to unify text and graph spaces effectively.

Overview of the LLM-BP framework

Principle I: Task-Adaptive Embeddings

Instead of relying on static embeddings (like SBERT), the authors utilize an LLM-based encoder (LLM2Vec). They introduce a specialized prompting strategy that incorporates the task description and class information directly during the encoding process. This conditions the embeddings, ensuring that the vector representation of a node is specifically tailored to the classification task at hand. Visualizations in the study demonstrate that this task-awareness creates much tighter, more distinct clusters for the same class compared to standard encoders.

Principle II: Generalizable Graph Aggregation

To process graph structures without hitting LLM context limits, the framework employs Belief Propagation (BP), a classic algorithm for inference on Markov Random Fields.

  • The LLM Agent: BP requires an "edge potential" to understand how likely connected nodes are to share a label. The authors deploy an LLM to analyze a small sample of edges and estimate the homophily ratio (the tendency of similar nodes to connect).
  • Message Passing: This LLM-estimated ratio guides a training-free message-passing process that aggregates information across the entire graph.

Key Insights and Results

The framework was evaluated on 11 real-world TAG benchmarks, encompassing citation networks (Cora, Citeseer, Pubmed), e-commerce/knowledge graphs (History, Children, Sportsfit, Wikics), and heterophilic webpage networks (Cornell, Texas, Wisconsin, Washington).

LLM agent homophily estimation vs. ground truth
  • Algorithmic Adaptivity: By using an LLM to estimate the homophily ratio, the model dynamically adapts its logic. If the LLM detects a heterophilic graph (where neighbors are often different, like a webpage network), the BP algorithm adjusts how it treats a neighbor's "signal." This allows LLM-BP to maintain strong performance where traditional Graph Neural Networks (GNNs) often fail.
  • State-of-the-Art Zero-Shot Performance: LLM-BP achieved the highest average ranking across all 11 datasets.
  • Quantitative Gains: The task-conditional embeddings provided an 8.10% improvement over the best LM-based encoders, while the adaptive BP aggregation added an additional 1.71% gain.
  • Efficiency: Because the framework requires zero training or fine-tuning, it is highly "plug-and-play" for new graph tasks.

Limitations and Future Work

While highly effective, the current framework focuses primarily on node classification. Its success also heavily depends on the quality of the LLM used as the agent; while models like GPT-4o-mini perform well at estimating homophily, smaller models (like Mistral-7B) struggle. Finally, the authors used a single homophily ratio as a proof of concept. Future iterations could leverage LLMs to estimate more complex, category-to-category edge probability matrices, further refining the Belief Propagation process.

Summary updated

BibTeX
@inproceedings{wang2025generalization,
  author = {Haoyu Peter Wang and Shikun Liu and Rongzhe Wei and Pan Li},
  title = {{Generalization Principles for Inference over Text-Attributed Graphs with Large Language Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=dfOqiHuklY},
}
Figure