- The paper introduces a dual-branch prompting framework combining class-specific and class-agnostic losses with frozen pre-trained GNNs.
- The method achieves significant AUC improvements and reduces training time by up to 64ร compared to state-of-the-art methods.
- The explicit generation of prompt graphs enhances interpretability by highlighting discriminative substructures for reliable OOD detection.
Disentangled Graph Prompting for Out-of-Distribution Detection: Summary and Analysis
Introduction and Motivation
Graph neural networks (GNNs) have established themselves as effective tools for modeling structured data. However, their vulnerability to distribution shiftsโwhere test data deviates from the in-distribution (ID) training regimeโposes severe risks, especially in critical applications. This motivates the graph out-of-distribution (OOD) detection problem: distinguishing OOD graphs at test time to maintain reliable system behavior. While existing OOD detectors for graphs either rely on end-to-end training or leverage pre-trained encoders with prompting, these paradigms either lack fine-grained modeling of ID patterns or under-utilize the expressive capacity of prompting mechanisms.
The paper "Disentangled Graph Prompting for Out-Of-Distribution Detection" (2603.29644) systematically addresses these limitations by proposing the Disentangled Graph Prompting (DGP) framework. DGP combines the advantages of pre-training with frozen GNN encoders and decomposes graph prompting into class-specific and class-agnostic components to mine fine-grained ID patterns beyond what previous methods can achieve.
The DGP Framework
At the core of DGP is the pre-training+prompting paradigm. Instead of retraining GNNs end-to-end, DGP freezes well-trained encoders and learns prompt generators that modify edge weights in input graphs, thus yielding two views: a class-specific prompt and a class-agnostic prompt. The hypothesis is that class-specific prompts capture discriminative motifs for ID classification while class-agnostic prompts amplify shared invariants across all ID classes. This duality ensures both discriminative and invariant ID signals are exploited for robust OOD detection.
Figure 1: An overview of Disentangled Graph Prompting, illustrating both class-specific and class-agnostic prompt generation alongside a frozen pre-trained GNN encoder.
The DGP training regime further involves carefully designed loss functions for both prompt generators:
- A class-specific classification loss (cross-entropy to labels) emphasizes discriminative ID features.
- A class-agnostic loss (cross-entropy to a uniform label distribution) enforces the extraction of invariants spanning all classes.
- Explicit regularization via distance-based losses prevents trivial prompt solutions that simply reproduce the input or collapse all prompt graphs into similar forms.
This results in two decoupled prompt generators (realized as MLPs), which, during testing, produce prompt graphs whose representations are scored using the Mahalanobis distance, facilitating robust ID/OOD separation.
Figure 2: The DGP training pipeline, detailing the generation of prompt graphs, dual branches for losses, and loss-based regularization to avoid triviality.
Experimental Evaluation
DGP is evaluated on ten OOD detection benchmarks, encompassing molecular, social, and bioinformatics domains. GNN encoders are pre-trained using self-supervised contrastive learning approaches (GCL and SimGRACE), aligning with SOTA protocol.
Key Empirical Results
- DGP yields a relative AUC improvement of 3.63% over the strongest prior baseline (SEGO), with absolute AUCs exceeding 87% on average across the benchmarks.
- Compared with naรฏve usage or fine-tuning of pre-trained GNNs (GCL, SimGRACE, GCL-ft, SimGRACE-ft), DGP achieves up to 19.86% (pre-trained) and 13.65% (fine-tuned) relative AUC improvements.
- Ablations confirm that both class-specific and class-agnostic prompt branches are complementary; removing either degrades detection performance.
- DGP attains 46โ64ร reduction in training time compared to the SOTA competitors, highlighting its efficiency due to the frozen encoder.









Figure 3: Visualization of Mahalanobis score distributions for ID/OOD graphs; post-prompting, the distributional overlap is substantially reduced, improving detection margins.
Figure 4: Ablation analysis of AUC versus DGP module variants and GNN encoder initialization; ablations verify the need for both branches and pre-training.
Figure 5: Comparative analysis of training times, showcasing the computational advantage of DGP over prior SOTA methods.
Prompt Interpretability and Hyperparameters
A salient feature of DGP is its interpretability: by explicitly generating prompt graphs, DGP enables analysis of which substructures are emphasized by each branch. Visualizations confirm that class-specific prompt graphs select salient subgraphs relevant for label discrimination, while class-agnostic prompts emphasize structures common to all ID samples.







Figure 6: Case study visualizations of prompt graphs; top: class-specific (discriminative edges), bottom: class-agnostic (shared edges).
Hyperparameter studies demonstrate DGPโs robust performance across a wide range of loss balancing parameters and MLP depths, with two-layer prompt generators generally optimal.


Figure 7: Sensitivity of DGP AUC performance to major hyperparameters and MLP layer depth (on BZR-COX2 and PTC_MR-MUTAG).
Theoretical and Practical Implications
Theoretically, DGP substantiates the necessity of modeling fine-grained, disentangled patterns in OOD detection for structured data. Explicitly decomposing the prompt generation process into class-specific and class-agnostic branches leverages complementary inductive biases: one supporting discriminative partition of ID data, the other capturing invariants that regularize against spurious correlations. Moreover, by freezing GNN encoders, the approach decouples pattern mining from representational learning, reducing training instability and resource requirements.
Practically, DGPโs computational efficiency and modular design make it suitable for deployment in real-world systems where model retraining is costly or undesirable. The explicit generation of prompt graphs potentially enhances explanation and debugging of OOD decisions, a factor of growing importance in safety-critical applications.
Future Directions
Potential extensions include designing more expressive prompt generator architectures capable of generating non-edge-centric (e.g., motif-based or subgraph-based) prompts, and adapting DGP to heterogeneous, dynamic, or attributed graphs common in real-world scenarios. Further, unifying prompting with causal inference frameworks may enable domain-adaptive OOD detectors with theoretical distributional guarantees.
Conclusion
The DGP framework advances graph OOD detection by disentangling prompt generation into complementary class-specific and class-agnostic losses, leveraging frozen pre-trained GNNs for efficient and effective processing. Extensive benchmarking demonstrates superior accuracy, robustness to hyperparameters, interpretability, and significant improvements in computational efficiency. The principles of disentangled modeling and pre-training+prompting developed in DGP offer a viable foundation for robust OOD detection in structured domains and present compelling avenues for further research in graph representation and AI safety (2603.29644).