Few-Shot Graph Out-of-Distribution Detection with LLMs

Haoyan Xu, Zhengtao Yao, Yushun Dong, Ziyi Wang, Ryan A. Rossi, Mengyuan Li, Yue Zhao

Introduction

In real-world graph machine learning applications—ranging from social network analysis to citation graph classification—models frequently encounter "Out-of-Distribution" (OOD) nodes. These are data points that do not belong to any of the categories seen during training. Detecting and isolating these nodes is essential for maintaining the reliability and safety of AI systems. However, traditional graph OOD detection methods rely heavily on large-scale, high-quality labeled datasets of "In-Distribution" (ID) nodes.

For text-attributed graphs (TAGs), the labeling process is particularly arduous, requiring human experts to parse complex textual information and structural context. While Large Language Models (LLMs) have shown promise in zero-shot text classification, they lack an inherent understanding of graph topology and are too expensive to deploy across million-node datasets. This paper introduces LLM-GOOD (LLM-Graph Out-Of-Distribution), a framework designed to achieve high-accuracy OOD detection and ID classification under a strictly limited human annotation budget.

The LLM-GOOD Framework

LLM-GOOD addresses the labeling bottleneck through a strategic hand-off between LLMs, GNNs, and human annotators. The pipeline consists of five key stages:

  1. LLM Zero-Shot Pre-filtering: The process begins by selecting a small, random subset of unlabeled nodes. An LLM (such as GPT-4o-mini) evaluates these nodes based solely on their text attributes, categorizing them into known ID classes or flagging them as "none" (OOD).
  2. Lightweight GNN Filter: To avoid the prohibitive cost of querying an LLM for every node in the graph, the framework trains a lightweight, 2-layer Graph Convolutional Network (GCN) on the noisy LLM-generated labels. This GNN propagates the LLM's textual insights across the graph's edges, learning to predict the ID/OOD status for the entire graph by integrating structural features.
  3. Informativeness-Aware Selection: Using node embeddings from the GNN filter, the system identifies likely-ID nodes. It then employs a selection strategy (e.g., K-Medoids clustering) to pick the most mathematically informative nodes for human review.
  4. Human Annotation: Human experts label this highly curated, tiny subset. Because the LLM and GNN have already filtered out likely OOD nodes, the human budget is spent exclusively on the most valuable ID data.
  5. Final Training: The target ID classifier is trained using these high-quality human labels. In scenarios with extreme data scarcity, the model can also incorporate the initial noisy LLM labels to bolster performance.

Overcoming the Active Learning Trap

A significant contribution of this work is solving what the authors call the "Active Learning Trap." Traditional active learning strategies prioritize nodes that the model is most uncertain about. In an open-world setting, OOD nodes are inherently the most "uncertain" because they do not fit any known class. Consequently, standard active learning often wastes the entire human budget on irrelevant OOD data. By using an LLM to prune OOD nodes before human intervention, LLM-GOOD ensures that human effort is focused on refining the boundaries of known classes.

Experimental Results

The authors evaluated LLM-GOOD on four benchmark TAG datasets: Cora, Citeseer, Pubmed, and Wiki-CS. The experiments simulated a low-resource environment with budgets as small as 5 to 10 labels per class ($K$).

Performance Gains

The framework demonstrated substantial improvements over existing baselines like GNNSafe:

  • Cora: With a $5 \times K$ budget, LLM-GOOD achieved an ID classification accuracy of 81.52%, outperforming the best baseline (63.80%) by nearly 18 percentage points.
  • Pubmed: At a $10 \times K$ budget, the AUROC for OOD detection reached 64.87%, compared to 57.91% for the best baseline.

Cost Efficiency

The use of LLMs in this pipeline is remarkably economical. By using GPT-4o-mini to annotate only the initial 200 seed nodes, the cost was approximately $0.02. This demonstrates that LLMs can be used as high-leverage "cheap annotators" when combined with GNNs that handle the heavy lifting of structural propagation.

Conclusion and Future Directions

LLM-GOOD proves that the synergy between the textual reasoning of LLMs and the structural learning of GNNs can overcome the data scarcity challenges in graph OOD detection. While the results are promising, the authors identify two key areas for future research:

  • Noise-Resistant Architectures: Developing GNNs that can explicitly distinguish between ground-truth human labels and noisy LLM pseudo-labels.
  • Advanced Prompting: Exploring in-context learning and few-shot prompting to further enhance the accuracy of the initial LLM pre-filtering stage.

By effectively bypassing the active learning trap and leveraging the low cost of modern LLMs, LLM-GOOD sets a new standard for efficient, reliable graph machine learning in the open world.

Summary updated

BibTeX
@inproceedings{xu2025few,
  author = {Haoyan Xu and Zhengtao Yao and Yushun Dong and Ziyi Wang and Ryan A. Rossi and Mengyuan Li and Yue Zhao},
  title = {{Few-Shot Graph Out-of-Distribution Detection with LLMs}},
  booktitle = {ECML/PKDD},
  year = {2025},
  doi = {10.1007/978-3-032-06078-5\_18},
}

Loading related content...

Figure