---
title: 'ANPrompt: Anti-noise Prompt Tuning for VLMs'
url: https://www.emergentmind.com/topics/anprompt
type: topic
---

# ANPrompt: Anti-noise Prompt Tuning for VLMs

Searching arXiv for the exact ANPrompt paper and closely related prompt-learning work to ground the article.
ANPrompt is a prompt tuning framework for vision-language models, particularly CLIP-like architectures, that is designed to improve robustness to weak semantic perturbations in both image and text inputs. It addresses a limitation attributed to earlier prompt tuning methods: although they are parameter-efficient and often effective for base-to-novel transfer, they remain vulnerable to subtle semantic noise such as background clutter, co-occurring objects, or linguistically misleading phrasing that preserves nominal class identity while shifting nearby semantics. ANPrompt responds by constructing weak-noise text features, clustering them into noise prompts, integrating those prompts with learnable prompt tokens, injecting the resulting anti-noise prompts into deeper layers of both the image and text encoders, and optimizing the system with cross-entropy, similarity, and weak semantic noise alignment objectives [2508.04677].

## 1. Definition and problem formulation

ANPrompt is introduced as **Anti-noise Prompt Tuning for Vision-Language Models**, a prompt-learning method for CLIP with the explicit goal of improving robustness under weak semantic perturbations [2508.04677]. In the paper’s formulation, the standard CLIP prediction rule remains unchanged:

\[
p(y = c \mid f) = \frac{\exp(\text{sim}(f, w_c)/\tau)}{\sum_{i=1}^C \exp(\text{sim}(f, w_i)/\tau)}
\]

where \(f\) is the image feature, \(w_c\) is the text feature for class \(c\), \(\tau\) is a learnable temperature, and \(\text{sim}(\cdot)\) is cosine similarity [2508.04677]. ANPrompt does not replace this scoring rule; instead, it changes how the prompt representations are constructed and aligned.

The motivating problem is not gross corruption but weak semantic perturbation. On the image side, the paper identifies background clutter, irrelevant regions, co-occurring objects, and attention drifting to non-discriminative regions. On the text side, it identifies subtle linguistic shifts that preserve class identity but nudge semantics toward adjacent categories, such as wording that moves “cat” toward “tiger”-like semantics. The paper’s central claim is that prior prompt tuning approaches improve efficiency or transferability but generally do not explicitly model such perturbations [2508.04677].

This places ANPrompt within a broader line of vision-language prompt learning methods that seek improved generalization beyond seen categories. Relative to CoOp, CoCoOp, MaPLe, PromptSRC, CoPrompt, MMRL, and TAC, ANPrompt is specifically framed around robustness to weak semantic noise rather than only base-to-novel transfer or cross-dataset adaptation [2508.04677].

## 2. Core mechanism: weak-noise features and anti-noise prompts

The first stage of ANPrompt constructs weak-noise frozen text features from two intra-class descriptions sampled from a language cache. One is a main text encoding the core semantics, and the other is a noise text introducing small linguistic variation. These are encoded by the frozen CLIP text encoder to obtain \(f_m\) and \(f_n\), and then fused as

\[
f_w = f_m + \alpha f_n
\]

with perturbation strength \(\alpha\) [2508.04677]. The implementation sets \(\alpha = 0.001\), and the ablation reported in the paper finds the best harmonic mean at this value, with higher weights reducing novel-class accuracy [2508.04677].

The weak-noise text features \(f_w\) are clustered with K-means to form noise prompts \(P_w\). The paper states that the weak-noise frozen text features lie in \(\mathbb{R}^{N \times C}\), and the clustered noise prompts \(P_w \in \mathbb{R}^{k \times C}\), where the number of clusters matches the number of learnable prompt tokens \(P_c \in \mathbb{R}^{k \times C}\) [2508.04677]. The paper does not provide an explicit K-means objective, initialization scheme, distance metric, or clustering schedule, so those details remain unspecified.

The anti-noise prompt is then defined as

\[
P_a = P_c + \epsilon P_w
\]

where \(P_c\) denotes learnable prompt tokens, \(P_w\) the clustered noise prompts, and \(\epsilon\) the perturbation injection strength [2508.04677]. The paper further states that \(P_a\) is projected through separate fully connected layers into modality-specific anti-noise prompts for the image and text encoders, though the explicit projection formulas are not given.

This design reflects a broader anchor-based tendency in prompt learning, but with a distinct emphasis. ATPrompt, for example, augments textual prompt learning by inserting explicit universal attribute anchors such as “shape” or “color” into CLIP prompts and selecting attribute sets through differentiable search [2412.09442]. AnchorOPT later replaces fixed textual anchors with learned implicit anchors and optimizes anchor positions with a learnable position matrix [2511.21188]. ANPrompt differs from both in that its auxiliary prompt source is not attribute vocabulary or latent anchor tokens but clustered weak semantic perturbation features derived from intra-class textual variation [2508.04677].

## 3. Deep prompt injection and Noise-Resistant Visual Prompt Prototype

ANPrompt is a deep prompt tuning method. The paper states that anti-noise prompts are injected into the deeper layers of both the image and text encoders, rather than only appended as shallow input-level context [2508.04677]. The pretrained encoder weights remain frozen, and only prompt-related parameters are learned. The exact number of prompted layers is not specified.

The token-sequence notation in the paper is partially malformed, but its intended structure is clear. For the visual encoder, the input sequence contains anti-noise image prompts together with the class token and patch tokens. For the text encoder, the sequence contains the SOS token, anti-noise text prompts, text tokens, class token(s), and EOS token [2508.04677]. No layerwise residual update equations are provided.

From the output of the visual prompt tokens, ANPrompt computes the **Noise-Resistant Visual Prompt Prototype (NRVPP)**. If the output visual prompt token features are denoted \(f_v^o \in \mathbb{R}^{N \times C}\), then

\[
f_N = \frac{1}{N} \sum_{i=1}^{N} f_v^{o(i)}
\]

This prototype is intended to suppress token-level variation, mitigate visual semantic distraction, and reduce sensitivity to irrelevant attended regions [2508.04677]. The prompted image feature \(f_v\) is taken from the final image class token, and the prompted text feature \(f_t\) from the final EOS token [2508.04677].

The model then defines three logit families:

\[
\ell_A = f_v \cdot f_t^\top
\]

\[
\ell_R = f_v \cdot f_w^\top
\]

\[
\ell_W = f_N \cdot f_w^\top
\]

The final classification logits are

\[
\ell_{\text{final}} = \theta \ell_A + (1 - \theta)\ell_R
\]

with \(\theta = 0.7\) in the implementation [2508.04677]. This makes the final decision depend jointly on prompted image-text alignment and robustness against weak-noise text features.

A plausible implication is that ANPrompt operates simultaneously at two levels: prompt-space perturbation modeling and logit-space robustness calibration. That contrasts with methods that improve prompt generalization mainly through textual structure or richer language priors. For example, AAPE in “Aggregate-and-Adapt Natural Language Prompts” distills rich natural-language prompt summaries into an image-conditional prompt embedding for improved few-shot and out-of-distribution generalization, but it does not formulate weak semantic perturbation as the central object of optimization [2410.08696].

## 4. Training objectives and optimization behavior

ANPrompt uses three losses: standard cross-entropy, a cosine-similarity-based sim loss, and the Weak semantic noise Alignment Loss (WALoss) [2508.04677]. The exact formula for the sim loss is not provided in the paper text, but it is described as a cosine loss between frozen and prompted features used to preserve semantic consistency.

WALoss is the most distinctive objective. It is defined using the robustness logits \(\ell_R\) and weak-noise logits \(\ell_W\):

\[
\mathcal{L}_{\text{WA}} = \gamma \cdot \text{KL}(\text{softmax}(\ell_R) \| \text{softmax}(\ell_W))
\]

where

\[
\gamma = \frac{1}{\text{std}(\ell_R) \cdot |\ell_R| + \epsilon_0}
\]

The paper describes \(\gamma\) as a variance-adaptive coefficient that stabilizes optimization across different confidence regimes [2508.04677]. The total objective is written as

\[
\mathcal{L} = \mathcal{L}_{\text{CE}} + \lambda \mathcal{L}_{\text{sim}} + \gamma \mathcal{L}_{\text{WA}}
\]

though the paper also defines \(\mathcal{L}_{\text{WA}}\) itself with a multiplicative \(\gamma\), creating a notational ambiguity [2508.04677].

The training configuration uses CLIP ViT-B/16 as backbone, Adam with learning rate \(0.001\), 10 epochs, batch size 4, and averaging over 3 random seeds on a single NVIDIA RTX 3090 Ti GPU [2508.04677]. The language cache incorporates prompts from CoPrompt and HPT, and weak perturbations are formed by randomly sampling two intra-class descriptions from this cache [2508.04677].

The combination of prompt construction and alignment loss should be distinguished from other robustness-oriented prompt methods. APT for anomaly detection, for instance, also uses prompt adaptation plus semantic alignment, but in a different setting: few-shot anomaly detection with synthetic anomaly generation, learnable normality and abnormality prompts, and gradient-calibrated alignment to meta-prompts [2508.16157]. ANPrompt instead addresses classification robustness under weak semantic noise in CLIP-style vision-language learning [2508.04677].

## 5. Empirical results and ablations

ANPrompt is evaluated on the standard 11-dataset CoOp suite: ImageNet, Caltech101, OxfordPets, Flowers102, Food101, StanfordCars, FGVCAircraft, EuroSAT, UCF101, DTD, and SUN397 [2508.04677]. The evaluation protocols are base-to-novel generalization, cross-dataset transfer from ImageNet, and domain generalization to ImageNet-V2, ImageNet-Sketch, ImageNet-A, and ImageNet-R [2508.04677].

In base-to-novel generalization, the reported average results are:

| Method | Base | Novel | HM |
|---|---:|---:|---:|
| ANPrompt | 86.15 | 77.70 | 81.70 |
| MMRL | 85.68 | 77.16 | 81.20 |
| CoPrompt | 84.00 | 77.23 | 80.48 |
| PromptSRC | 84.26 | 76.10 | 79.97 |

ANPrompt therefore achieves the best average harmonic mean, with reported gains over MMRL of \(+0.44\%\) on base, \(+0.43\%\) on novel, and \(+0.44\%\) on harmonic mean [2508.04677]. Dataset-level highlights include EuroSAT at 95.53 / 87.33 / 91.21, StanfordCars with the best base accuracy 83.57 and HM 78.85, FGVCAircraft with the best base accuracy 49.67 and HM 42.14, UCF101 with the best base accuracy 88.80 and HM 84.21, and Caltech101 with tied-best base accuracy 98.97 and best novel and HM of 94.73 and 96.80 [2508.04677]. The paper also notes that ANPrompt is not best on every dataset; for example, MMRL is slightly better on ImageNet novel/HM, and CoPrompt or MMRL are slightly stronger on OxfordPets [2508.04677].

In cross-dataset transfer, ANPrompt reports the best average accuracy at 67.14, ahead of CoPrompt at 67.00, TAC at 66.53, MaPLe at 66.10, PromptSRC at 65.81, CoCoOp at 65.74, and CoOp at 63.88 [2508.04677]. It is strongest on six of ten target datasets and is particularly strong on FGVCAircraft, EuroSAT, OxfordPets, StanfordCars, Flowers, and Caltech [2508.04677].

In domain generalization, the result is more mixed. ANPrompt reports an average of 60.40 on ImageNet-derived targets, compared with PromptSRC at 60.63, MMRL at 60.59, CoPrompt at 60.42, and MaPLe at 60.26 [2508.04677]. It is best on ImageNet-V2 with 64.63 but not best on average.

The ablation results clarify where the gains come from. Removing all anti-noise components yields HM 80.91. Adding WALoss alone gives 80.97, Anti-Prompt alone 81.10, TextNoise + WALoss 81.25, WALoss + Anti-Prompt 81.27, TextNoise + Anti-Prompt 81.31, and the full method 81.70 [2508.04677]. This shows that the gains are complementary rather than attributable to a single component.

Prompt token length is also studied: \(T=1\) gives HM 80.53, \(T=2\) 80.30, \(T=3\) 80.45, \(T=4\) 80.66, \(T=5\) 81.70, and \(T=6\) 81.66, with best performance at 5 prompt tokens [2508.04677]. Varying the weak-noise text feature weight gives HM 81.70 at 0.001, 81.21 at 0.01, 81.00 at 0.1, and 80.43 at 1.0, indicating that subtle perturbation helps while stronger perturbation degrades generalization [2508.04677].

## 6. Position within prompt-learning research and methodological interpretation

ANPrompt belongs to a broader family of prompt-learning methods that use auxiliary semantics to improve transfer. ATPrompt extends CLIP textual prompt learning by embedding universal attributes as explicit semantic anchors, moving from category-only alignment to attribute-category hybrid prompting and using differentiable search over attribute combinations [2412.09442]. AnchorOPT later argues that anchors should be dynamic in both value and position, replacing fixed textual attribute anchors with learned implicit anchor tokens and a learnable position matrix [2511.21188]. AAPE instead distills knowledge from multiple natural-language prompts into an image-conditional prompt embedding through aggregation and adaptation [2410.08696].

Within that landscape, ANPrompt’s distinctive move is to treat weak semantic perturbation itself as a constructive supervisory resource. It neither relies on explicit hand-authored attributes, as in ATPrompt, nor on latent anchors learned from class-description distillation, as in AnchorOPT, nor on prompt-summary distillation from large prompt sets, as in AAPE. Instead, it builds a perturbation-aware prompt space from intra-class textual variation and then ties that space to both encoder prompting and logit-level alignment [2508.04677].

This suggests a specific interpretation of its contribution. The paper is not primarily about richer class semantics or broader textual knowledge, but about making prompt-tuned VLMs less brittle in the vicinity of semantically neighboring alternatives. That helps explain why the strongest gains appear in settings where subtle semantic distinctions matter, such as EuroSAT, FGVCAircraft, and StanfordCars [2508.04677].

The method also has clear limitations. The paper does not report a dedicated semantic-noise corruption benchmark, so its robustness claims are supported indirectly through downstream generalization and ablation gains rather than explicit perturbation-severity evaluation [2508.04677]. Several implementation details remain underspecified, including clustering configuration, exact prompt injection depth, and the sim-loss formula [2508.04677]. Domain generalization gains are mixed rather than uniformly superior. The weak-noise weight must remain small, and larger perturbation weights reduce novel-class accuracy [2508.04677].

A plausible implication is that ANPrompt is most useful when the failure mode of prompt tuning is semantic brittleness rather than gross domain mismatch. Where the primary issue is underrepresented class knowledge, attribute anchoring or prompt-summary distillation may be more central [2412.09442] [2410.08696]. Where the issue is fixed anchor rigidity, dynamic anchor optimization may be more relevant [2511.21188]. ANPrompt’s specific niche is robustness to weak semantic drift in few-shot prompt-tuned CLIP classification [2508.04677].

In that sense, ANPrompt advances prompt learning by reframing noise not as an external corruption to be filtered away, but as a nearby semantic neighborhood that prompt representations should explicitly model and survive.

Source: https://www.emergentmind.com/topics/anprompt