Aligning Visual Contrastive learning models via Preference Optimization

Amirabbas Afzali, Borna khodabandeh, Ali Rasekh, Mahyar JafariNodeh, Sepehr Kazemi Ranjbar, Simon Gottschalk

TL;DR

Researchers have successfully adapted Preference Optimization (PO) techniques—the same mathematical frameworks used to align Large Language Models (LLMs) like ChatGPT—to vision-language models like CLIP. By framing image-text retrieval as a series of "preferences," this novel method significantly boosts model robustness against typographic attacks and provides a surgical way to mitigate social biases without destroying the model's foundational knowledge.

The Problem: Typographic Attacks and Inherited Biases

Vision-Language Models (VLMs) such as CLIP are the backbone of modern AI, powering everything from zero-shot image classification to text-to-image generation. However, they suffer from a "reading problem." Because they are trained on massive, uncurated web datasets, they often prioritize text found inside an image over the actual visual content. This vulnerability leads to typographic attacks: if an adversary places a sticky note reading "iPod" on a physical apple, CLIP might confidently classify the fruit as a music player.

Beyond adversarial robustness, these models inherit the messy biases of the internet, such as gender or racial stereotypes. Traditional fine-tuning methods designed to correct these flaws often suffer from "catastrophic forgetting," where fixing one specific bias causes the model to lose its general-purpose accuracy. The authors sought a way to "align" these models—teaching them what features to prefer (the true object) and what to ignore (misleading text or biased associations)—while keeping their pre-trained intelligence intact.

Methods: Contrastive Learning as Preference Optimization

The core innovation of this paper is treating contrastive learning as a one-step Markov Decision Process (MDP). In this framework, the model isn't just matching images to text; it is making a choice between a "preferred" response (the correct label) and a "dispreferred" one (the attack label or biased association).

Overview of the preference-based contrastive optimization method.

The authors adapted three prominent alignment techniques from the LLM domain to the VLM space:

  1. DPO (Direct Preference Optimization): Directly optimizes the model to increase the likelihood of preferred image-text pairs over dispreferred ones.
  2. IPO (Identity Preference Optimization): A variation designed to prevent the model from overfitting to the preference data.
  3. KTO (Kahneman-Tversky Optimization): A newer method that only requires a binary "good/bad" signal rather than explicit pairs, making it highly scalable.

To ensure the model doesn't drift too far from its original state, the researchers incorporated a regularization term using clean data and employed a Beta Moving Average (BMA). Furthermore, they introduced a learnable linear projection head on top of the encoders. By performing Singular Value Decomposition (SVD) on this layer, they created a "tuning knob" that allows researchers to strengthen or weaken specific concepts (like gender) post-training.

Key Insights and Results

The study utilized a massive battery of datasets to prove the method's versatility, including general benchmarks (ImageNet-100, Caltech101), typographic attack datasets (RTA-100, PAINT), and bias mitigation sets (VL-Bias).

Retrieval is Preference: The fundamental breakthrough is realizing that contrastive learning is inherently a ranking problem. By ranking a "clean" caption higher than a "misleading" one, the exact same mathematical machinery used to align LLMs can be deployed for vision models.

Defeating Typographic Attacks: The experiments demonstrated that KTO is remarkably sample-efficient and highly effective at ignoring adversarial text.

Performance comparison across various datasets on original (O) and typographic attack (T) images.

As shown in the results, the proposed method significantly outperforms standard contrastive learning techniques. On the EuroSAT dataset, the KTO-based approach improved accuracy against typographic attacks by a staggering 19.63% over the best existing baseline (PAINT), while maintaining or even slightly improving accuracy on original, non-attacked datasets.

The "Concept Knob" and Bias Reversal: By adjusting the singular values of the linear transformation, the authors showed they could literally "dial down" the model's reliance on certain features. As a proof of concept, they successfully "flipped" the model's gender understanding—training the model to prefer the label "woman" for an image of a man (and vice versa)—proving they had gained surgical control over the embedding space without degrading the model's ability to recognize underlying activities.

Limitations and Future Work

While powerful, the method has its hurdles. The authors noted that IPO is highly sensitive to hyperparameters (specifically the $\beta$ value), making it tricky to stabilize. Additionally, when using the matrix power trick to amplify or dampen concepts, researchers must carefully manage normalization; otherwise, the embedding vectors can grow too large and destabilize the model.

Future work could involve applying these preference methods to even larger multi-modal models or exploring how to automate the generation of "preference pairs" to eliminate the need for manual dataset curation entirely.

Summary updated

BibTeX
@inproceedings{afzali2025aligning,
  author = {Amirabbas Afzali and Borna khodabandeh and Ali Rasekh and Mahyar JafariNodeh and Sepehr Kazemi Ranjbar and Simon Gottschalk},
  title = {{Aligning Visual Contrastive learning models via Preference Optimization}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=wgRQ2WAORJ},
}
Figure