Attraction-Ranking Mismatch in Out-of-Distribution Detection: Theory and Evidence from Hamiltonian Feature Dynamics

Zilin Wang, Lianghai XiaoarXiv 2026 · arXiv

TL;DR

This paper challenges the intuitive assumption that "attracting" data features toward known class regions necessarily improves out-of-distribution (OOD) detection. By modeling feature refinement through Hamiltonian dynamics, the authors identify an attraction–ranking mismatch: while individual scores may improve, the relative ordering of in-distribution (ID) and OOD samples—the true driver of detection performance—can simultaneously degrade.

What Problem Does This Paper Address?

In OOD detection, we want to distinguish between samples from known classes (ID) and unknown ones (OOD). A common intuition is that if we can move a feature closer to its predicted class center (feature refinement), it should be easier to detect as ID.

However, OOD detection performance is typically measured by AUROC, which depends on the pairwise ranking of ID and OOD samples, not just their individual distances to a center. The authors tackle the unresolved question: does pointwise geometric attraction actually improve this global ranking? They investigate why a refinement rule that makes every sample look "more ID" can paradoxically make the detector worse at separating the two distributions.

Methods

The authors develop a theoretical framework and a controlled experimental testbed:

  • Hamiltonian Feature Dynamics: They model features as particles moving on a unit sphere, attracted to "potential wells" defined by ID class anchors. This provides a transparent way to study how "attraction" affects features over time.
  • AUROC Decomposition: They derive an exact mathematical decomposition of AUROC changes into "corrected" and "spoiled" pairs. This proves that AUROC only improves if the number of ID-OOD pairs whose relative order is fixed exceeds those that are swapped incorrectly.
  • Boundary-Conditioned Analysis: They identify that the first-order change in AUROC is determined by relative score changes specifically at the ranking boundary (where ID and OOD samples have nearly identical scores), rather than the global average of score changes.
  • Static Centroid Connection: They show that at "zero steps" (before any motion), their model reduces to a family of static centroid-based detectors, including the existing CTM (Cosine Similarity with Training Means) method.
Figure 1: Research map. Class-conditioned concentration on the feature sphere defines potential wells and a testable Hamiltonian hypothesis. Positive-time attraction need not preserve ID–OOD ordering; the locked score-aligned audit shows that the mismatch can persist without a winning-class switch. The exact T = 0 reference exposes a static geometry that reduces, after explicit candidate expansion, centroid approximation, and scale sharing, to a centroid family containing CTM as a full-bank member.

Datasets

The study evaluates its findings across several standard computer vision benchmarks using the OpenOOD v1.5 framework:

  • CIFAR-10 & CIFAR-100
  • ImageNet-200
  • ImageNet-1K (using ResNet-50 and DenseNet-121 backbones)

The evaluation includes both "Near-OOD" (semantically similar to ID) and "Far-OOD" (distinctly different) test sets.

Key Insights and Ideas

  • Attraction $\neq$ Better Ranking: A refinement rule can increase the "ID-ness" score for every single sample in a dataset and still decrease the AUROC. This happens if OOD samples "benefit" more from the attraction than ID samples do at the critical ranking boundary.
  • Field-Score Mismatch: The total "force" pulling a feature (which might be a sum of attractions to multiple classes) can be misaligned with the specific class score used by the detector. This can cause the winning class affinity to actually decrease even as the feature moves toward the aggregate ID region.
  • The Boundary is King: The paper demonstrates that global averages of score improvements are misleading. To predict if a method will work, you must look at the samples that the detector is currently "unsure" about—those near the ID-OOD decision threshold.
  • Class Switching is Not Required: Ranking can fail even if every sample maintains its original predicted class. The "mismatch" is a subtle shift in relative confidence, not necessarily a catastrophic misclassification.

Key Results

  • Refinement Failure: In experiments on ImageNet-1K, a refinement rule that improved AUROC on a validation set consistently degraded performance when transferred to other benchmarks. For example, it lost 1.63 points on Near-OOD and 3.07 points on Far-OOD tasks (see Table 1 in the paper).
  • Diagnostic Success: The authors' proposed boundary statistic ($B_{5\%}$) correctly predicted the direction of AUROC change in 14 out of 15 experimental runs across different datasets and backbones. In contrast, the unconditional global mean often had the opposite sign of the actual performance change.
  • Static Equivalence: The analysis successfully linked various "feature shaping" intuitions to a static centroid family, providing a unified view of why certain geometric methods (like CTM) perform well without needing complex dynamical refinement.
Schematic of the trajectory score showing how the maximum affinity visited along a path is used as evidence.

Limitations and Future Work

  • Fixed Candidate Sets: The current dynamics assume a fixed set of candidate classes for attraction, which might not capture the full complexity of open-world scenarios.
  • Proxy OOD Data: The boundary-based diagnostic requires some form of proxy OOD data for validation, which may not always be available or representative.
  • Model Scope: While tested on standard CNNs, it remains to be seen how these dynamics translate to large-scale transformers or foundation models where feature spaces may behave differently.
  • Future Direction: The authors suggest that future feature refinement research should move away from justifying methods based on pointwise "attraction" and instead focus on how these changes affect the ID-OOD ranking boundary.

Summary updated

Abstract

Attracting features toward learned in-distribution (ID) regions is an intuitive strategy for out-of-distribution (OOD) detection, but does such attraction improve detection? We investigate this question using class-conditioned Hamiltonian dynamics as a controlled testbed and identify an attraction-ranking mismatch: improving individual class-affinity scores need not improve the relative ordering of ID and OOD samples. Our analysis separates misalignment between the driving field and the detection score from ranking failure that persists even when they are aligned. An exact AUROC decomposition and a local boundary analysis identify relative score changes at the ID-OOD ranking boundary as the source of first-order AUROC change under regularity conditions. Experiments demonstrate that a score-aligned rule can improve performance on a held-out source validation split yet consistently degrade it after transfer, even without a single winning-class change. A separate perturbation study finds that near-boundary relative score changes track the direction of small AUROC changes in the tested settings. Finally, centroid approximation and shared scales connect the zero-step score to a static centroid family that includes the existing CTM detector. Together, these results explain why class attraction is insufficient to justify feature refinement and motivate evaluating its effect on the ranking boundary.
BibTeX
@misc{wang2026attraction,
  author = {Zilin Wang and Lianghai Xiao},
  title = {{Attraction-Ranking Mismatch in Out-of-Distribution Detection: Theory and Evidence from Hamiltonian Feature Dynamics}},
  year = {2026},
  eprint = {2611.06021},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.06021},
}
Figure