arXiv:2611.06021cs.LGNov 2026

Manuscript Offprint

arXiv:2611.06021

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

Zilin Wang, Lianghai Xiao

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.

Keywords: Out-of-Distribution Detection, Attraction-Ranking Mismatch, Feature Dynamics, Hamiltonian Framework, Pairwise Ranking

1. Introduction

Post-hoc out-of-distribution (OOD) detection asks whether a test sample belongs to the distribution represented by a fixed classifier (Hendrycks and Gimpel, 2017; Liang et al., 2017). Existing detectors extract evidence from confidence, logits, or feature geometry (Liu et al., 2020; Wang et al., 2022; Sun et al., 2022). A recurring intuition is that an in-distribution (ID) feature should lie near, or move toward, a learned class region. The unresolved question is whether this pointwise geometric attraction improves the relative ordering of ID and OOD samples.

We turn that intuition into a minimal dynamical problem. Normalized training features define class-conditioned wells on the unit sphere; a query starts from rest; and the strongest class affinity visited along its trajectory is used as ID evidence. Hamiltonian dynamics provide a transparent testbed because the force, trajectory, and observed score are all explicit. We use this model to examine whether attraction implies better detection.

The implication fails in two logically distinct ways. First, the field that moves a feature can be misaligned with the instantaneous class evidence used by the detector: summing class forces may reduce the affinity of the currently winning class. Second, even a score-aligned flow can raise OOD scores more than ID scores near the baseline ranking boundary. We call these failures attraction-ranking mismatch. The distinction matters because AUROC is a functional of ID–OOD pairs, not an average of samplewise score changes.

The central ranking result identifies the relative score change at the ID–OOD ranking boundary that determines the first-order AUROC change under regularity conditions. An exact decomposition into corrected and spoiled pairs explains finite changes. A first-step analysis links the driving field to the detection score, while an ordering-preservation result states the limits of universal improvement by deterministic refinement.

Our experiments show that local score alignment does not ensure better OOD ranking. A rule that improves AUROC on a held-out source split reduces it on the target benchmarks when the refinement rule and step count are kept fixed. This failure occurs without observed winning-class changes within the fixed candidate sets, showing that class switching is not required to explain the loss in ranking quality. In a separate perturbation study, near-boundary relative score changes track the direction of small AUROC changes more consistently than their global average. The experiments thus illustrate ranking failure despite local alignment; they do not establish the destructive class interference allowed by the theory.

The T = 0 reference separates the static geometric information from the effect of motion. After removing candidate truncation, we bound the error of replacing each class field by a radial centroid score. Under shared scales, this approximate score is exactly rank-equivalent to centroid cosine similarity. CTM (Nguyen et al., 2023) is an existing full-bank, feature-norm-weighted member of the resulting family. This relation

∗^{*}Corresponding author.

Email address: xiaolh@jnu.edu.cn (Lianghai Xiao)

Figure

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=0T=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.

provides a static baseline for studying the contribution of motion.

The contribution of this study is threefold:

  • first, we analyze the attraction–ranking mismatch by separating field–score alignment from ID–OOD ranking and identifying the boundary condition that governs first-order AUROC change under regularity conditions;

  • second, we show through controlled experiments that local score alignment does not guarantee better ranking, even without winning-class changes, and examine the boundary-based explanation in a separate perturbation study;

  • third, we connect zero-step anchor scores to a static centroid family through approximation bounds and shared-scale ranking equivalence. This analysis also shows that CTM is an existing member of this family.

The rest of the paper is organized as follows. Section 2 positions the problem. Section 3 states the fundamental model, Section 4 develops the theory, and Section 5 derives its static consequence. Section 6 tests the theoretical chain, followed by discussion and limitations.

References (28)