Abstract
Detecting out-of-distribution (OOD) nodes in Text-Attributed Graphs (TAGs) is a critical task for ensuring the reliability of Graph Neural Networks (GNNs). Existing methods often rely on "easy" synthetic outliers that fail to define precise decision boundaries. We present LLMGuard, a novel framework that leverages Large Language Models (LLMs) to generate "hard" OOD nodes—samples that are semantically related to in-distribution (ID) data but belong to distinct categories. LLMGuard further integrates these nodes into the graph structure using an efficient two-stage edge completion process. Experimental results across four benchmarks demonstrate that LLMGuard significantly improves OOD detection performance, achieving state-of-the-art results while maintaining computational efficiency.
Introduction
In real-world applications, Text-Attributed Graphs (TAGs) such as citation networks and social media platforms frequently encounter out-of-distribution (OOD) data. Standard GNN-based classifiers trained on a fixed set of in-distribution (ID) labels often produce overconfident and incorrect predictions for OOD samples. While training detectors with auxiliary OOD data is a common strategy, the quality of these outliers is paramount. Most existing approaches utilize "easy" outliers that are semantically distant from ID data, leading to loose decision boundaries. To build robust systems, models require "hard" OOD samples that reside near the decision boundary. However, generating such samples and integrating them into large-scale graphs poses significant semantic and computational challenges.
Methodology
LLMGuard addresses these challenges through a two-stage process: LLM-Guided Hard OOD Node Synthesis and Two-Staged OOD Edge Completion.
1. Hard OOD Node Synthesis
Instead of random text generation, LLMGuard prompts an LLM to identify "hard" labels semantically adjacent to ID categories (e.g., mapping "Machine Learning" to "Data Mining"). Using an ID "anchor" node and its local subgraph context, the LLM generates node text that fits the structural context while adhering to the new OOD label. This ensures the generated nodes are not only semantically challenging but also structurally plausible.
2. Two-Staged OOD Edge Completion
Integrating new nodes into a graph requires determining potential edges, an $O(N^2)$ problem if handled by direct LLM inference. LLMGuard circumvents this by fine-tuning a local LLM (e.g., Vicuna) to distinguish between ID and OOD nodes. The embeddings from this local model are then used to train lightweight Multi-Layer Perceptron (MLP) edge predictors. This distillation process enables high-speed edge generation suitable for large-scale graphs.
Experimental Setup
The framework was evaluated on four standard TAG benchmarks: Cora, Arxiv, Products-subset, and WikiCS. For each dataset, specific classes were held out as ground-truth OOD data during testing, while LLMGuard generated synthetic outliers for training the detectors.
Key Results and Analysis
LLMGuard consistently outperformed both classical OOD detection methods and state-of-the-art graph-specific models, such as GNNSAFE++ and NodeSAFE++.
- Detection Accuracy: On the Cora dataset, LLMGuard achieved an AUROC of 96.09%, a significant improvement over the 92.74% achieved by previous top-tier methods.
- False Positive Reduction: The FPR95 (the rate of OOD samples misclassified as ID when 95% of ID samples are correctly caught) dropped to 23.14% on Cora, compared to over 30% for baselines.
- Computational Efficiency: The distillation of LLM reasoning into MLP edge predictors yielded massive efficiency gains. While a direct LLM call took approximately 10 seconds per edge, the LLMGuard MLP predictor took only 0.04 milliseconds, representing a speedup of several orders of magnitude.
Conclusion
LLMGuard demonstrates the power of LLMs in generating high-quality synthetic data for graph-based OOD detection. By focusing on "hard" outliers and efficient edge completion, it establishes a new state-of-the-art for the field. Future work will explore incorporating multi-hop topological information and more advanced retrieval-augmented generation (RAG) techniques to further enhance the realism of synthetic sub-communities.
Summary updated