Aligning Visual Contrastive learning models via Preference Optimization

## Abstract

Abstract Contrastive learning models have demonstrated impressive abilities to capture semantic similarities by aligning representations in the embedding space. However, their performance can be limited by the quality of the training data and its inherent biases. While Reinforcement Learning from Human Feedback (RLHF) and Direct Preference Optimization (DPO) have been applied to generative models to align them with human preferences, their use in contrastive learning has yet to be explored.
This paper introduces a novel method for training contrastive learning models using Preference Optimization (PO) to break down complex concepts. Our method systematically aligns model behavior with desired preferences, enhancing performance on the targeted task. In particular, we focus on enhancing model robustness against typographic attacks, commonly seen in contrastive models like CLIP. We further apply our method to disentangle gender understanding and mitigate gender biases, offering a more nuanced control over these sensitive attributes. Our experiments demonstrate that models trained using PO outperform standard contrastive learning techniques while retaining their ability to handle adversarial challenges and maintain accuracy on other downstream tasks. This makes our method well-suited for tasks requiring fairness, robustness, and alignment with specific preferences. We evaluate our method on several vision-language tasks, tackling challenges such as typographic attacks. Additionally, we explore the model’s ability to disentangle gender concepts and mitigate gender bias, showcasing the versatility of our approach.

### 1 Introduction

In recent years, Vision-Language Models (VLMs) such as CLIP (Radford et al., ) have revolutionized downstream vision-language tasks like classification (Conde & Turgutlu, ), object detection (Zhong et al., ), segmentation (Xu et al., ), and image generation (Saharia et al., ). These models are trained on large-scale web data, such as the 400 million text-image pairs used for training CLIP. However, despite their success, VLMs exhibit several vulnerabilities. For instance, adversarial attacks (Goodfellow et al., ; Moosavi-Dezfooli et al., ) and backdoor vulnerabilities (Bai et al., ; Liang et al., ) can lead to erroneous classifications with high confidence. CLIP has also been shown to be vulnerable to typographic attacks, where text within images causes misclassification (Goh et al., ). Additionally, biases such as gender and racial bias (Ruggeri & Nozza, ; Zhang et al., ; Bolukbasi et al., ; Jialu Wang et al., ) can be amplified by these models due to biases in their training datasets. Another dispreferred behavior occurs when models focus on tasks unrelated to the intended objective, as highlighted by (Menon et al., ). These challenges underscore the need for alignment methods in large pre-trained models.

Generative models, including Large Language Models (LLMs), have also been widely adopted for solving complex problems across various domains. Examples in the literature include GPT-4 (Achiam et al., ), Mistral (Albert Q. Jiang et al., ), and LLaMA (Touvron et al., ). These models are trained on massive datasets of unlabeled text, learning general language representations. Some of these LLMs require additional Supervised Fine-Tuning (SFT) to specialize for specific tasks using labeled data.
However, even with fine-tuning, LLMs can produce outputs that misalign with human values or safety expectations, such as the unreliability of LLMs in autonomous driving (Chen et al., ). To mitigate this, alignment techniques are applied, where models are further trained using a reward model that captures human preferences (Stiennon et al., ; Ouyang et al., ; Bai et al., ). Popular alignment approaches include Reinforcement Learning from Human Feedback (RLHF) (Ouyang et al., ; Christiano et al., ) and Direct Preference Optimization (DPO) (Rafailov et al., ), both of which extend the capabilities of these models beyond what SFT alone can achieve. These alignment techniques have improved the safety and relevance of LLM outputs by making them more aligned with human preferences.

Alignment methods have been explored in VLMs (Sun et al., ; Gallego, ; Clark et al., ), but to the best of our knowledge, they have not been extensively applied to contrastive learning models like CLIP. In this work, we extend the preference optimization paradigm to non-generative VLMs. Our approach builds on the contrastive learning framework while simultaneously aiming to preserve the pretrained knowledge—a concept known as continual learning (Garg et al., ; Wang et al., ).

In this work, we extend the preference optimization paradigm to contrastive learning models, focusing on enhancing robustness against typographic attacks and mitigating gender biases. By systematically aligning the model’s behavior with human preferences, we aim to preserve its pretrained knowledge while improving its performance in sensitive areas such as fairness and robustness. The core tasks addressed in this work—mitigating typographic attacks and disentangling gender biases—underscore the versatility of our approach and its potential for improving model alignment in real-world applications.
Our contributions are as the following:

- •
We extend preference optimization methods, originally developed for generative models, to non-generative models, particularly contrastive learning models. This expansion opens new opportunities for improving model alignment in non-generative tasks, preserving the pretrained knowledge of models while optimizing for desired behaviors.
- •
We propose controlling model behavior by adjusting the singular values of a learnable linear transformation. This allows fine-tuning of specific concepts, like gender, by modulating critical directions in the representation space while preserving overall performance. This method provides precise control and interpretability, enabling flexible post-training adjustments.
- •
Our experiments demonstrate the usefulness of applying preference optimization in contrastive learning tasks, such as training for robustness against typographic attacks and disentangling gender information from the embedding space, mitigating gender bias, and showcasing its effectiveness in improving model behavior in real-world scenarios.

### 2 Foundations & Related Work

Preference Optimization and RLHF.
Reinforcement Learning from Human Feedback (RLHF) aligns model behavior with human preferences by training the model based on feedback from human annotators. In the standard RLHF paradigm, annotators rank model responses. For example, given an input prompt $x$, a preference inequality might be expressed as $y_{l}\prec y_{w}$, meaning response $y_{w}$ is preferred over response $y_{l}$ for prompt $x$. These preferences are structured into datasets $\mathcal{D}=\{(x,y_{w},y_{l})\}$. The preference modeling often follows energy-based methods like the Bradley-Terry model (Bradley & Terry, ), where the probability of preferring $y_{w}$ over $y_{l}$ is modeled as below, where $r^{*}$ is the “true” reward function underlying the preferences:

$$ $P^{*}(y_{w}\succ y_{l}\mid x)=\frac{e^{r^{*}(x,y_{w})}}{e^{r^{*}(x,y_{w})}+e^{ r^{*}(x,y_{l})}}=\sigma\left(r^{*}(x,y_{w})-r^{*}(x,y_{l})\right).$ (1) $$

Since obtaining the true reward $r^{*}$ from a human is impossible, a reward model $r_{\phi}$ is learned by approximating the true reward function. This model is optimized by minimizing the negative log-likelihood of the human preference data:

$$ $\mathcal{L}_{R}(r_{\phi})=\mathbb{E}_{x,y_{w},y_{l}\sim\mathcal{D}}[-\log( \sigma(r_{\phi}(x,y_{w})-r_{\phi}(x,y_{l})))].$ (2) $$

Once the reward function is learned, the RL pipeline can be used to improve the generation policy. To prevent significant deviation from the pretrained reference model, a KL-divergence-shaped reward is incorporated, with the RL objective defined as:

$$ $\max_{\pi_{\theta}}\mathbb{E}_{x\sim\mathcal{D},y\sim\pi_{\theta}}[r_{\phi}(x, y)]-\beta D_{\mathrm{KL}}(\pi_{\theta}(y|x)\|\pi_{\text{ref}}(y|x)),$ (3) $$

where $\beta>0$ controls the degree of allowed divergence from $\pi_{\text{ref}}$.
Unlike RLHF, which is often slow and unstable due to its reliance on sampling and reinforcement learning, DPO (Rafailov et al., ) offers a more efficient and stable alternative by directly defining a loss function and bypassing reinforcement learning, allowing for standard optimization. However, DPO can sometimes overfit to preference datasets. To address this, Identity Preference Optimization (IPO) (Azar et al., ) bypasses the Bradley-Terry modelization and introduces a new loss function to decrease overfitting by controlling the gap between the likelihood ratios of the model and a reference model. Defining the policy ratio as below:

$$ $h_{\pi_{\theta}}(y_{w},y_{l};x)=\log\left(\frac{\pi_{\theta}(y_{w}|x)\pi_{ \text{ref}}(y_{l}|x)}{\pi_{\theta}(y_{l}|x)\pi_{\text{ref}}(y_{w}|x)}\right).$ (4) $$

We can now express both the DPO and IPO objectives in terms of this ratio:

$$ $\mathcal{L}_{\text{DPO}}(\pi_{\theta},\pi_{ref})=\mathbb{E}_{(x,y_{l},y_{w}) \sim\mathcal{D}}\left[-\log\sigma\left(\beta h_{\pi_{\theta}}(y_{w},y_{l},x) \right)\right],$ (5) $$

$$ $\mathcal{L}_{\text{IPO}}(\pi_{\theta};\pi_{\text{ref}})=\mathbb{E}_{(x,y_{w},y _{l})\sim\mathcal{D}}\left[\left(h_{\pi_{\theta}}(y_{w},y_{l};x)-\frac{\beta^{ -1}}{2}\right)^{2}\right].$ (6) $$

Additionally, newer methods like Kahneman-Tversky Optimization (KTO) (Kawin Ethayarajh et al., ) only require a binary signal of whether an output
is desirable or undesirable, making it more practical for many real-world applications:

$$ $\mathcal{L}_{\text{KTO}}(\pi_{\theta},\pi_{\text{ref}})=\mathbb{E}_{x,y\sim \mathcal{D}}[w(y)(1-v_{\text{KTO}}(x,y;\beta))],$ (7) $$

where the weights $w(y)$ depend on whether the outcome is desirable or undesirable, and $v_{\text{KTO}}$ adjusts the model based on the reference distribution:

$$ $v_{\text{KTO}}(x,y;\beta)=\begin{cases}\sigma(r_{\text{KTO}}(x,y)-z_{\text{ref }})&y\sim y_{\text{desirable}}|x\\ \sigma(z_{\text{ref}}-r_{\text{KTO}}(x,y))&y\sim y_{\text{undesirable}}|x\end{ cases},\quad w(y)=\begin{cases}\lambda_{U}&y\sim y_{\text{undesirable}}|x\\ \lambda_{D}&y\sim y_{\text{desirable}}|x\end{cases},$ $$

where $z_{\text{ref}}=\mathbb{E}_{x^{\prime}\sim\mathcal{D}}[\beta D_{\mathrm{KL}}(
\pi_{\theta}(y^{\prime}|x^{\prime})\|\pi_{\text{ref}}(y^{\prime}|x^{\prime})]$ and $r_{\text{KTO}}(x,y)=\beta\log\frac{\pi_{\theta}(y|x)}{\pi_{\text{ref}}(y|x)}$. Further details of mentioned methods are provided in Appendix A.
These methods have been widely adopted in training generative models, including diffusion models like Denoising Diffusion Policy Optimization (DDPO) (Black et al., ). This work investigates how these methodologies can be applied to contrastive learning-based models. This paper focused on two critical applications: mitigating typographic attacks and addressing biases, such as gender bias in contrastive models like CLIP.

Typographic attacks.
Typographic attacks exploit a model’s tendency to prioritize text over visual content, as shown by (Goh et al., ), causing CLIP to misclassify images based on misleading text. For example, writing ”cat” on an image of a dog could lead CLIP to incorrectly label it as ”an image of a cat”. This represents a clear example of undesired behavior in CLIP and is an ideal test case for preference optimization. Recent works, such as (Azuma & Matsui, ; Joanna Materzynska et al., ; Ilharco et al., ), address this shortcoming through various fine-tuning schemes.

Gender bias, task bias, and other inductive biases. Biases such as gender and racial bias (Ruggeri & Nozza, ; Zhang et al., ; Bolukbasi et al., ; Jialu Wang et al., ) are prevalent in vision-language models like CLIP. These models often unintentionally encode and maintain societal biases, leading to skewed predictions that disproportionately affect marginalized groups. Another common issue is task bias, where models may focus on unintended aspects of the task, further amplifying distortions in their outputs.

### 3 Methodology

#### 3.1 Problem Formulation: Contrastive Learning as an MDP

To effectively apply preference optimization to contrastive learning models, we first need to frame the problem within the reinforcement learning paradigm, modeling it as a Markov decision process (MDP). Specifically, we define the contrastive learning task as a one-step MDP, denoted as
$\mathcal{M}=(\mathcal{S},\mathcal{A},\rho_{0},P,R,\gamma)$, where $\mathcal{S}$ is the state space, $\mathcal{A}$ is the action space, $\rho_{0}$ is the initial state distribution, $P$ is the transition function, $R$ is the reward function, and $\gamma$ is the discount factor.
Since it is a one-step process, the transition function $P$ and the discount factor $\gamma$ are unnecessary, as states do not continue beyond the first step. In this setup, the model operates as a retrieval system: the input (either text or image) represents the state $s\in\mathcal{S}$, and the most similar text or image is selected as the action $a\in\mathcal{A}$. Additionally, $\rho_{0}$ defines the distribution of initial states, and $R$ represents the reward function.

The policy $\pi_{\theta}(a|s)$ is defined analogously to the contrastive learning objective, typically using a softmax function over the similarity score
$f_{\theta}(x,y)=\mathcal{I}_{\theta}(x)^{T}\mathcal{T}_{\theta}(y)/\tau,$
where $\mathcal{I}_{\theta}:\mathcal{X}_{\text{image}}\rightarrow\mathbb{R}^{d}$ and $\mathcal{T}_{\theta}:\mathcal{X}_{\text{text}}\rightarrow\mathbb{R}^{d}$ are the encoders for the image and text, respectively. Here, $\mathcal{X}_{\text{image}}$ and $\mathcal{X}_{\text{text}}$ represent the input distributions of images and texts, and $d$ is the dimensionality of the latent space where both image and text representations are embedded. $\theta$ represents the model parameters, and $\tau$ is the temperature. The action space is chosen from a fixed set of possible outputs
$\mathcal{A}=\mathcal{Y}\triangleq\{y_{i}\}_{i\in\{1,\dots,K\}},$
where $K$ represents the total number of classes. The components of $\mathcal{M}(\mathcal{S},\mathcal{A},\rho_{0},R)$ are defined as follows:

$$ $\begin{cases}s\triangleq x\\ a\triangleq y\end{cases},\quad\begin{cases}\rho_{0}(s)\triangleq p(x)\\ R(s,a)\triangleq r(x,y)\end{cases},\quad\pi_{\theta}(a|s)\triangleq\frac{e^{f_ {\theta}(y,x)}}{\sum_{y_{i}}e^{f_{\theta}(y_{i},x)}}.$ $$

This MDP framework can be applied to different tasks and provides flexibility in designing policies. We specifically utilize methods like DPO and KTO due to their implicit reward modeling, which allows for more effective model alignment with desired behaviors.

#### 3.2 Preference and Regularization Datasets

In our framework, the desired response of the model given an input $x$ (e.g., an adversarial image) is considered the preferred output $y_{w}$. This represents the correct or human-aligned response that we aim to optimize for. On the other hand, the dispreferred output $y_{l}$ refers to the model’s potentially biased response, or the target of an adversarial attack, or an undesirable outcome (such as bias related to gender or other attributes). The model learns to be robust against adversarial attacks or specific biases by comparing these two outputs.

We use two datasets to facilitate this learning:

- •
Preference Dataset $\mathcal{D}_{\text{pref}}$: This dataset contains pairs $(x,y_{w},y_{l})$, where $y_{w}$ is the preferred output and $y_{l}$ is the dispreferred output. The model learns to differentiate between desired and undesired outcomes through this dataset, improving its robustness against adversarial attacks and biases.
- •
Regularization Dataset $\mathcal{D}_{\text{reg}}$: This dataset consists of clean samples (images or text) without adversarial manipulation. It is used during training to ensure the model retains its accuracy on clean data, enhancing its robustness in general scenarios.

By combining the preference and regularization datasets, the model is trained to align with a specific behavior or be robust against adversarial inputs while maintaining performance on clean data and other downstream tasks.

#### 3.3 Preference-Based Contrastive Optimization

Building on the proposed formulation, preference optimization can be effectively applied to contrastive learning models by guiding the optimization process toward desired behaviors. Moreover, we can shape the policy to learn specific behaviors or patterns by defining them as preferred. Furthermore, in section 4.3, we highlight a significant advantage of this optimization paradigm as a fine-tuning method, helping retain the pre-trained knowledge of the model while adapting it to new preferences and support it with experiment results.

Recalling Equation 4, we first focused on policy ratio,
$h_{\pi_{\theta}}(y_{w},y_{l},x)$ which we can write as the following:

$$ $h_{\pi_{\theta}}(y_{w},y_{l},x)=\bigg{(}\log\pi_{\theta}(y_{w}|x)-\log\pi_{ \theta}(y_{l}|x)\bigg{)}-\bigg{(}\log\pi_{\text{ref}}(y_{w}|x)-\log\pi_{\text{ ref}}(y_{l}|x)\bigg{)}$ (8) $$

Given that the objective of the model $\pi_{\theta}$ is to simultaneously increase the probability of the preferred label $\pi_{\theta}(y_{w}|x)$ and decrease the probability of the dispreferred label $\pi_{\theta}(y_{l}|x)$, the term $h_{\pi_{\theta}}(y_{w},y_{l},x)$ is positive.

###### Lemma 3.1

Under the assumption that the text encoder is frozen, i.e., $\mathcal{T}_{\text{ref}}=\mathcal{T}_{\theta}=\mathcal{T}$, the policy ratio for models using the contrastive learning policy, in the methods such as DPO or IPO can be expressed as:

$$ $h_{\pi_{\theta}}(y_{w},y_{l},x)=\frac{1}{\tau}(\mathcal{I}_{\theta}(x)- \mathcal{I}_{\text{ref}}(x))^{T}(\mathcal{T}(y_{w})-\mathcal{T}(y_{l})).$ (9) $$

The proof is provided in Appendix B.1.

Based on Lemma 3.1, the term $h_{\pi_{\theta}}$ depends only on the term $(\mathcal{I}_{\theta}(x)-\mathcal{I}_{\text{ref}}(x))^{T}(\mathcal{T}(y_{w})-
\mathcal{T}(y_{l}))$. This indicates that the loss objective is designed to adjust $\mathcal{I}_{\theta}(x)$ to align more closely with the preferred text embedding difference, i.e., $\mathcal{T}(y_{w})-\mathcal{T}(y_{l})$, while maintaining appropriate proximity to the reference embedding $\mathcal{I}_{\text{ref}}(x)$. Having this in mind, we now raise the following question:

*How does the Gradient update work in case of DPO/IPO?*

First, we need to formulate the gradient of loss correctly in order to analyze it. The following Corollary provides a more insightful way of writing the gradient.

###### Corollary 3.2

Using Lemma 3.1 we can obtain the gradient of the loss as the following. Further details is provided in Appendix B.3.

$$ $\nabla_{\theta}\mathcal{L}_{\text{pref}}(\pi_{\theta},\pi_{ref})=-\underbrace{ w_{\text{pref}}(y_{w},y_{l};x)}_{({I})}\cdot\underbrace{\left[\frac{\partial \mathcal{I}_{\theta}}{\partial\theta}\right]^{T}(\mathcal{T}(y_{w})-\mathcal{T }(y_{l}))}_{({II})},$ (10) $$

where the gradient weight (I) in DPO is
$w_{\text{pref}}(y_{w},y_{l};x)=\sigma(-\beta h_{\pi_{\theta}}(y_{w},y_{l},x)),$
and in IPO,
$w_{\text{pref}}(y_{w},y_{l};x)=\left(\frac{1}{2\beta}-h_{\pi_{\theta}}(y_{w},y
_{l},x)\right).$
Intuitively, the term (II) shows that adjusting the image embedding $\mathcal{I}_{\theta}(x)$ in the direction of $\mathcal{T}(y_{w})-\mathcal{T}(y_{l})$, also encourages the model to better align with the preferred outputs. Importantly, if the distribution of $\pi_{\theta}$ deviates significantly from the reference distribution $\pi_{\text{ref}}$, the absolute value of the policy ratio increases. As noted previously, this effect reduces the update rate in the direction of (II), acting as a mechanism to control the model and keep it closer to the reference policy, preventing excessive divergence from the reference distribution.

In the KTO method, since there is no direct comparison between $y_{w}$ and $y_{l}$, we do not get the same equation as in 9. However, the main idea still applies. The model adjusts the image embedding $\mathcal{I}_{\theta}(x)$ to match human preferences, but it does so through a different optimization approach.

Figure: Figure 1: Overview of our proposed framework, on the left side, we calculate the preference optimization loss $\mathcal{L}_{pref}(\pi_{\theta},\pi_{\text{ref}};\mathcal{D}_{\text{pref}})$ using the preference dataset, and the output logits $\mathcal{T}(y_{w})^{T}\mathcal{I}(x),\mathcal{T}(y_{l})^{T}\mathcal{I}(x)$ from both models. on the right side the regulatory loss $\mathcal{L}_{\text{reg}}(\pi_{\theta},\pi_{\text{ref}};\mathcal{D}_{\text{reg}})$ is calculated using the clean regularization dataset.
Refer to caption: x1.png

###### Lemma 3.1

###### Corollary 3.2

##### 3.3.1 Regularization

In all of our training methods, we explicitly constrain our model to be proximal to the reference model on the preference dataset $\mathcal{D}_{\text{pref}}$. However, the preference dataset $\mathcal{D}_{\text{pref}}$ is often tiny and often fails to capture the entire data manifold since, in many cases, it only contains adversarial samples and out-of-distribution samples; this leads us to introduce additional regularization terms to our training, which serve to maintain proximity between the trained model and the reference.

This motivates the introduction of a regularization term $\mathcal{L}_{\text{reg}}$, designed to maintain proximity between the trained model $\pi_{\theta}$ and the reference model $\pi_{\text{ref}}$ as follow:

$$ $\displaystyle\mathcal{L}_{\text{reg}}(\pi,\pi_{\text{ref}};\mathcal{D}_{\text{ reg}})$ $\displaystyle=D_{\text{KL}}(\pi(y|x)\|\pi_{\text{ref}}(y|x))=\mathbb{E}_{x\sim \mathcal{D}_{\text{reg}}}\mathbb{E}_{y\sim\pi(y|x)}\left[\log\frac{\pi(y|x)}{ \pi_{\text{reg}}(y|x)}\right],$ (11) $$

where $\mathcal{D}_{\text{reg}}$ is the set of clean images; for example, in the typographic attack task, we construct $\mathcal{D}_{\text{reg}}$ using clean images from the training dataset. By adding this term to the loss function, the model can better maintain its accuracy on true labels, even when facing adversarial challenges, by using the regularization dataset $\mathcal{D}_{\text{reg}}$ to ensure robustness.

A shortcoming from these preference losses also suggests us to introduce additional regularization terms.

From this point on, for the sake of simplicity, we denote $\frac{\pi_{\theta}(y_{w}|x)}{\pi_{\text{ref}}(y_{w}|x)}=x_{1}$ and $\frac{\pi_{\theta}(y_{l}|x)}{\pi_{\text{ref}}(y_{l}|x)}=x_{2}$.

In order to better understand the effect of regularization, we will build up on top of following theorem.

###### Theorem 3.3

(Feng et al., )
The partial derivatives of Equation 5 with respect to $x_{1}$ and $x_{2}$ are given by:

$$ $\left|\frac{\partial\mathcal{L}_{\text{DPO}}(x_{1};x_{2})}{\partial x_{1}}/ \frac{\partial\mathcal{L}_{\text{DPO}}(x_{1};x_{2})}{\partial x_{2}}\right|= \frac{x_{2}}{x_{1}}<1.$ (12) $$

We also find a similar result in the case of IPO, We leave the proof in Appendix B.2.:

###### Proposition 3.4

The partial derivatives of Equation 6 with respect to $x_{1}$ and $x_{2}$ are given by:

$$ $\left|\frac{\partial\mathcal{L}_{\text{IPO}}(x_{1};x_{2})}{\partial x_{1}}/ \frac{\partial\mathcal{L}_{\text{IPO}}(x_{1};x_{2})}{\partial x_{2}}\right|= \frac{x_{2}}{x_{1}}<1.$ $$

In our problem formulation in section 3.1, we define the true label as $y_{w}$ and the adversarial label (e.g., typographic label) as $y_{l}$. According to Theorem 3.3 and Proposition 3.4, the rate of increase in the probability of the preferred response $y_{w}$ is lower than the rate of decrease in the probability of the dispreferred response $y_{l}$, Therefore, as suggested by Feng et al. (), our model primarily focuses on reducing the likelihood of the dispreferred response. This also motivates us to introduce more regulatory terms to ensure proximity.

For training, we propose using a total loss function from the dataset $\mathcal{D}=(\mathcal{D}_{\text{pref}},\mathcal{D}_{\text{reg}})$ as follows, where $\mathcal{L}_{\text{reg}}$ is the regularization loss and $\mathcal{L}_{\text{pref}}$ is the preference optimization objective:

$$ $\mathcal{L}(\pi_{\theta},\pi_{\text{ref}};\mathcal{D})=\mathcal{L}_{\text{pref }}(\pi_{\theta},\pi_{\text{ref}};\mathcal{D}_{\text{pref}})+\lambda_{\text{reg }}\mathcal{L}_{\text{reg}}(\pi_{\theta},\pi_{\text{ref}};\mathcal{D}_{\text{ reg}}).$ (13) $$

For example, consider giving images as input to CLIP, where the model chooses the corresponding caption from a fixed caption set. The selection process follows the policy we defined, using the softmax function over the similarity scores between the image and each caption in the set, as shown in Figure 1.

###### Theorem 3.3

###### Proposition 3.4

#### 3.4 Linear Transformations and Adaptations

In many cases, fine-tuning the entire model may be unnecessary and require more interpretation and control. Therefore, we employ a linear head on top of the encoders. This linear projection layer offers a more interpretable approach, providing a plug-and-play framework where the projection can be learned during training and then applied as needed.

This linear layer also introduces a linear-algebraic perspective to the adaptation process. Suppose the learned transformation is represented by the learnable matrix $W$. This matrix transforms both vectors $\mathcal{I}(x)$ and $\mathcal{T}(y)$ to $W\mathcal{I}(x)$ and $W\mathcal{T}(y)$ respectively, thereby transforming the similarity function $f(y,x)=\mathcal{I}(x)^{T}\mathcal{T}(y)/\tau$ into a new function $\tilde{f}(y,x)=\mathcal{I}(x)^{T}W^{T}W\mathcal{T}(y)/\tau$. Utilizing the Singular Value Decomposition (SVD), we can express $W=U\Sigma V^{T}$. Therefore, we have:

$$ $\tilde{f}(y,x)=\mathcal{I}(x)^{T}W^{T}W\mathcal{T}(y)/\tau=(V^{T}\mathcal{I}(x ))^{T}\Sigma^{2}(V^{T}\mathcal{T}(y))/\tau.$ (14) $$

In this formulation, the unitary matrix $V$ selects the important directions, and the diagonal matrix $\Sigma=\text{diag}(\sigma_{1},\dots,\sigma_{n})$ determines the degree of attenuation or amplification along each direction $v_{i}$. Specifically, each $\sigma_{i}$ determines whether the corresponding direction $v_{i}$ is strengthened ($\sigma_{i}>1$) or weakened ($\sigma_{i}<1$). Since our training process keeps the model close to the reference, each $\sigma_{i}$ remains relatively close to 1, and the overall matrix $W^{T}W$ remains close to the identity matrix.

This observation allows for post-training adjustments, where we can strengthen or weaken each $v_{i}$ as desired. One method for achieving this is by directly tuning each singular value $\sigma_{i}$ using either linear interpolation or matrix powers, as follows:

$$ $W_{t}=U\Sigma^{t}V^{T},$ (15) $$

where $\Sigma^{t}=\text{diag}(\sigma_{1}^{t},\dots,\sigma_{n}^{t}).$ This approach provides flexibility in adapting the model, enabling fine-grained control over the transformation applied to the encoded representations.

### 4 Experiments and Results

In this section, we experimentally justify our method capabilities, using the CLIP model as our contrastive learning model. An explanation of the datasets we used can be found in section E.

Setup: For all experiments, we used 8 A100 GPUs, each with 40GB of memory. For the typographic attack experiments, hyperparameters such as $\beta$ and $\lambda$ were selected based on the ablation studies in the appendix. Specifically, we used $\beta=\lambda=1$ for DPO, $\beta=\lambda=0.01$ for IPO, and $\beta=1.5$, $\lambda=0.01$ for KTO. In disentangling gender bias, we also set $\beta=\lambda=1$. All models were trained for three epochs with a batch size of 512. The learning rate was set to $2\times 10^{-5}$, and we employed the Adamax optimizer with a linear warmup and a cosine scheduler, setting the warmup ratio to 0.1. We set the random seed to 0 for all experiments to ensure reproducibility.

#### 4.1 Typographic Robustness

This section evaluates our method using the typographic attack mitigation task. We set up the problem as described, using the template "an image of a <class $i$>" (or a more dataset-specific template for non-generic images), designating the typographic class as the undesired outcome $y_{l}$ and the original caption as the desired outcome $y_{w}$.

Baselines: We evaluate our method against the following baselines: pre-trained CLIP (Radford et al., ), PAINT (Ilharco et al., ), and Defense-prefix (Azuma & Matsui, ), with results collected from (Azuma & Matsui, ) for comparability. We use ImageNet-100, a 100-class subset of ImageNet (Russakovsky et al., ) to train the model. Typographic attack images are generated by adding misleading text labels to the original images, using open-source implementations from (Azuma & Matsui, ).

**Table 1: Classification accuracy results on the datasets: O (Original dataset) and T (Typographic dataset). Note that other methods’ analyses and experimental results on the ImageNet dataset were conducted on a subset called ImageNetV2 validation, which was not publicly available when these results were derived. We report the results on different datasets.**
| Method | $\text{{ImageNet}}^{*}$ | Caltech101 | OxfordPets | StanfordCars | Flowers102 | FGVCAircraft | DTD | SUN397 | EuroSAT |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|  | O | T | O | T | O | T | O | T | O | T | O | T | O | T | O | T | O | T |
| CLIP | 62.02 | 39.10 | 88.64 | 63.97 | 87.35 | 58.95 | 58.72 | 21.02 | 66.32 | 31.32 | 18.99 | 10.83 | 44.57 | 25.53 | 61.74 | 34.02 | 42.98 | 4.86 |
| Materzynska+ | 54.38 | 44.91 | 80.53 | 74.73 | 75.01 | 63.61 | 40.33 | 15.79 | 51.86 | 34.95 | 13.23 | 8.28 | 36.28 | 33.03 | 51.06 | 39.52 | 37.32 | 16.22 |
| PAINT | 61.82 | 55.90 | 88.48 | 83.57 | 85.23 | 76.53 | 55.30 | 33.44 | 64.73 | 54.92 | 17.73 | 14.46 | 42.61 | 36.60 | 61.69 | 53.62 | 38.20 | 17.31 |
| Defense-Prefix | 62.48 | 49.83 | 89.28 | 79.54 | 87.22 | 72.86 | 57.47 | 28.64 | 63.82 | 44.12 | 19.26 | 14.49 | 40.64 | 31.60 | 61.41 | 43.50 | 43.85 | 9.85 |
| Ours (DPO) | 53.80 | 49.18 | 87.50 | 85.43 | 85.25 | 79.72 | 56.03 | 34.33 | 56.60 | 55.70 | 16.21 | 13.87 | 39.36 | 38.48 | 61.02 | 56.34 | 49.33 | 28.32 |
| Ours (IPO) | 47.61 | 42.75 | 85.73 | 83.78 | 85.32 | 80.44 | 53.67 | 35.02 | 54.50 | 52.80 | 17.97 | 15.86 | 40.53 | 39.94 | 61.91 | 58.05 | 46.12 | 43.23 |
| Ours (KTO) | 53.17 | 50.35 | 87.67 | 86.02 | 85.41 | 81.02 | 57.76 | 37.04 | 59.10 | 58.00 | 17.27 | 15.59 | 40.74 | 40.33 | 62.52 | 59.01 | 46.26 | 36.94 |
| Difference | $\downarrow$8.68 | $\downarrow$5.55 | $\downarrow$1.61 | $\uparrow$2.45 | $\downarrow$1.94 | $\uparrow$4.49 | $\downarrow$0.96 | $\uparrow$3.60 | $\downarrow$5.63 | $\uparrow$3.08 | $\downarrow$1.29 | $\uparrow$1.37 | $\downarrow$1.87 | $\uparrow$3.73 | $\uparrow$0.17 | $\uparrow$5.39 | $\uparrow$5.84 | $\uparrow$25.92 |

Our results, as seen in table 1, indicate that our method can effectively prevent typographic attacks with little loss of prior knowledge. In addition, we provided a qualitative analysis in Appendix C and D.

Table: Table 2: Classification accuracy results on real typographic datasets.

##### 4.1.1 Control between Optical Character Recognition and Object detection

In this experiment, we apply linear adaptations and retrain the network, then evaluate the training results. We then interpolate between models using previously discussed linear transformation methods, varying the transformation scaling $t$, defined in 15 from $-2.0$ to $1.2$ to assess performance. By doing this, we measure the effectiveness of our controlling scheme between the Optical Character Recognition (OCR) and Object Detection tasks.

Figure: Figure 2: (Left) Accuracy on typographic samples and percentage of typographic label predictions versus transformation scaling factor $t$. As $t$ increases, the model favors object labels over typographic labels while maintaining accuracy. (Right) Frontier of a DPO fine-tuned model, showing OCR accuracy vs. object detection accuracy across models with varying $t$.
Refer to caption: x2.png

Our results in Figure 2 demonstrate that we can confidently control the trade-off between OCR and object detection tasks without any additional training and with minimal impact on overall accuracy. This method allows us to choose which task to prioritize flexibly, and we can visualize the performance frontier, showing that improvements in OCR accuracy come at the cost of object detection accuracy and vice versa. The ability of this linear layer to manage the trade-off suggests that the concept is linearly separable within the CLIP embedding space.

#### 4.2 Disentangling Gender Understanding

In this setup, we demonstrate how our approach can completely reverse a contrastive learning model’s understanding of a concept, such as gender, without significantly altering other aspects of the model’s performance.

Figure: Figure 3: (Left) Image input. (Center) Comparison of model predictions before and after applying our gender-flipping method, showing changes in the predicted gender probabilities. (Right) Performance across transformation scaling $t$: As $t$ increases from 0 to 1, gender-specific predictions are reversed. The intersection at $t^{*}$ marks the point where gender information is effectively neutralized, leading to balanced male and female predictions. Task detection accuracy remains stable across all models. (I) and (II) are the corresponding captions: (I) The prediction that the man in the photo is working. (II) The prediction is that the woman in the photo is working.
Refer to caption: x3.png

We focus on flipping the CLIP model’s understanding of gender. We utilize a dataset of labeled images featuring men and women engaged in various activities and occupations from (Zhang et al., ). The problem setup is as follows: given choices like $y_{\text{man}}=\texttt{"The man is <activity>"}$ and $y_{\text{woman}}=\texttt{"The woman is <activity>"}$, the CLIP model typically picks one of these answers. To reverse the gender understanding, we designate the label with the correct activity but flipped gender as the preferred answer $y_{w}$ and the original gender-specific label as $y_{l}$.

As the regulatory term, we use the same dataset of images. However, we employ androgynous target labels such "The person in <activity>" to ensure that our model does not forget any information on detecting the correct activity.
We repeat our learning process using only the linear layer and then visualize the effect of varying the transformation scaling $t$ between 0 and 1.
Our results confirm that we have a high degree of control over CLIP’s understanding of gender, as demonstrated in Figure 3.

To further evaluate our results, we apply the modified CLIP models to an image retrieval task, distinct from the original text retrieval task used for training. We assess how this impacts the retrieved images for specific text prompts by computing the similarity scores between the prompts and images as $s(\text{image},\text{text})=\mathcal{I}_{\theta}(\text{image})^{T}\mathcal{T}_
{\theta}(\text{text})$. Using the dataset from (Zhang et al., ), we issue prompts describing individuals in various occupations to analyze the model’s behavior and showcase an instance in Figure 4.

Figure: Figure 4: Retrieved images for caption ”an image of a police”, Top: Reversed(6W,4M), Middle: Original(2W, 8M), Bottom: Neutralized(5W, 5M) being the model at $t=t^{*}$
Refer to caption: x4.png

#### 4.3 Preserving Pretrained Knowledge via Preference Optimization

In all of the aforementioned preference optimization methods, an implicit or explicit constraint exists to keep the model as close as possible to the reference model. Specifically, including KL-divergence regularization facilitates adjustments without deviating significantly from the reference model $\pi_{\text{ref}}$. To support this claim, Figure 5-(a) shows the KL-divergence between the output distributions of the model and the reference model on the original dataset, measured as $\mathbb{E}_{x\sim\mathcal{D}_{\text{reg}}}\left[D_{\mathrm{KL}}(\pi_{\theta}(
\cdot|x)||\pi_{\mathrm{ref}}(\cdot|x))\right]$, after fine-tuning for the typographic robustness task using different optimization methods.

Compared to Cross-Entropy optimization, our proposed methods result in lower divergence, demonstrating better retention of the model’s pre-trained knowledge. Additionally, Figure 5-(b) illustrates that we can control this deviation (i.e., retention of pre-trained knowledge) during fine-tuning by adjusting the $\beta$ hyperparameter, consistent with Equation 3. All models in (a) and (b) were trained on the Imagenet100 and FOOD101 datasets, respectively, and the models in (b) are optimized using the IPO method.

Figure: Figure 5: (a) KL-divergence comparison of our methods versus Cross-Entropy optimization. (b) Effect of the hyperparameter $\beta$ on divergence between the model and reference model.
Refer to caption: x5.png

### 5 Conclusion

This paper introduced a novel framework for improving contrastive learning models through Preference Optimization (PO). Our approach systematically aligns model behavior with desired preferences, enhancing robustness against typographic attacks and effectively mitigating biases, such as gender bias, in vision-language models like CLIP. By extending techniques such as Direct Preference Optimization (DPO) and Identity Preference Optimization (IPO), we showed that preference-based optimization can fine-tune models to meet specific behavioral requirements while maintaining their pre-trained knowledge. Our experiments demonstrated improved performance over standard contrastive learning methods in adversarial robustness and fairness, particularly in handling sensitive attributes like gender and race.

This work could open new pathways for applying preference-based optimization to non-generative models. It highlights its potential for tasks requiring fairness, alignment with human values, and robustness to adversarial attacks. Future work could explore further extensions of PO to other domains and modalities and investigate more fine-grained control mechanisms for tuning model behaviors post-training.

## Appendix

### Appendix A Theoretical Foundations of RLHF

RLHF extends the traditional reinforcement learning paradigm by incorporating human preferences into the learning process (Ouyang et al., ). This feedback can take the form of direct preference comparisons between different actions or sequences of actions, or it can involve explicit corrections when the agent’s behavior is undesirable. Human judgments are converted into a reward signal that helps the agent refine its policy. RLHF has gained attention in areas like natural language processing and fine-tuning large language models, where specifying a clear reward function is difficult and aligning the agent’s behavior with human values or intentions is critical. This method offers a more robust approach to training AI systems in tasks that require subjective judgment or nuanced decision-making.

In the context of aligning Large Language Models (LLMs), RLHF plays a crucial role. The process usually begins with supervised fine-tuning (SFT) of a pre-trained model on task-specific datasets, which helps the model learn to generate appropriate responses for various queries, resulting in a reference model denoted as $\pi_{\text{ref}}$. This model is refined using RLHF, which consists of three core steps.

1. Supervised Fine-tuning (SFT): Pre-trained language models often require an initial supervised fine-tuning phase to follow human instructions better. This phase aligns the model’s responses with human expectations. After this phase, we obtain a model $\pi_{\theta}^{\text{SFT}}$, which serves as the initial policy for further training.

2. Reward Model Training: Once the SFT model is trained, the next step in RLHF is to train a reward model $r_{\psi}(x,y)$, where $x$ is an input prompt and $y$ is the corresponding response. The reward model is trained to reflect human preferences between different responses. Given two responses $y_{w}$ (preferred, or ”win”) and $y_{l}$ (less preferred, or ”lose”), the Bradley-Terry model is commonly used to model human preferences:

$$ $p^{*}(y_{w}\succ y_{l}|x)=\frac{e^{r_{\psi}(x,y_{w})}}{e^{r_{\psi}(x,y_{w})}+e ^{r_{\psi}(x,y_{l})}},$ (16) $$

which can be rewritten as:

$$ $p^{*}(y_{w}\succ y_{l}|x)=\sigma(r_{\psi}(x,y_{w})-r_{\psi}(x,y_{l})),$ (17) $$

where $\sigma$ is the sigmoid function. To train the reward model, the following log-loss function is minimized over a dataset of human preferences $\mathcal{D}=\{(x^{(i)},(y_{w}^{(i)},y_{l}^{(i)}))\}_{i=1}^{N}$:

$$ $-\mathbb{E}_{(x,y_{w},y_{l})\sim\mathcal{D}}[\log\sigma(r_{\psi}(x,y_{w})-r_{ \psi}(x,y_{l}))].$ (18) $$

3. Fine-tuning with Reinforcement Learning: In the final stage of RLHF, the trained reward model is kept fixed, and the policy $\pi_{\theta}^{\text{RL}}$ (initialized from $\pi_{\theta}^{\text{SFT}}$) is fine-tuned using the PPO algorithm. The goal is to optimize the policy to maximize the expected reward predicted by the reward model while maintaining closeness to the supervised fine-tuned model through Kullback-Leibler (KL) divergence regularization. The optimization problem is formalized as:

$$ $\max_{\theta}\mathbb{E}_{x\sim\mathcal{D},y\sim\pi_{\theta}^{\text{RL}}(y|x)}[ r_{\psi}(x,y)-\beta\,D_{\mathrm{KL}}(\pi_{\theta}^{\text{RL}}(y|x)\|\pi_{ \theta}^{\text{SFT}}(y|x))],$ (19) $$

where $D_{\mathrm{KL}}(\pi_{\theta}^{\text{RL}}(y|x)\|\pi_{\theta}^{\text{SFT}}(y|x))$ represents the KL divergence between the RL policy and the SFT policy. The coefficient $\beta$ controls the trade-off between encouraging exploration and maintaining consistency with the supervised model. L divergence serves two purposes: it acts as an entropy bonus, encourages exploration, and ensures that the RL policy stays within the supervised fine-tuned model.

This structured process ensures that LLMs are capable of solving complex tasks and remain aligned with human preferences and ethical guidelines, which is essential in applications where human values play a crucial role.

#### A.1 Deriving Preference Optimization as a Supervised Learning Framework

In traditional RLHF, RL algorithms like PPO are required to optimize the policy since the reward signal is not differentiable. However, RLHF is often slow, primarily due to the need for sampling generations, and could be more stable in practice, especially in distributed settings. As a result, recent research has focused on designing closed-form loss functions that maximize the margin between preferred and dispreferred generations. One prominent approach is Direct Preference Optimization, which has gained popularity due to its mathematical equivalence with RLHF.

Direct Preference Optimization (DPO). DPO (Rafailov et al., ) leverages offline preference data to directly optimize the policy without relying on reinforcement learning-based methods like PPO. DPO demonstrates that the optimal solution to Eq. 19, $\pi_{\theta}^{*}$, satisfies the following equation:

$$ $r_{\theta}(x,y)=\beta\log\frac{\pi_{\theta}(y|x)}{\pi_{\text{ref}}(y|x)}+\beta \log Z(x).$ (20) $$

Here, $r_{\theta}$ represents the reward model, $\pi_{\theta}$ is the policy model, and $\pi_{\text{ref}}$ is the reference model. Both $\pi_{\theta}$ and $\pi_{\text{ref}}$ are initialized from the same SFT (Supervised Fine-Tuning) model, but only $\pi_{\theta}$ is further optimized during DPO, while $\pi_{\text{ref}}$ remains unchanged. $Z(x)$ is the partition function, and $\beta$ is a hyper-parameter that controls the intensity of the reward signal.

The preference probability $P_{\theta}$ is derived from pairwise comparisons using the Bradley-Terry model. Substituting Equation 20 into Equation 18 yields the following loss function for DPO:

$$ $\mathcal{L}_{\text{dpo}}(\pi_{\theta};\pi_{\text{ref}})=-\mathbb{E}_{(x,y_{w}, y_{l})\sim\mathcal{D}}\left[\log\sigma\left(\beta\log\frac{\pi_{\theta}(y_{w}| x)}{\pi_{\text{ref}}(y_{w}|x)}-\beta\log\frac{\pi_{\theta}(y_{l}|x)}{\pi_{ \text{ref}}(y_{l}|x)}\right)\right].$ (21) $$

In Equation 21, $\sigma$ denotes the sigmoid function, and $\mathcal{D}$ represents the dataset consisting of pairwise preferences. Each preference triplet $(x,y_{w},y_{l})$ includes a prompt $x$, a preferred response $y_{w}$, and a less preferred response $y_{l}$. This formulation allows DPO to optimize directly on pairwise preference data, avoiding the instability of RL methods while maintaining mathematical equivalence with traditional RLHF.

Identity Preference Optimization (IPO).
As the original DPO loss function has shown limitations in practice, such as overfitting to the preference dataset (Azar et al., ), IPO was proposed as an extension. IPO introduces a regularization term to the DPO loss to mitigate overfitting by controlling the gap between the log-likelihood ratios of the preferred and dispreferred outputs for both the model and the reference model. The IPO loss function is defined as:

$$ $\mathcal{L}_{\text{IPO}}(\pi_{\theta};\pi_{\text{ref}})=-\mathbb{E}_{(x,y_{w}, y_{l})\sim\mathcal{D}}\left[\left(\log\left(\frac{\pi_{\theta}(y_{w}|x)\pi_{ \text{ref}}(y_{l}|x)}{\pi_{\theta}(y_{l}|x)\pi_{\text{ref}}(y_{w}|x)}\right)- \frac{\beta^{-1}}{2}\right)^{2}\right].$ (22) $$

By adding this regularization, IPO ensures better generalization of the model, avoiding overfitting to specific preference patterns and maintaining stability in performance across different datasets.

Kahneman-Tversky Optimization (KTO).
In language modeling, collecting large-scale preference datasets can be difficult, but it is relatively easier to determine whether an output is desirable or undesirable. This challenge has inspired KTO (Kawin Ethayarajh et al., ), a method that bypasses the need for detailed preference data by using a binary signal to guide optimization. KTO is based on prospect theory (Tversky, ), directly maximizing the utility of generations using a model of human decision-making.

KTO has demonstrated higher data efficiency and better handling of imbalanced datasets compared to DPO. The KTO loss function is defined as:

$$ $\mathcal{L}_{\text{KTO}}(\pi_{\theta},\pi_{\text{ref}})=\mathbb{E}_{x,y\sim \mathcal{D}}[w(y)(1-v_{\text{KTO}}(x,y;\beta))],$ (23) $$

where $v_{\text{KTO}}(x,y;\beta)$ adjusts based on whether the output is desirable or not:

$$ $\displaystyle v_{\text{KTO}}(x,y;\beta)=\begin{cases}\sigma(r_{\text{KTO}}(x,y )-z_{\text{ref}})&y\sim y_{\text{desired}}|x\\ \sigma(z_{\text{ref}}-r_{\text{KTO}}(x,y))&y\sim y_{\text{undesired}}|x\end{ cases},\quad w(y)=\begin{cases}\lambda_{U}&y\sim y_{\text{undesired}}|x\\ \lambda_{D}&y\sim y_{\text{desired}}|x\end{cases}.$ $$

Here, $z_{\text{ref}}$ represents the reference reward, and $r_{\text{KTO}}(x,y)=\beta\log\frac{\pi_{\theta}(y|x)}{\pi_{\text{ref}}(y|x)}$. The weighting function $w(y)$ differentiates between desirable and undesirable outputs, where $\lambda_{D}$ and $\lambda_{U}$ are hyper-parameters controlling the weighting of each.

KTO’s key advantage is its ability to focus on maximizing the reward for desirable outputs without inflating the KL divergence term, effectively balancing utility and regularization. This makes KTO a practical solution for real-world applications, where collecting detailed preference data is infeasible.

In all three methods—DPO, IPO, and KTO—the policy $\pi_{\theta}$ is directly optimized without the need for a reward model. We incorporate these methods into our experiments to compare their effectiveness in various aspects, such as reducing bias and improving adversarial robustness and overall model performance.

### Appendix B Proofs

For simplicity, in all the sections that follow, we assume $\tau=1$.

#### B.1 Proof of Lemma 3.1

As seen in DPO and IPO,for preference optimization, using a preference dataset he key objective is to optimize based on a preference dataset by calculating $h_{\pi}(y_{w},y_{l},x)$ define in 4. using our defined policy $\pi_{\theta}$ with the softmax output, we find the following;

$$ $\displaystyle h_{\pi_{\theta}}(y_{w},y_{l},x)$ $\displaystyle=\log\left(\frac{\pi_{\theta}(y_{w}|x)\pi_{\text{ref}}(y_{l}|x)}{ \pi_{\theta}(y_{l}|x)\pi_{\text{ref}}(y_{w}|x)}\right)=\log\left(\frac{\frac{e ^{f_{\theta}(y_{w},x)}}{\sum_{y_{i}}e^{f_{\theta}(y_{i},x)}}\cdot\frac{e^{f_{ \text{ref}}(y_{l},x)}}{\sum_{y_{i}}e^{f_{\text{ref}}(y_{i},x)}}}{\frac{e^{f_{ \theta}(y_{l},x)}}{\sum_{y_{i}}e^{f_{\theta}(y_{i},x)}}\cdot\frac{e^{f_{\text{ ref}}(y_{w},x)}}{\sum_{y_{i}}e^{f_{\text{ref}}(y_{i},x)}}}\right)$ $\displaystyle=\log\left(e^{f_{\theta}(y_{w},x)-f_{\theta}(y_{l},x)+f_{\text{ ref}}(y_{l},x)-f_{\text{ref}}(y_{w},x)}\right)$ $\displaystyle=f_{\theta}(y_{w},x)-f_{\theta}(y_{l},x)+f_{\text{ref}}(y_{l},x)- f_{\text{ref}}(y_{w},x)$ $\displaystyle=\left(\mathcal{I}_{\theta}(x)^{T}\mathcal{T}_{\theta}(y_{w})- \mathcal{I}_{\theta}(x)^{T}\mathcal{T}_{\theta}(y_{l})-\mathcal{I}_{\text{ref} }(x)^{T}\mathcal{T}_{\text{ref}}(y_{w})+\mathcal{I}_{\text{ref}}(x)^{T} \mathcal{T}_{\text{ref}}(y_{w})\right)/\tau$ $\displaystyle=\mathcal{I}_{\theta}(x)^{T}(\mathcal{T}_{\theta}(y_{w})-\mathcal {T}_{\theta}(y_{l}))-\mathcal{I}_{\text{ref}}(x)^{T}(\mathcal{T}_{\text{ref}}( y_{w})-\mathcal{T}_{\text{ref}}(y_{w})).$ (24) $$

Assuming the text encoder
$\mathcal{T_{\theta}}$
is frozen, such that $\mathcal{T}_{\theta}=\mathcal{T}_{\text{ref}}=\mathcal{T}$, the expression simplifies to:

$$ $h_{\pi_{\theta}}(y_{w},y_{l},x)=(\mathcal{I}_{\theta}(x)-\mathcal{I}_{\text{ ref}}(x))^{T}(\mathcal{T}(y_{w})-\mathcal{T}(y_{l})).$ (25) $$

Our loss functions aim to increase $h_{\pi_{\theta}}(y_{w},y_{l},x)$, starting from the initialized value of 0 (since $\pi_{\theta}$ is initially set to $\pi_{\text{ref}}$). With some proximity constraints, as in DPO and IPO:

$$ $\mathcal{L}_{\text{DPO}}(\pi_{\theta},\pi_{ref})=\mathbb{E}_{(x,y_{l},y_{w}) \sim\mathcal{D}}\left[-\log\sigma\left(\beta h_{\pi_{\theta}}(y_{w},y_{l},x) \right)\right],$ (26) $$

$$ $\mathcal{L}_{\text{IPO}}(\pi_{\theta};\pi_{\text{ref}})=\mathbb{E}_{(x,y_{w},y _{l})\sim\mathcal{D}}\left[\left(h_{\pi_{\theta}}(y_{w},y_{l},x)-\frac{\beta^{ -1}}{2}\right)^{2}\right].$ (27) $$

#### B.2 Proof of Proposition 3.4

By rewriting $\mathcal{L}_{\text{IPO}}(\pi_{\theta},\pi_{\text{ref}})$ with $x_{1}$ and $x_{2}$, we obtain:

$$ $\mathcal{L}_{\text{IPO}}(\pi_{\theta},\pi_{\text{ref}})=\mathbb{E}_{(x_{1},y_{ 1},y_{2})\sim\mathcal{D}}\left[\left(h_{\pi_{\theta}}(y_{1},y_{2},x_{1},x_{2}) -\frac{\beta^{-1}}{2}\right)^{2}\right]$ $$

$$ $=\mathbb{E}_{(x_{1},y_{1},y_{2})\sim\mathcal{D}}\left[\left(\log\left(\frac{x_ {1}}{x_{2}}\right)-\frac{\beta^{-1}}{2}\right)^{2}\right]$ (28) $$

For $\frac{\partial\mathcal{L}_{\text{IPO}}(x_{1};x_{2})}{\partial x_{1}}$,

$$ $\displaystyle\frac{\partial\mathcal{L}_{\text{IPO}}(x_{1};x_{2})}{\partial x_{ 1}}$ $\displaystyle=2\left(\log\left(\frac{x_{1}}{x_{2}}\right)-\frac{\beta^{-1}}{2} \right)\cdot\frac{1}{x_{2}}\frac{x_{2}}{x_{1}}$ (29) $\displaystyle=2\left(\log\left(\frac{x_{1}}{x_{2}}\right)-\frac{\beta^{-1}}{2} \right)\cdot\frac{1}{x_{1}}$ $$

For $\frac{\partial\mathcal{L}_{\text{IPO}}(x_{1};x_{2})}{\partial x_{2}}$,

$$ $\displaystyle\frac{\partial\mathcal{L}_{\text{IPO}}(x_{1};x_{2})}{\partial x_{ 2}}$ $\displaystyle=2\left(\log\left(\frac{x_{1}}{x_{2}}\right)-\frac{\beta^{-1}}{2} \right)\cdot\left(-\frac{x_{1}}{x^{2}_{2}}\frac{x_{2}}{x_{1}}\right)$ (30) $\displaystyle=2\left(\log\left(\frac{x_{1}}{x_{2}}\right)-\frac{\beta^{-1}}{2} \right)\cdot\frac{-1}{x_{2}}$ $$

and for the second part we have:

$$ $\displaystyle\left|\frac{\partial\mathcal{L}_{\text{DPO}}(x_{1};x_{2})}{ \partial x_{1}}/\frac{\partial\mathcal{L}_{\text{DPO}}(x_{1};x_{2})}{\partial x _{2}}\right|$ $\displaystyle=\frac{2\left(\log\left(\frac{x_{1}}{x_{2}}\right)-\frac{\beta^{- 1}}{2}\right)\cdot\frac{1}{x_{1}}}{2\left(\log\left(\frac{x_{1}}{x_{2}}\right) -\frac{\beta^{-1}}{2}\right)\cdot\frac{1}{x_{2}}},$ (31) $\displaystyle=\frac{x_{2}}{x_{1}},$ $$

and finally given that $x_{1}=\frac{\pi_{\theta}(y_{w}|x)}{\pi_{\text{ref}}(y_{w}|x)}$ and $x_{2}=\frac{\pi_{\theta}(y_{l}|x)}{\pi_{\text{ref}}(y_{l}|x)}$ are two probability ratios, where $\pi_{\theta}(y|x)\in[0,1]$ and $\pi_{\text{ref}}(y|x)\in[0,1]$. Assuming $\pi_{\text{ref}}(y|x)$ is the probability of the fixed reference model, we can assume $\pi_{\text{ref}}(y_{w}|x)=\frac{1}{a}$ and $\pi_{\text{ref}}(y_{l}|x)=\frac{1}{b}$, where $(a,b\geq 1)$. In this case, we have $x_{1}\in[0,a]$ and $x_{2}\in[0,b]$. As the DPO optimization progresses, $x_{1}$ tends to increase and $x_{2}$ tends to decrease. Consequently, $\pi_{\theta}(y_{w}|x)$ will be greater than $\frac{1}{a}$, and $\pi_{\theta}(y_{l}|x)$ will be smaller than $\frac{1}{b}$. In other words, this implies that $x_{1}=\frac{\pi_{\theta}(y_{w}|x)}{\pi_{\text{ref}}(y_{w}|x)}$ is greater than 1, $x_{2}=\frac{\pi_{\theta}(y_{l}|x)}{\pi_{\text{ref}}(y_{l}|x)}$ is less than 1, and therefore $x_{2}<x_{1}$.

#### B.3 The Gradient of the DPO and IPO Objectives

The gradients of these loss functions highlight how the image encoder $\mathcal{I}_{\theta}$ is adjusted to align more closely with the desired output:

$$ $\nabla_{\theta}\mathcal{L}_{\text{DPO}}(\pi_{\theta},\pi_{ref})=-\beta\bigg{[} \underbrace{\sigma\bigg{(}-\beta h_{\pi_{\theta}}(y_{w},y_{l},x)\bigg{)}}_{ \text{higher when proximal to reference}}\cdot\underbrace{\left[\frac{\partial \mathcal{I}_{\theta}}{\partial\theta}\right]^{T}(\mathcal{T}(y_{w})-\mathcal{T }(y_{l}))}_{\text{increase $I_{\theta}(x)$ in direction of $\mathcal{T}(y_{w}) -\mathcal{T}(y_{l})$}}\bigg{]}.$ (32) $$

$$ $\nabla_{\theta}\mathcal{L}_{\text{IPO}}(\pi_{\theta},\pi_{ref})=-\bigg{[} \underbrace{\left(\frac{\beta^{-1}}{2}-h_{\pi_{\theta}}(y_{w},y_{l},x)\right)} _{\text{positive when proximal to reference}}\cdot\underbrace{\left[\frac{ \partial\mathcal{I}_{\theta}}{\partial\theta}\right]^{T}(\mathcal{T}(y_{w})- \mathcal{T}(y_{l}))}_{\text{increase $I_{\theta}(x)$ in direction of $\mathcal {T}(y_{w})-\mathcal{T}(y_{l})$}}\bigg{]}.$ (33) $$

These gradients show that both DPO and IPO adjust the image embedding $\mathcal{I}_{\theta}(x)$ in the direction of $\mathcal{T}(y_{w})-\mathcal{T}(y_{l})$, encouraging the model to better align with the preferred outputs.

### Appendix C What features does our method learn

In Figure 6, we showcase how applying our method, forces the model to focus on the suitable features of the data rather than different sorts of attacks such as typographic.

Figure: Figure 6: Typographic attack assessment. (Left) Saliency maps of vanilla CLIP and our fine-tuned version on typographic images. Each column represents a sample consisting of a typographic image, a saliency map for the prediction of vanilla CLIP, and a saliency map for the prediction of our fine-tuned version. As seen, vanilla CLIP focuses on unrelevant parts of images, especially typo texts, which results in false predictions. On the other hand, our model is capable of ignoring such fake text and focusing on the visual concept of the image, which results in true prediction. (Center) Image after typographic attack with misleading text (”clam chowder”). (Right) Model predictions: The finetuned model remains robust, correctly classifying the attacked image, while the original model misclassifies it. The inverse model confidently selects the typographic label but preserves classification accuracy.
Refer to caption: x7.png

### Appendix D Latent visualization using VQGAN

In this section, we further investigate our fine-tuned CLIP on typographical attack datasets. We use VQGAN-CLIP (Crowson et al., ) as the generative model which use CLIP in its backbone. The results are shown in figure 7. As can be seen, our fine-tuned CLIP completely ignores text in its image encoder representation and only focus on visual concepts which increase it reliabity and trustworthiness.

Figure: Figure 7: Retrieved images using VQGAN-CLIP (Crowson et al., ). The captions for image generation is ”focus”, ”Love”, ”Male police”, ”Time”. As can be seen, vanilla CLIP put the texts on image too, but our model fine-tuned on typographical attack dataset, SUN, ignores such image texts and generated only visual concepts.
Refer to caption: x8.png

### Appendix E Datasets

Tabel 3 shows the statistics of the datasets we used in this paper. To evaluate the accuracy of our method on both normal classification and typographic classification (results on table 1), we consider $9$ datasets: ImageNet-100 (Deng et al., ), Caltech101 (Fei-Fei et al., ), OxfordPets (Parkhi et al., ), StanfordCars (Krause et al., ), Flowers102 (Nilsback & Zisserman, ), FGVCAirCrafts (Maji et al., ), DTD (Cimpoi et al., ), SUN397 (Xiao et al., ) and EuroSAT (Helber et al., ). These datasets are not typographic attack datasets, so we follow the procedure in (Azuma & Matsui, ) to generate typographic attack images from these datasets. We also consider three more datasets designed for typographic attacks (results on table 2): Materzynska (Materzynska et al., ), PAINT (Ilharco et al., ), and RTA-100 (Azuma & Matsui, ). Figure 8 shows some samples from the RTA-100 dataset. Additionally, for the Gender Bias results and analysis, we considered the VL-Bias Zhang et al. () dataset. Also, we consider Food101 (Bossard et al., ) for additional experiments, including saliency maps in section C.

Figure: Figure 8: Samples from RTA-100 dataset.
Refer to caption: x9.png

**Table 3: Datasets statistics**
| Dataset | Num. of.<br>Classes | Num. of.<br>Images |
| --- | --- | --- |
| ImageNet-100 | 100 | 130,000 |
| Caltech101 | 101 | 9,146 |
| OxfordPets | 37 | 7,393 |
| StanfordCars | 196 | 16,185 |
| Flowers102 | 102 | 8,189 |
| FGVCAircraft | 100 | 10,000 |
| DTD | 47 | 5,640 |
| SUN397 | 397 | 108,754 |
| EuroSAT | 10 | 27,000 |
| Food101 | 101 | 101,000 |
| Materzynska | 19 | 171 |
| PAINT | 89 | 110 |
| RTA-100 | 100 | 1,000 |
| VL-Bias | 65 | 24,000 |

### Appendix F Hyperparameter Sensitivity Analysis

In this section, we analyze the impact of several hyper-parameters such as $\beta$ and $\lambda$. We utilize the FOOD101 dataset for training and SUN as the zero-shot dataset to assess model generalization. All experiments are conducted for 3 epochs, with a learning rate of $2\times 10^{-5}$, and a coefficient $\gamma=0.7$ in the Beta Moving Average.

#### F.1 Effect of β 𝛽 \beta italic_β

The hyper-parameter $\beta$ controls the deviation from the policy in the loss function 13. To assess its impact, we experiment with values between 0.01 and 1.5 on both the in-domain and zero-shot datasets.

As shown in Figure 9, our results indicate that IPO is highly sensitive to $\beta$. Additionally, the performance of both DPO and KTO decreases for excessively large $\beta$ values on the zero-shot dataset.

Figure: Figure 9: Ablation study on the effect of the hyper-parameter $\beta$ on classification accuracies for clean and typographic datasets. The results highlight the performance of DPO, IPO, and KTO models and their impact on in-domain accuracy and (b) zero-shot accuracy.
Refer to caption: x10.png

#### F.2 Ablation Study on the Regularization Loss ℒ reg subscript ℒ reg \mathcal{L}_{\text{reg}} caligraphic_L start_POSTSUBSCRIPT reg end_POSTSUBSCRIPT and the Effect of λ 𝜆 \lambda italic_λ

The hyperparameter $\lambda$ serves as the weight of the regularization term in our loss function. This regularizer is crucial for maintaining model performance on clean datasets during debiasing and adversarial training procedures. As shown in Figure 10, we vary $\lambda$ between 0.01 and 2.0 to analyze its impact on both in-domain and zero-shot datasets, highlighting a trade-off. In the zero-shot dataset, excessively large $\lambda$ values result in improved performance on the clean dataset but a decrease in performance on the typographic dataset. Conversely, very small values of $\lambda$ (e.g., 0.01) lead to lower performance on the clean dataset and higher performance on the typographic dataset.

Figure: Figure 10: Ablation study on the effect of the hyper-parameter $\lambda$ on classification accuracies for clean and typographic datasets. The results highlight the performance of DPO, IPO, and KTO models and their impact on in-domain accuracy and (b) zero-shot accuracy.
Refer to caption: x12.png

### Appendix G Beta Moving Average vs. Exponential Moving Average

Fine-tuning enhances task-specific performance but can degrade a model’s generalization, particularly in zero-shot tasks. Exponential Moving Average (EMA) tends to accelerate this degradation by diminishing the pre-trained model’s influence over time, whereas Beta Moving Average (BMA) (Bayer et al., ) retains more knowledge from the pre-trained model, achieving a better balance between task-specific adaptation and generalization. This balance is essential for tasks like debiasing, adversarial robustness, and zero-shot classification, as evidenced in VLMs for out-of-distribution detection (Shu et al., ). BMA applies a temporal ensemble approach, weighting each training checkpoint along the fine-tuning trajectory by a Beta distribution to compute the final model state.

$$ $\theta^{\text{TE}}=\sum_{t=0}^{T}\frac{\alpha_{t}}{\sum_{k=0}^{T}\alpha_{k}} \cdot\theta_{t},$ (34) $$

where $\alpha_{t}$ is determined by a Beta distribution and controls how much influence each model has in the final ensemble. Unlike EMA, which rapidly diminishes the contribution of earlier models (including the pre-trained model), BMA ensures that $\theta_{0}$ remains a significant part of the model’s knowledge, promoting better zero-shot generalization.

The weights $\alpha_{t}$ are drawn from the Beta distribution, normalized over the training steps:

$$ $\alpha_{t}=\text{Beta}(\gamma,\gamma)\left(\frac{t+0.5}{T+1}\right),$ (35) $$

where $\gamma$ is a hyper-parameter that controls the balance between the pre-trained and fine-tuned models. By setting $\gamma<1$, we ensure that both the pre-trained and fine-tuned models contribute more heavily to the final averaged model, thus reducing the forgetting problem of EMA.

To make BMA efficient in practice, it can be implemented as a moving average:

$$ $\theta_{t}^{\text{BMA}}=\frac{\sum_{k=0}^{t-1}\alpha_{k}\cdot\theta^{\text{BMA }}_{k}+\alpha_{t}\cdot\theta_{t}}{\sum_{k=0}^{t}\alpha_{k}},$ (36) $$

which allows us to compute the model’s temporal ensemble without needing to store all the intermediate checkpoints.

In all of our reported results, we employed the BMA update strategy to enhance zero-shot performance. The specifics of our training procedure are detailed in Algorithm 1, where: $x$ denotes the original image, $\tilde{x}$ the perturbed image (e.g., typographic image), $y$ the label, and $\tilde{y}$ the adversarial label (e.g., typographic label). As demonstrated in Table 4(b), we compare the performance of BMA and EMA. The hyperparameters $\beta$ and $\lambda$ for each method are the same as those used during their training on ImageNet.

Figure: Algorithm 1 Preference optimization for contrastive learning with BMA details

**Table 4: Comparison of the effect of BMA and EMA optimization strategies on the in-domain dataset (FOOD101) and the zero-shot dataset (SUN).**
|  | Original | Typographic |  |  |
| --- | --- | --- | --- | --- |
| Method | BMA | EMA | BMA | EMA |
| CLIP | 78.88 | 51.43 |  |  |
| DPO | 79.20 | 78.99 | 76.14 | 75.49 |
| IPO | 81.94 | 80.67 | 78.12 | 76.90 |
| KTO | 81.58 | 79.99 | 80.49 | 80.63 |

### Appendix H Sample Efficiency Analysis

In this section, we examine how efficiently our model learns with different dataset sizes. This analysis helps us understand how well the models perform with less data and how their accuracy changes as the dataset grows (see Figure 11). As expected, based on the foundation in Section 4.2 of (Azar et al., ), when there is insufficient training data, DPO tends to overfit, leading to poor performance on both In-domain and Zero-shot datasets, while KTO performs better in this situation.

Specifically, we focus on the impact of the number of typographic instances per image and how this affects both the in-domain and zero-shot generalization performance.

Figure: Figure 11: Ablation study on the effect of dataset size on classification accuracies for clean and typographic datasets. The results highlight the performance of DPO, IPO, and KTO models and their impact on (a) in-domain accuracy and (b) zero-shot accuracy.
Refer to caption: x14.png

**Table 5: Impact of number of typographic instances per image on in-domain (FOOD101) and zero-shot (SUN) performance. Results show accuracy (%) for different settings.**
| Number of Instances | FOOD101 (In-domain) | SUN (Zero-shot) |  |  |
| --- | --- | --- | --- | --- |
|  | BMA | EMA | BMA | EMA |
| 1 | 74.85 | 75.24 | 58.27 | 57.47 |
| 3 | 75.22 | 75.25 | 58.83 | 58.46 |
| 5 | 75.59 | 75.49 | 58.18 | 58.07 |
| 10 | 76.25 | 75.78 | 57.88 | 57.29 |

#### H.1 Impact of Number of Typographic Instances per Image

To investigate the effect of varying the number of typographic instances per image, we conducted experiments using 1, 3, 5, and 10 typographic variations for each image on the FOOD101 dataset (in-domain) and the SUN dataset (zero-shot). We evaluate the effect of varying the number of typographic instances per image on model performance. The results, summarized in Table 5, suggest that increasing the number of instances does not significantly improve accuracy, indicating that this augmentation technique may not be effective for enhancing the model’s generalization.

## Peer Reviews

confidence: 3
contribution: 2
initial_rating: 5
presentation: 4
questions: - The role of the transformation scaling parameter $t$ in the results in Table 1 remains unclear to me. Is the parameter varied between all settings or kept constant?
- The scaling range from -2 to 1.2 in Figure 2 has likely been chosen because the performance improves up until that point. But what happens if you scale between e.g. -4 and 4? It would be interesting to see even if performance starts to deteriorate after some threshold.
- Have you tried training separate linear projection layers for the text and image decoders?
soundness: 3
strengths: - This paper appears to be the first paper to apply preference optimisation to contrastive models, and presents an interesting use of SVD to control model behaviour. 
- Optimising robustness and mitigating (gender) biases are of significant interest, especially in high-risk domains. 
- The evaluation results suggest comparable and often better performance than alternative approaches in improving robustness while enabling a (to some degree) interpretable intervention technique. 
- The paper is well written and easy-to-follow.
summary: This paper introduces an alignment method designed for contrastive models, such as CLIP, using aligned and unaligned image-text pairs. In this setup, each image input has a preferred (or aligned) response and an dispreferred (or unaligned) output. The model is trained to differentiate between these two responses using preference optimisation designed as a one-step Markov decision process. Therefore, they use a preference dataset that pairs images with aligned and unaligned responses, and a regularisation dataset containing clean examples to maintain the model's ability to generalise to other downstream tasks. Importantly, they don't fine-tune the full model but train a single linear projection layer on top of the frozen text and image encoders. 

To further control the model's behaviour, the authors modify the singular values of the learned linear transformation. Specifically, they apply a singular value decomposition (SVD) to the weight matrix of this layer and scale all singular values using a scaling parameter $t$. This intervention technique builds on the intuition that the linear transformation transforms the original similarity function between image and text spaces.

They evaluate the effectiveness of their method in two settings. First, they evaluate its effect on typographic robustness by comparing it against baseline models (incl. standard CLIP, PAINT, Defense-Prefix) across nine datasets (incl. ImageNet, Flowers102, and EuroSAT). The preference dataset is created by adding misleading text to the original images of each dataset. They find that their method performs on par or better than prior methods, with a few exceptions. Despite improving the robustness, some performance gaps between the original and typographic dataset remain; for example, a gap of around 20 % on StanfordCars. Using the intervention technique leveraging the SVD of the linear projection layer, they show that they can modify the trade-off between OCR and object detection performance. In the second setting, they explore the possibility to disentangle gender representations. They train the linear transformation using a dataset of images depicting men and women during activities, and show that by scaling the singular values they can reverse gender-specific representations, including a specific scaling factor where the gender information is effectively neutralised, without significant degradation on the downstream task.
weaknesses: - Despite improving robustness over baseline methods in some datasets, none of the methods consistently outperforms other methods (see Table 1). 
- The baseline methods, PAINT and Defense-prefix, and their differences to the proposed method are not explained in the paper.  

Minor Comments: 
- Line 23: Incomplete sentence „Our experiments We demonstrate“. 
- Line 256: Comma instead of dot used. 
- Line 258: Comma should be a dot, and dot should be a comma. 
- Line 289: „this“ -> „This“ 
- The differences in Table 1 appear to computed inconsistently. While most of the time the differences are computed based on the best alternative method incl. the base model (e.g. OxfordPets), the difference for DTD O is computed with respect to PAINT, whereas CLIP seems to performs better. Overall, I think it would be easier to follow if all differences would be reported relative to the base CLIP model.

---

confidence: 2
contribution: 4
initial_rating: 8
presentation: 4
questions: Broadly speaking, for a general image-text task, e.g., VQA or retrieval, is there any guidance to design the preferences? The easiest way is following standard RLHF and curating a set with actual human preferences, but could the authors kindly suggest any other auxiliary information we can leverage?
soundness: 3
strengths: Originality: This is the first work to improve contrastive learning models through Preference Optimization. The idea of leveraging true labels and typographic labels for preferences, instead of curating a separate preference set from human annotation, is novel and interesting.

Clarity: This paper is well-written and has very clear motivations, backgrounds, methods, and experiments. 

Significance: The topic of aligning human preferences in contrastive learning is impactful, as models like CLIP are now used widely, yet many undesirable behaviors such as gender biases still exist.
summary: This paper introduces a method for aligning contrastive learning models (CLIP), with human preferences using preference optimization techniques such as DPO and IPO. By formulating contrastive learning as a one-step MDP and fine-tuning CLIP with these techniques, the authors enhance the model robustness of CLIP against typographic attacks and mitigate biases, particularly around gender. Experimental results show improvement on multiple datasets.
weaknesses: Significance: this paper relies on a preference dataset, which requires heavy annotations and the preference set will be very small compared to the training set of CLIP. Also, the preference would be very task-specific (e.g., typographic or gender), limiting the generalizability of the approach to new, unseen attacks or biases.

Quality: the inclusion of SVD makes it much slower to fine-tune on a larger scale. Also, the experiments focus on controlled, relatively smaller-scale datasets (the largest being ImageNet100), so the effectiveness of the approach is yet to be seen on diverse, complex large-scale datasets.

---

confidence: 4
contribution: 3
initial_rating: 5
presentation: 2
questions: The reviewer appreciates the well-organized background of DPO, IPO, and KTO, as well as the new perspective on these methods with CLIP. The paper focuses on providing new insights into preference optimization with CLIP. However, the most significant difference between DPO, IPO, and KTO—i.e., per-example weighting—is not discussed sufficiently in the paper (KTO might require further discussion). Additionally, the lack of a thorough comparison and the absence of clear distinctions in Table 1 together weaken the contribution. Therefore, the reviewer’s main questions are as follows:

1. What are the differences among the proposed method variants? Which types of inputs or datasets are weighted more or preferred for each variant? 
2. Could these variants be unified into a single method that outperforms the other baselines in Table 1?

The reviewer is open to reconsidering the rating if the authors could address these questions (including those in Weakness section).

Some typos:
* In Ln. 023, “Our experiments” appears incorrectly inserted.
* Table 2 lacks a reference. The possible related reference is in Ln. 1073 in the appendix.
* Several papers in the references are duplicated: Ln. 551 and Ln. 554; Ln. 559 and Ln. 562; Ln. 681 and Ln. 687; Ln. 750 and Ln. 754.
soundness: 3
strengths: 1. The proposed method is simple yet effective.
2. The authors provide a new perspective on IPO and DPO concerning the representation space learned by CLIP.
3. The alignment controllability through $t$ is effective.
4. The background and motivation are well-organized.
summary: The paper revisits well-known alignment techniques, such as Direct Preference Optimization (DPO) and Identity Preference Optimization (IPO), in the representation space learned by CLIP. The idea is simple yet effective: reformulate the policy $\pi$ in DPO and IPO by using the similarity scores between preference texts, $y_w$ (preferred) and $y_l$ (unpreferred), and the given adversarial image $x'$. The authors evaluate the proposed method on typographic attacks and show that it improves the CLIP model’s robustness to these attacks while preserving performance on the original datasets (without typographic attacks). To mitigate the overfitting issue of training large models on small datasets, the authors propose training a linear layer (parameterized by $W$) appended to the visual encoder, with both the pre-trained visual and text encoders frozen. Additionally, the authors propose applying SVD decomposition over $W$ as $W=U\Sigma^tV$, allowing the alignment magnitude to be controlled by $t\in\mathcal{R}$. The authors demonstrate that a learned alignment for gender bias can be effectively controlled by adjusting $t$.
weaknesses: 1. Clarity needs improvement.
    * $\mathcal{L}_{pref}$ in (10) appears without a definition. In Corollary 3.2, it is assumed to be either the DPO loss or IPO loss, while the experiments further include the case of KTO loss.
    * In (9), $\mathcal{I}_{ref}$ is frozen and has no trainable parameters, contributing solely to per-example weighting when substituted in (5), (6), and (7). It is recommended to clarify this in advance.
    * In Fig.1, $\mathcal{L}_{pref}$ is computed with the given triplet $(y_w, y_l, x’)$, where $x’$ is an adversarial image. The presence of multiple negative text representations, such as $\tau_1$, $\tau_2$, and $\tau_3$, is confusing without specifying either $y_w$ or $y_l$ as text inputs.
    * The overall loss in (13) is iterated over two different datasets, $D_{pref}$ and $D_{reg}$, simultaneously. Further explanation is needed on how the inputs $(y_w, y_l, x’)\in D_{pref}$ and $x\in D_{reg}$ are paired or sampled.
    * The bottom row (differences) in Table 1 is confusing, and it cannot correctly demonstrate the trade-off between O (Original dataset) and T (Target dataset) for each variant of the proposed method. The reviewer recommends indicating the improvement or degradation alongside each accuracy as $\color{green}{(+1.0)}$ or $\color{red}{(-1.0)}$ relative to the base model, i.e., CLIP, for clarity.
2. Lack of a concrete conclusion over comparisons with baselines. The results in Table 1 deserve more discussion. Examples are listed below.
    * No method in Table 1 consistently outperforms the others. Is there a large domain gap between different datasets that prevents any method from generalizing well across all of them?
    * PAINT significantly outperforms the proposed method (including all variants: DPO, IPO, and KTO) on both O and T in the ImageNet* column. Is the constraint of a single trainable linear layer in the proposed method too restrictive?
    * A comparison between different variants of the proposed method would be valuable. For example, what types of inputs are weighted more in different variants according to (10)?

---

confidence: 4
contribution: 2
initial_rating: 3
presentation: 1
questions: 1. Could this method be applied to other tasks apart from enhancing robustness against typographic attacks and mitigating gender biases?
2. Could you provide the ablation study results for components $\mathcal{L}_{pref}$ and $\mathcal{L}_{reg}$ in the loss function?
3. I do not understand the image in the left part of Figure 1. What does the obscured dog in the left part of Figure 1 signify?
4. What is the role of section 3.4 in your method? Why is fine-tuning the model mentioned in Section 3.4?
5. Could you provide evidence for your claim “the overall matrix $W^TW$ remains close to the identity matrix” in Section3.4？ 
6. Section 3 does not clearly introduce the method. In the last part of Section 3, you should package and summarize your method to give readers an overall understanding.
7. In Table 1, although the accuracy on the typographic dataset has increased compared to other methods, the accuracy on the original dataset has generally decreased. Therefore, the method has harmed the pretrained knowledge.
8. Could you provide an analysis of the different performances of DPO, IPO, and KTO in your method in Section 4?
9. What is the relationship between Section 4.4.1 and Section 4.1? I am not sure about the role of Section 4.4.1.
10.  What is the meaning of transformation scaling t in Section 4?
soundness: 2
strengths: It is significant to explore aligning non-generative model with human preferences using Preference Optimization.

This paper is well-motivated.
summary: This paper introduces Preference Optimization for training the contrastive learning model CLIP, aiming to enhance the model's robustness against typographic attacks and mitigate gender biases. This approach aligns the model with human preferences. Experimental results on datasets such as ImageNet, Caltech101, and OxfordPets demonstrate the effectiveness of this method.
weaknesses: See questions.

Meta-review: The reviewers largely appreciated the paper's novel approach of applying Preference Optimization (PO) to enhance the CLIP contrastive learning model's robustness and reduce biases. Both Direct Preference Optimization (DPO) and Identity Preference Optimization (IPO) show promise in mitigating typographic attacks and bias. Evaluations on various datasets demonstrate comparable or superior results compared to existing methods. The method's clarity and novelty were widely praised, with some reviewers suggesting further elaboration on specific experiments and results. On the other hand, the manuscript would benefit from a clearer explanation of the trade-offs between methods like DPO, IPO, and KTO, as well as a more thorough discussion of their respective effectiveness in different settings. Furthermore, while the approach was seen as promising, several reviewers noted that the experiments primarily involved smaller datasets, which might not fully demonstrate the method's scalability to more complex, real-world tasks. Despite these critiques, the general consensus remained positive, with the paper seen as a valuable contribution to improving contrastive learning models. We ask the authors to incorporate the feedback and additional results from the discussion phase.

Decision: Accept (Poster)