TINS: Test-time ID-prototype-separated Negative Semantics Learning for OOD Detection

Yifeng Yang, Jubo Feng, Jing Xu, Xinbing Wang, Qinying Gu, Nanyang YearXiv 2026

TL;DR

TINS (Test-time ID-prototype-separated Negative Semantics learning) is a novel test-time adaptation method that dynamically expands a vision-language model's negative label space to improve out-of-distribution (OOD) detection. By explicitly regularizing dynamically learned negative text embeddings to stay away from in-distribution (ID) class prototypes, TINS prevents hard ID samples from contaminating the negative space. This approach slashes the average false positive rate (FPR95) on the ImageNet Four-OOD benchmark from 14.04% to an impressive 6.72%.

What Problem Does This Paper Address?

When deploying vision-language models (VLMs) like CLIP in the real world, identifying out-of-distribution (OOD) inputs—samples that do not belong to any of the known in-distribution (ID) classes—is critical for safety. A popular strategy is to use "negative labels" (words or phrases representing concepts outside the ID space). If an image aligns more closely with these negative semantics than any ID class, it is flagged as OOD.

However, most existing methods rely on a static set of negative labels defined before deployment. This fails to capture the diverse, unpredictable, and evolving concepts encountered in a live test stream. While dynamically learning negative semantics at test time seems like an obvious fix, it introduces a major challenge: hard ID contamination. The unlabeled test stream often contains ambiguous or difficult ID samples. If a model naively extracts negative semantics from these samples, it accidentally pulls ID concepts into the negative space, blurring the boundary between what is in-distribution and what is out-of-distribution.

Methods

TINS addresses these challenges through a three-pronged architecture designed for controlled test-time expansion:

  1. ID-Prototype-Separated Modality Inversion: When a test sample is flagged as potentially OOD (based on a confidence threshold $\beta$), TINS freezes the CLIP model and optimizes a learnable pseudo-token embedding ($z$) using the prompt template "a photo of <CLS>". Crucially, the loss function balances two objectives: it pulls the text embedding ($t^-$) toward the image feature ($v$) while pushing it away from the pre-computed ID class prototypes ($\mu_c$).
  2. Vocabulary-Prior Initialization: Instead of initializing the learnable token $z$ randomly, TINS selects a starting word from a predefined negative corpus that already shows a good trade-off between matching the sample and staying away from ID prototypes. This significantly accelerates optimization convergence.
  3. Group-Wise Aggregation Scoring: Accumulating too many negative concepts can artificially deflate the model's overall ID confidence scores (a phenomenon called denominator inflation). TINS mitigates this by randomly permuting and partitioning the combined static and dynamic negatives into $G$ disjoint groups, calculating OOD scores per group, and averaging them.
  4. Buffer Update Strategy: To handle sudden shifts in the OOD data distribution over time, TINS maintains a dynamic bank and a secondary buffer ($Q$). When the bank is full, overflow candidates go to the buffer. Once the buffer fills up, a "Flash" operation filters out the most ID-like candidates and merges the rest back into the bank via random sampling to preserve semantic diversity.
The overall framework of TINS, illustrating modality inversion, group-wise scoring, and the buffer update strategy.

Datasets

The authors evaluated TINS using ImageNet-1K as the primary ID dataset, alongside alternative ID datasets to test robustness: Food-101, ImageNet-Sketch, ImageNet-R, ImageNet-V2, CIFAR-10, and CIFAR-100.

For OOD detection, they utilized standard benchmarks:

  • Four-OOD: Consisting of iNaturalist, SUN, Places, and Textures.
  • OpenOOD v1.5: Evaluating both Near-OOD (SSB-hard, NINCO) and Far-OOD (iNaturalist, Textures, OpenImage-O) settings.
  • Temporal-Shift Setting: A custom sequential stream where the Four-OOD datasets arrive one after another in various orderings to simulate real-world distribution shifts.

Key Insights and Ideas

  • The Danger of Unconstrained Test-Time Learning: Without explicit constraints, dynamic negative learning methods suffer in the "ID-tail" region (hard ID samples). By enforcing separation from ID prototypes, TINS ensures that the dynamically generated negative space strictly represents novel OOD concepts.
t-SNE and score distribution comparison showing clearer ID/OOD separation with TINS compared to InterNeg.
  • Prior Knowledge Speeds Up Test-Time Optimization: Initializing the text inversion process with a vocabulary prior rather than random noise acts as an effective shortcut, achieving superior OOD detection performance in far fewer optimization steps.
Comparison of random vs. vocabulary-prior initialization across iteration steps.
  • Divide and Conquer for Score Stability: Grouping negative labels prevents the mathematical inflation of the denominator in the softmax-like scoring function, ensuring that the addition of thousands of new test-time concepts doesn't degrade the detection performance of the original ID classes.

Key Results

  • State-of-the-Art OOD Detection: On the ImageNet-1K Four-OOD benchmark, TINS achieved an average AUROC of 98.51% and reduced the FPR95 to 6.72%, outperforming the previous best test-time adaptation method, InterNeg (14.04% FPR95).
  • Robustness to Temporal Shift: In streaming scenarios where the OOD distribution suddenly changes, the buffer update strategy allowed TINS to maintain stable performance, improving the average AUROC from 96.95% (without buffer) to 97.89% (with buffer).
  • Versatility: TINS demonstrated consistent performance gains across different CLIP backbones (ResNet50, ResNet101, ViT-B/32, and ViT-B/16) and varying ID-to-OOD sample ratios.

Limitations and Future Work

The primary limitation of TINS is its computational overhead at test time. Performing gradient-based optimization (modality inversion) during inference slows down processing speeds. On a single NVIDIA RTX 4090 GPU, running 40 optimization iterations drops the throughput from 263 frames per second (FPS) to 105 FPS and introduces a peak memory overhead of roughly 2GB.

Future work could explore hardware-aware acceleration techniques, such as mixed-precision execution on Tensor Cores, or look into lighter weight, gradient-free methods to approximate the ID-prototype-separated negative space.

Trade-off between OOD detection performance (FPR95) and inference speed (FPS) across optimization steps.

Summary updated

BibTeX
@misc{yang2026tins,
  author = {Yifeng Yang and Jubo Feng and Jing Xu and Xinbing Wang and Qinying Gu and Nanyang Ye},
  title = {{TINS: Test-time ID-prototype-separated Negative Semantics Learning for OOD Detection}},
  year = {2026},
  eprint = {2605.10756},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.10756},
}
Figure