PromptCD: Test-Time Behavior Enhancement via Polarity-Prompt Contrastive Decoding

Baolong Bi, Yuyao Ge, Shenghua Liu, Yuchen He, Siqian Tong, Lizhe Chen, Lingrui Mei, Zehao Li, Yiwei Wang, Yujun Cai, Ming-Hsuan Yang, Xueqi ChengarXiv 2026

TL;DR

PromptCD (Polarity-Prompt Contrastive Decoding) is a training-free, test-time behavior control method that significantly improves large model alignment and visual grounding. By contrasting a model's internal distributions (logits for LLMs and cross-modal attention maps for VLMs) under paired positive and negative prompts, it amplifies desired behaviors without parameter updates. This simple strategy consistently enhances helpfulness, honesty, harmlessness, and visual question-answering performance across multiple architectures.

What Problem Does This Paper Address?

Aligning Large Language Models (LLMs) with human values typically happens during post-training via methods like Reinforcement Learning from Human Feedback (RLHF) or Direct Preference Optimization (DPO). However, these approaches are computationally expensive, result in rigid parameters that cannot easily adapt to new contexts, and struggle to balance conflicting objectives (like being simultaneously helpful and harmless).

While test-time steering via prompting is a lightweight alternative, the authors reveal a frustrating phenomenon they call latent alignment: when given a positive instruction, a model's internal token probabilities do shift toward the desired behavior, but often not enough to override its deeply entrenched parametric priors. This failure of the internal signal to manifest in the final text generation is driven by stubborn knowledge.

The challenge is to design a generalized, parameter-free inference-time mechanism that can actively amplify these latent alignment signals across both text and vision modalities.

Methods

The authors introduce Polarity-Prompt Contrastive Decoding (PromptCD), which steers model behavior at decoding time by utilizing paired, opposing instructions called Polarity Prompts:

  • Positive Prompt ($P$): Explicitly encourages the target behavior (e.g., "Answer the question faithfully based on the context").
  • Negative Prompt ($N$): Suppresses the behavior or elicits a competing tendency (e.g., "Answer the question based on your own parametric knowledge").
Fig. 1. Overview of PromptCD. A unified framework for test-time behavior enhancement. By contrasting the logits (for text) or visual attention maps (for images) induced by positive and negative prompts, PromptCD effectively steers models toward desired goals without retraining. We demonstrate this capability through faithfulness enhancement in LLMs and visual attentiveness improvement in VLMs.

1. LLM Track: Token Logit Contrast

For text generation, PromptCD runs two parallel inference streams synchronized token-by-token. At each step, it subtracts the log-probabilities generated under the negative prompt from those generated under the positive prompt, scaled by a contrastive coefficient ($\gamma$).

To prevent the generation of gibberish (the "amateur correction" pathology), they apply an Adaptive Plausibility Constraint (APC), which restricts the next-token candidates to only those that are already highly plausible under the positive prompt alone.

Fig. 4. Illustration of PromptCD enhancing context-faithfulness. By con- trasting the probability distributions induced by positive and negative prompts, PromptCD amplifies contextual signals, guiding the LLM to generate faithful responses to the input question.

2. VLM Track: Cross-Modal Attention Contrast

For Vision-Language Models (VLMs), PromptCD extends this contrastive logic to the spatial dimension. It divides the cross-modal attention map induced by a task-specific positive prompt by the generic attention map induced by a vague negative prompt (e.g., "Write a general description of the image"). This cancels out background noise and generic visual saliency, isolating a high-fidelity attention mask that precisely targets task-relevant image regions.

PromptCD framework for cross-modal attention refinement in VLMs

Datasets

The authors evaluated PromptCD across a diverse suite of benchmarks targeting the "3H" dimensions and visual reasoning:

  • Helpfulness (Context-Faithfulness): Natural Questions (NQ), ConFiQA, and CoConflictQA.
  • Honesty (Factuality): TruthfulQA (multiple-choice) and FActScore (open-ended generation).
  • Harmlessness (Safety): SafeEdit (covering 9 unsafe categories like bias, illegal activities, and physical harm).
  • Knowledge Editing: MQUAKE-3K and MQUAKE-2002/HARD. They also introduced a MQUAKE-STUBBORN subset specifically to analyze instances where standard prompting fails due to parametric memory inertia.
  • VLM Evaluation (VQA): A-OKVQA, POPE, V*, and TextVQA.

Key Insights and Ideas

  • The "Willingness" vs. "Decisiveness" Gap: Standard prompting acts merely as a weak probabilistic bias. Models often possess the correct answer latently when prompted positively, but standard decoding strategies fail to capitalize on it because the margin over parametric priors is too small.
  • Instruction-Level Contrast: Unlike traditional contrastive decoding which requires a separate "amateur" model or complex layer heuristics, PromptCD demonstrates that the same model can serve as its own contrastive baseline simply by varying the input instructions.
  • Deep Layers Hold the Key for VLMs: Layer-wise analysis showed that deeper VLM layers provide the most effective contrastive attention maps. Early layers perform global visual scanning, while deep layers capture the refined semantic patterns necessary for task-relevant visual grounding.

Key Results

LLM Performance

PromptCD achieved substantial, consistent improvements across all three behavioral dimensions:

  • Helpfulness: Improved context-faithfulness (ConR) by an average of 62.64% on NQ, 59.49% on ConFiQA, and 11.08% on CoConflictQA compared to vanilla decoding.
  • Honesty: Achieved the highest MC1 scores on TruthfulQA (e.g., 42.59% on LLaMA2-7B-Chat) and led in open-ended factuality metrics on FActScore.
  • Harmlessness: Reached a 96.67% Defense Success rate on LLaMA2-7B-Chat while maintaining excellent language fluency, outperforming dedicated safety-tuning baselines like DINM which severely degrade text naturalness.

VLM Performance

  • PromptCD delivered massive relative performance gains on the visual search benchmark ($V^*$), notably achieving a 71.83% relative improvement for LLaVA-1.5-7B.
  • On TextVQA, it boosted accuracy from 47.8% to 58.2% for LLaVA-1.5-7B, outperforming external tool-based pipelines like SAM and YOLO while maintaining a lower computational footprint.

Limitations and Future Work

  • Inference Overhead: Because PromptCD requires maintaining dual synchronized forward passes (positive and negative streams), it incurs a 1.6× to 1.8× latency and throughput overhead during decoding.
  • Hyperparameter Sensitivity: The contrastive coefficient ($\gamma$) follows an inverted U-shape; setting it too high can disrupt linguistic coherence, meaning it requires careful validation.
  • Prompt Dependency: The method relies on human-engineered polarity prompts. Future work could explore automating the generation of optimal positive/negative prompt pairs for arbitrary target behaviors.

Summary updated

BibTeX
@misc{bi2026promptcd,
  author = {Baolong Bi and Yuyao Ge and Shenghua Liu and Yuchen He and Siqian Tong and Lizhe Chen and Lingrui Mei and Zehao Li and Yiwei Wang and Yujun Cai and Ming-Hsuan Yang and Xueqi Cheng},
  title = {{PromptCD: Test-Time Behavior Enhancement via Polarity-Prompt Contrastive Decoding}},
  year = {2026},
  eprint = {2602.20696},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.20696},
}

Loading related content...

Figure