Table of Contents
Fetching ...

SpectralGap: Graph-Level Out-of-Distribution Detection via Laplacian Eigenvalue Gaps

Jiawei Gu, Ziyue Qiao, Zechao Li

TL;DR

SpecGap adjusts features by subtracting the component associated with the second-largest eigenvalue, scaled by the spectral gap, from the high-level features of the Laplacian matrix, and achieves state-of-the-art performance across multiple benchmark datasets.

Abstract

The task of graph-level out-of-distribution (OOD) detection is crucial for deploying graph neural networks in real-world settings. In this paper, we observe a significant difference in the relationship between the largest and second-largest eigenvalues of the Laplacian matrix for in-distribution (ID) and OOD graph samples: \textit{OOD samples often exhibit anomalous spectral gaps (the difference between the largest and second-largest eigenvalues)}. This observation motivates us to propose SpecGap, an effective post-hoc approach for OOD detection on graphs. SpecGap adjusts features by subtracting the component associated with the second-largest eigenvalue, scaled by the spectral gap, from the high-level features (i.e., $\mathbf{X}-\left(λ_n-λ_{n-1}\right) \mathbf{u}_{n-1} \mathbf{v}_{n-1}^T$). SpecGap achieves state-of-the-art performance across multiple benchmark datasets. We present extensive ablation studies and comprehensive theoretical analyses to support our empirical results. As a parameter-free post-hoc method, SpecGap can be easily integrated into existing graph neural network models without requiring any additional training or model modification.

SpectralGap: Graph-Level Out-of-Distribution Detection via Laplacian Eigenvalue Gaps

TL;DR

SpecGap adjusts features by subtracting the component associated with the second-largest eigenvalue, scaled by the spectral gap, from the high-level features of the Laplacian matrix, and achieves state-of-the-art performance across multiple benchmark datasets.

Abstract

The task of graph-level out-of-distribution (OOD) detection is crucial for deploying graph neural networks in real-world settings. In this paper, we observe a significant difference in the relationship between the largest and second-largest eigenvalues of the Laplacian matrix for in-distribution (ID) and OOD graph samples: \textit{OOD samples often exhibit anomalous spectral gaps (the difference between the largest and second-largest eigenvalues)}. This observation motivates us to propose SpecGap, an effective post-hoc approach for OOD detection on graphs. SpecGap adjusts features by subtracting the component associated with the second-largest eigenvalue, scaled by the spectral gap, from the high-level features (i.e., ). SpecGap achieves state-of-the-art performance across multiple benchmark datasets. We present extensive ablation studies and comprehensive theoretical analyses to support our empirical results. As a parameter-free post-hoc method, SpecGap can be easily integrated into existing graph neural network models without requiring any additional training or model modification.

Paper Structure

This paper contains 51 sections, 1 theorem, 29 equations, 7 figures, 9 tables.

Key Result

Theorem 1

Under assumptions (D1) and (D2) above, let $(\Delta\lambda_{\text{ID}},\mathbf{u}_{n-1,\text{ID}})$ and $(\Delta\lambda_{\text{OOD}},\mathbf{u}_{n-1,\text{OOD}})$ be drawn from their respective distributions. Then, on average, SpecGap produces a strictly larger separation: for some $\Gamma>0$ that depends on (i) the distribution difference in $\Delta\lambda$, and (ii) the typical angle between $\

Figures (7)

  • Figure 1: SpecGap: Spectral Gap-based OOD Detection. (a) Original Eigenvalue Distribution: OOD samples show larger and more varied spectral gaps compared to ID samples. (b) Spectral Gap Distribution: Clear separation between ID and OOD samples based on spectral gap. (c) Distribution After SpecGap: The method effectively brings OOD samples closer to the ID distribution.
  • Figure 2: Performance comparison of OOD detection methods before and after applying SpecGap. Each subplot represents a different dataset pair, with methods on the x-axis and AUC scores on the y-axis. Coral and slate blue bars indicate performance before and after SpecGap application, respectively.
  • Figure 3: Impact of the number of largest eigenvalues used in SpecGap on OOD detection performance (AUC) using the GCL$_S$ model on the ENZYMES-PROTEIN dataset.
  • Figure 4: Comparison of different feature projection methods in SpecGap on the IMDBM-IMDBB dataset using the JOAO$_S$ model.
  • Figure 5: An example ID vs. OOD spectral gap distribution from randomly perturbed graphs (Section \ref{['subsec:empirical_demo']}). The ID distribution (green) has a mild peak around $\Delta\lambda \approx 3.5$, while the OOD distribution (orange) is broader and shifted, with some overlap but still a noticeable difference. A threshold near $\tau\approx 3.0$ can separate many samples. This aligns with assumptions (D1)--(D2).
  • ...and 2 more figures

Theorems & Definitions (1)

  • Theorem 1: Distribution-level Separation Gain