Papers
Topics
Authors
Recent
Search
2000 character limit reached

Forced Prompt Learning (FA) for OOD Detection

Updated 6 July 2026
  • Forced Prompt Learning (FA) is a CLIP-based prompt-learning framework that enriches in-distribution semantics for few-shot out-of-distribution detection without relying on auxiliary OOD data.
  • It leverages a forced prompt trained to outperform a frozen reference prompt using a forced cross-entropy loss, thereby capturing richer and more nuanced class descriptors.
  • Empirical results on ImageNet benchmarks show that FA improves OOD detection metrics and transferability while maintaining comparable in-distribution classification accuracy to CoOp.

Forced Prompt Learning (FA) is a CLIP-based prompt-learning framework for few-shot out-of-distribution (OOD) detection that improves OOD separability by enriching in-distribution (ID) semantics rather than by learning explicit OOD-related knowledge. In the formulation introduced in "FA: Forced Prompt Learning of Vision-LLMs for Out-of-Distribution Detection" (Lu et al., 6 Jul 2025), the method operates in the realistic regime where only a small number of labeled ID samples are available for downstream tuning and no true OOD training data are assumed. Its central idea is to learn a forced prompt that must become more semantically aligned with ID images than a frozen reference prompt initialized from the same manual template. The resulting prompt is intended to encode more diversified, richer, and more nuanced descriptions of ID classes than class labels alone provide, thereby improving ID/OOD separability without external auxiliary datasets, synthetic OOD samples, or negative labels (Lu et al., 6 Jul 2025).

1. Definition and problem setting

FA is defined for few-shot OOD detection with CLIP under the constraint that only a small labeled ID training set is available for adaptation. The method is motivated by the observation that many recent CLIP-based OOD detectors improve performance by injecting or approximating OOD-related knowledge, for example through auxiliary OOD datasets, exposed outlier regions, synthetic “ID-like” negatives, or negative prompts. FA is proposed as a contrasting design principle: instead of approximating the open-ended OOD world, it seeks better OOD detection by learning richer ID semantics from the few-shot ID set alone (Lu et al., 6 Jul 2025).

In this formulation, CLIP supplies a frozen image encoder f()f(\cdot) and text encoder g()g(\cdot). For CC ID classes, a handcrafted prompt u^c\hat{\mathbf{u}}_c such as “a photo of a [class-c]” yields text features

t^c=g(u^c)Rd×1,c=1,,C.\hat{\mathbf{t}}_c = g(\hat{\mathbf{u}}_c)\in \mathbb{R}^{d\times 1}, \qquad c=1,\dots,C.

Given an image x\mathbf{x}, the image feature is

z=f(x)Rd×1.\mathbf{z}=f(\mathbf{x})\in \mathbb{R}^{d\times 1}.

The baseline prompt-tuning reference is CoOp-style learning of context vectors

uc=[v1,,vL,wc],c{1,,C},\mathbf{u}_c = [\mathbf{v}_1,\cdots,\mathbf{v}_L,\mathbf{w}_c], \qquad c\in\{1,\cdots,C\},

with class posterior

p(y=cx)=ecos(z,tc)/τj=1Cecos(z,tj)/τ.p(y=c\,|\,\mathbf{x}) = \dfrac{e^{\cos(\mathbf{z},\mathbf{t}_c)/\tau}}{\sum_{j=1}^C e^{\cos(\mathbf{z},\mathbf{t}_j)/\tau}}.

FA retains the frozen CLIP backbone but changes the prompt-learning objective: the trainable prompt is not merely optimized for closed-set classification, but is explicitly trained to be more salient than a frozen original prompt for ID samples (Lu et al., 6 Jul 2025).

A practical implication is that FA is an ID-centric OOD detector. It does not require external auxiliary OOD datasets, exposed outlier regions, synthetic OOD generation, negative prompts, or OOD labels. The method also keeps the same number of trainable parameters as CoOp, because the added original-prompt branch is frozen rather than trainable (Lu et al., 6 Jul 2025).

2. Prompt architecture and forced objective

FA introduces two prompt branches per class concept: an original prompt and a forced prompt, both initialized from the same manual template. The original prompt remains frozen and serves as a semantic reference; the forced prompt is trainable. The image encoder, text encoder, and class-name tokens in both prompts are frozen, and only the context vectors of the forced prompt are updated. As in low-shot CoOp, the forced prompt uses a shared learnable vector across classes rather than class-specific independent context vectors (Lu et al., 6 Jul 2025).

Let the text encoder produce class-wise text features for the two branches:

  • original prompt features: {t1o,,tCo}\{\mathbf{t}_1^o,\dots,\mathbf{t}_C^o\},
  • forced prompt features: g()g(\cdot)0.

For image feature g()g(\cdot)1, FA computes

g()g(\cdot)2

The key innovation is the forced cross-entropy loss

g()g(\cdot)3

This loss expands the softmax denominator to include both the trainable forced-prompt similarities and the frozen original-prompt similarities. Because the original prompt already carries meaningful CLIP semantics, the forced prompt can dominate only by learning a better class description for ID samples than the baseline prompt already provides (Lu et al., 6 Jul 2025).

FA then introduces the forced coefficient g()g(\cdot)4, a nonnegative integer hyperparameter: g()g(\cdot)5 The refined loss is

g()g(\cdot)6

When g()g(\cdot)7, the original-prompt term disappears and the method degenerates to ordinary CoOp-like training. As g()g(\cdot)8 increases, the original prompt acts as a stronger semantic competitor. In the paper’s interpretation, this increases the “intensity” with which the model is compelled to learn from ID data, encouraging more comprehensive class semantics (Lu et al., 6 Jul 2025).

The conceptual claim is precise: class names and their default CLIP text embeddings are too coarse to fully describe a class, so a prompt trained to surpass the manual prompt on ID images should encode richer semantic content. This suggests that FA improves OOD detection not by modeling the OOD universe, but by making the representation of ID classes more complete (Lu et al., 6 Jul 2025).

3. Training pipeline and OOD scoring

The FA training pipeline is deliberately simple. It begins with pre-trained CLIP, using ViT-B/16 in experiments. Two prompt branches are built from the same manual initialization “a photo of a [class-c].” CLIP’s image encoder, text encoder, the original prompt, and the class-name token portion are frozen. Only the shared context tokens of the forced prompt are learnable. For each ID training pair g()g(\cdot)9, FA computes CC0, obtains CC1 and CC2, computes CC3 and CC4, and optimizes the forced prompt with CC5. There is no extra regularization term beyond this loss in the main method (Lu et al., 6 Jul 2025).

At inference, FA uses only the forced prompt branch for ID classification. For OOD detection, it plugs into standard CLIP scoring rules, especially MCM and GL-MCM, modified to account for both forced and original prompt similarities. For MCM, with global image feature CC6 and combined candidate text feature set CC7, the paper gives

CC8

with CC9 at inference. For GL-MCM,

u^c\hat{\mathbf{u}}_c0

where

u^c\hat{\mathbf{u}}_c1

and u^c\hat{\mathbf{u}}_c2 is the u^c\hat{\mathbf{u}}_c3-th local feature extracted from the CLIP image encoder (Lu et al., 6 Jul 2025).

OOD detection then follows standard thresholding: u^c\hat{\mathbf{u}}_c4 where u^c\hat{\mathbf{u}}_c5 denotes ID and u^c\hat{\mathbf{u}}_c6 denotes OOD. Relative to prior prompt-learning OOD methods, FA is architecturally closest to CoOp, but differs in the addition of a frozen reference prompt and the forced loss (Lu et al., 6 Jul 2025).

4. Empirical performance and benchmark behavior

FA is evaluated on standard ImageNet-1k OOD benchmarks using iNaturalist, SUN, Places, and Textures as OOD datasets, and also on more challenging cleaner OOD datasets OpenImage-O, NINCO, and ImageNet-O. The experiments cover 1-shot, 4-shot, and 16-shot settings and also test transfer to UCF101, EuroSAT, Food101, StanfordCars, Caltech101, FGVCAircraft, Flowers102, and OxfordPets. The reported metrics are FPR95, AUROC, and ID Top-1 accuracy (Lu et al., 6 Jul 2025).

On ImageNet-1k conventional OOD benchmarks, FA achieves the strongest average OOD performance among methods that do not use real outliers. In the 1-shot setting, FAu^c\hat{\mathbf{u}}_c7 reaches 27.81 FPR95 / 93.26 AUROC, improving over SCTu^c\hat{\mathbf{u}}_c8 at 31.62 / 92.01. In the 16-shot setting, FAu^c\hat{\mathbf{u}}_c9 obtains 25.68 / 93.82, compared with 27.27 / 93.31 for SCTt^c=g(u^c)Rd×1,c=1,,C.\hat{\mathbf{t}}_c = g(\hat{\mathbf{u}}_c)\in \mathbb{R}^{d\times 1}, \qquad c=1,\dots,C.0. The paper also emphasizes that even FAt^c=g(u^c)Rd×1,c=1,,C.\hat{\mathbf{t}}_c = g(\hat{\mathbf{u}}_c)\in \mathbb{R}^{d\times 1}, \qquad c=1,\dots,C.1 in 1-shot slightly exceeds SCTt^c=g(u^c)Rd×1,c=1,,C.\hat{\mathbf{t}}_c = g(\hat{\mathbf{u}}_c)\in \mathbb{R}^{d\times 1}, \qquad c=1,\dots,C.2 on average AUROC/FPR95, which is presented as evidence that the gain stems from better prompt learning rather than only from the scoring rule (Lu et al., 6 Jul 2025).

On the more challenging cleaner OOD datasets in the 16-shot setting, FAt^c=g(u^c)Rd×1,c=1,,C.\hat{\mathbf{t}}_c = g(\hat{\mathbf{u}}_c)\in \mathbb{R}^{d\times 1}, \qquad c=1,\dots,C.3 achieves 53.61 FPR95 / 83.93 AUROC, improving over SCTt^c=g(u^c)Rd×1,c=1,,C.\hat{\mathbf{t}}_c = g(\hat{\mathbf{u}}_c)\in \mathbb{R}^{d\times 1}, \qquad c=1,\dots,C.4 at 58.25 / 82.24. FAt^c=g(u^c)Rd×1,c=1,,C.\hat{\mathbf{t}}_c = g(\hat{\mathbf{u}}_c)\in \mathbb{R}^{d\times 1}, \qquad c=1,\dots,C.5 also improves strongly there, reaching 57.40 / 84.08 (Lu et al., 6 Jul 2025).

A notable secondary result is that FA improves OOD detection without severely harming ID classification. On ImageNet-1k top-1 ID accuracy, FA is close to the strongest prompt-learning baselines: in 1-shot, FA reports 68.67% versus 68.63% for SCT; in 4-shot, 69.96% versus 69.93%; and in 16-shot, SCT remains slightly higher at 71.78% versus 71.02% for FA, while FA’s OOD performance is better (Lu et al., 6 Jul 2025).

Cross-dataset transfer reinforces the same interpretation. On UCF101 as ID in 16-shot, FA is reported as dramatically stronger than prior methods, with average MCM performance around 2.63 FPR95 / 99.42 AUROC and GL around 4.56 / 99.03. On EuroSAT, the paper highlights particularly large gains: FAt^c=g(u^c)Rd×1,c=1,,C.\hat{\mathbf{t}}_c = g(\hat{\mathbf{u}}_c)\in \mathbb{R}^{d\times 1}, \qquad c=1,\dots,C.6 exceeds LoCoOpt^c=g(u^c)Rd×1,c=1,,C.\hat{\mathbf{t}}_c = g(\hat{\mathbf{u}}_c)\in \mathbb{R}^{d\times 1}, \qquad c=1,\dots,C.7 by 16.09 AUROC points and 38.7 FPR95 points on average. This suggests that richer ID semantics can be especially useful when the downstream domain departs from ImageNet-like natural images (Lu et al., 6 Jul 2025).

5. Ablations, robustness, and design choices

The ablation studies show that FA’s improvement is not obtained merely by adding another prompt branch. Replacing t^c=g(u^c)Rd×1,c=1,,C.\hat{\mathbf{t}}_c = g(\hat{\mathbf{u}}_c)\in \mathbb{R}^{d\times 1}, \qquad c=1,\dots,C.8 with standard cross-entropy produces a much weaker model. On ImageNet-1k 16-shot, FAt^c=g(u^c)Rd×1,c=1,,C.\hat{\mathbf{t}}_c = g(\hat{\mathbf{u}}_c)\in \mathbb{R}^{d\times 1}, \qquad c=1,\dots,C.9 yields 41.43 / 91.01 with MCM and 34.29 / 90.99 with GL-MCM, whereas FAx\mathbf{x}0 gives 29.07 / 93.77 and 25.68 / 93.82. The paper’s conclusion is explicit: the forced competition objective is essential (Lu et al., 6 Jul 2025).

Initialization is also critical. If both prompts are randomly initialized, performance drops substantially. The best setup is manual/manual initialization for both the forced and original prompt. In the 16-shot ImageNet-1k benchmark, this configuration gives 29.07 / 93.77 with MCM and 25.68 / 93.82 with GL, outperforming mixed or random alternatives. This supports the argument that the original prompt should serve as a semantically meaningful CLIP prior rather than an arbitrary baseline (Lu et al., 6 Jul 2025).

The choice of a shared learnable vector rather than class-specific independent vectors also matters in low-shot settings. The shared+manual configuration gives the best result, consistent with CoOp’s earlier low-data observation that class-specific prompts are harder to train with limited supervision (Lu et al., 6 Jul 2025).

The forced coefficient x\mathbf{x}1 is reported as effective but not fragile. The paper fixes x\mathbf{x}2 in all experiments. Sensitivity analysis over x\mathbf{x}3 to x\mathbf{x}4 shows fairly stable performance above the best baseline, with AUROC improving and then plateauing as x\mathbf{x}5 increases. The authors interpret the plateau as a bottleneck in how much more comprehensive semantics the forced prompt can extract. The ablation also confirms that x\mathbf{x}6 is beneficial and that x\mathbf{x}7 degenerates to CoOp (Lu et al., 6 Jul 2025).

Computationally, FA remains lightweight: all experiments were run on a single Nvidia A30 GPU. This is relevant because several competing prompt-learning OOD methods introduce additional trainable negative prompts or other OOD-oriented mechanisms, whereas FA preserves CoOp-level trainable parameter count (Lu et al., 6 Jul 2025).

6. Relation to neighboring prompt-learning methods and terminological scope

FA belongs to the CLIP prompt-learning literature, but its design principle differs from several adjacent prompt-learning directions. Relative to CoOp, FA retains frozen CLIP encoders and learns prompt context vectors, yet adds a frozen reference prompt and a forced loss that turns prompt learning into a competition against a manual semantic prior (Lu et al., 6 Jul 2025). Relative to LoCoOp and SCT, the difference is more philosophical: those methods improve OOD detection by calibrating against ID-irrelevant local regions or OOD-like signals, whereas FA improves OOD detection by making ID class semantics more complete (Lu et al., 6 Jul 2025).

The term “forced prompt learning” should also be distinguished from other prompt-learning formulations that are unrelated to CLIP OOD detection. Prompt Diffusion learns a diffusion model in prompt space to produce sample-conditional prompts for robustness under distribution shift, but it is a plug-in adaptation mechanism for textual, visual, or multimodal prompts rather than an OOD detector built around forced competition with a frozen reference prompt (Du et al., 2024). Fed-CPrompt studies task-specific prompts in rehearsal-free federated continual learning and relies on asynchronous prompt learning plus a contrastive continual loss; it is not an FA method in the sense of (Lu et al., 6 Jul 2025, Bagwe et al., 2023). Likewise, PromptFL and related federated prompt-learning methods move adaptation into a small prompt parameter manifold for distributed optimization, but address federated classification rather than OOD detection (Guo et al., 2022).

A second disambiguation concerns the abbreviation FA itself. In speech research, FA often means forced alignment, as in comparisons of Montreal Forced Aligner with WhisperX and MMS (Rousso et al., 2024), end-to-end neural alignment with bidirectional attention (Li et al., 2022), or slot-filling speech-LLM alignment for multilingual long-form audio (Mu et al., 26 Jan 2026). That usage is terminologically unrelated to Forced Prompt Learning in CLIP-based OOD detection (Lu et al., 6 Jul 2025).

7. Limitations, benchmark interpretation, and significance

The paper identifies one practical limitation in benchmark interpretation: FA performs less impressively on SUN in the conventional ImageNet benchmark. The authors attribute this partly to contamination issues discussed in recent OOD work, since SUN contains many images overlapping with ImageNet semantics and is therefore not a perfectly clean OOD set (Lu et al., 6 Jul 2025).

A broader limitation is conceptual rather than numerical. FA assumes that richer ID descriptions are sufficient to improve OOD separation. The empirical evidence is strong, but the method does not explicitly model adversarially close OOD categories. The paper does not report severe failure cases beyond dataset cleanliness and the likely saturation effect at large x\mathbf{x}8, where the ability of the forced prompt to extract more comprehensive semantics appears to plateau (Lu et al., 6 Jul 2025).

Even with that limitation, FA is significant because it introduces a clean alternative principle for CLIP-based OOD detection: rather than approximating the unknowable OOD universe, one can improve OOD robustness by enriching the model’s understanding of ID classes. Technically, this is achieved with a minimal modification to CoOp-style prompt tuning: add a frozen reference prompt, train a copy to beat it through forced cross-entropy, and control the competition through a forced coefficient x\mathbf{x}9. The method uses no auxiliary OOD data, keeps the trainable parameter count equal to CoOp, and achieves state-of-the-art few-shot OOD detection across standard and challenging benchmarks (Lu et al., 6 Jul 2025).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Forced Prompt Learning (FA).