Contrastive Instruction Tuning (2024)

Abstract: Instruction tuning has been used as a promising approach to improve the performance of large language models (LLMs) on unseen tasks. However, current LLMs exhibit limited robustness to unseen instructions, generating inconsistent outputs when the same instruction is phrased with slightly varied forms or language styles. This behavior indicates LLMs’ lack of robustness to textual variations and generalizability to unseen instructions, potentially leading to trustworthiness issues. Accordingly, we propose Contrastive Instruction Tuning (COIN), which maximizes the similarity between the hidden representations of semantically equivalent instruction-instance pairs while minimizing the similarity between semantically different ones. To facilitate this approach, we augment the existing FLAN collection by paraphrasing task instructions. Experiments on the PromptBench benchmark show that COIN consistently improves LLMs’ robustness to unseen instructions with variations across character, word, sentence, and semantic levels by an average of +2.5% in accuracy.1

heading: 1 Introduction
text: Instruction tuning has emerged to be an essential training paradigm of large language models (LLMs; Wei et al. 2022; Sanh et al. 2022; Mishra et al. 2022). By training models on various pairs of task instructions and instances, instruction tuning has been widely adopted in LLMs, such as TK-Instruct (Wang et al., 2022), InstructGPT (Ouyang et al., 2022), FLAN-T5 (Wei et al., 2022), and Alpaca (Taori et al., 2023), allowing them to follow various human instructions and fulfill user intents (Wang et al., 2022; Zhang et al., 2023).
Despite these advancements, current instructiontuned LLMs are not robust to instruction variations. Their performance may vary significantly when one
1Code is available at https://github.com/ luka-group/CoIN.
re-formulates an instruction with different forms or language styles (Zhu et al., 2023; Liu et al., 2023b). While optimal instructions for specific user intents may exist, there is no guarantee that user-crafted instructions will precisely match them. Indeed, user-crafted instructions often contain variations that can cause drop in LLMs’ performance, such as unintended minor mistakes (e.g., a typo; Wang et al. 2021, 2023a), different expression preferences (e.g., choice of synonyms or paraphrases; Gu et al. 2023; Zhu et al. 2023), inefficient descriptions (Sun et al., 2023), and varying formats (Liang et al., 2023). As shown in Fig. 1, given different instructions of the same intent, an instruction-tuned LLM like Alpaca can generate entirely different responses, some of which can lead to wrong answers. LLMs’ current lack of robustness to instruction variations severely limits their real-world applications. However, prior instruction tuning methods mainly focus on aligning the desired output for a given instruction-input pair and do not explicitly address models’ robustness against variations in instructions (Ouyang et al., 2022; Wei et al., 2022; Zhang et al., 2023; Longpre et al., 2023).
In this paper, we propose Contrastive Instruction Tuning (COIN), an instruction tuning method that
10288
leverages contrastive learning to align the hidden representations of instruction-instance pairs that are semantically equivalent but textually different and to differentiate those that are semantically distinct. Given the same input and output instance, we pair each instruction with its perturbed versions as positive samples. Observed that the hidden representations of data from different tasks already have low cosine similarity with each other (Liu et al., 2023a), we use the same instruction paired with different instance input and output as hard negative samples (refer to §3.2 for more details). Intuitively, by recognizing that the same instruction with different formulations can have the same meaning, the model can generate more consistent answers given different instructions of the same intent and become more robust to variations in language expressions. At the same time, negative samples encourage the model to understand that an instruction can lead to different outcomes in different contexts, facilitating the model to distinguish inputs with different user intents.
We assess LLMs’ robustness on the PromptBench benchmark (Zhu et al., 2023), which introduces variations to instructions of a diverse set of tasks at character, word, sentence, and semantic levels. Experiments on the benchmark show that COIN significantly improves task performance and reduces response variation of Alpaca on unseen instructions with variations at all four levels, achieving an average accuracy improvement of +2.5% compared with continual instruction tuning on the same dataset.
Our contributions are three-fold. First, we propose a contrastive instruction tuning method, COIN, to enhance LLMs’ robustness to semanticinvariant instruction variations. Second, experiments on PromptBench demonstrate the effectiveness of COIN in handling semantically equivalent instructions that differ at the character, word, sentence, and semantic levels. Third, to facilitate the proposed approach, we augmented the FLAN collection, a widely used instruction tuning dataset, with contrastive instructions. We will release the augmented dataset consisting of 52k entries and 104k instructions to support future work in this direction.

heading: 2 Related Work
text: In this section, we provide a brief summary of three highly related topics.
Instruction Tuning and Generalizability. Instruction tuning has emerged to be one of the pivotal techniques for enhancing the generalizability of LLMs (Sanh et al., 2022; Zhang et al., 2023; Ouyang et al., 2022). This capability is crucial for LLMs, as it determines models’ performance when encountering new data. The efficacy of instruction tuning has become more evident when the number of tasks scales up (Xu et al., 2022). Consequently, many recent studies have been focusing on fine-tuning LLMs with a wide range of tasks. For instance, large-scale datasets that encompass numerous NLP tasks and multiple data sources have been curated for effectively enhancing LLMs’ zero-shot generalizability (Sanh et al., 2022; Wei et al., 2022; Niu et al., 2023; Kung et al., 2023; Wang et al., 2023b). Despite performance gained on unseen tasks, LLMs fine-tuned with large-scale instruction datasets remain vulnerable to how the same instruction is expressed differently (Wang et al., 2021; Zhu et al., 2023; Liu et al., 2023b; Sun et al., 2023; Liang et al., 2023). This limitation motivates us to enhance LLMs’ robustness to instruction variations in this work.
Robustness of Instruction-Tuned LLMs. With the increasing reliance on LLMs, recent works have focused on having a comprehensive understanding of the robustness of instruction-tuned language models. Zhu et al. (2023), Gu et al. (2023), and Wang et al. (2023a) add perturbations to instructions across multiple levels (character, word, sentence, etc.) and show that current LLMs are not robust to the introduced perturbations. LLMs’ performance can also be degraded when presented with unobserved, paraphrased versions of task instructions (Sun et al., 2023). Furthermore, inconsistency in format and style in instruction expressions, such as placing instructions before, in between, or after the input instances, can decrease models’ performance (Liang et al., 2023). While evaluating and analyzing LLMs’ robustness has garnered more attention, enhancing the models’ robustness, particularly against varied instructions of the same task, is an underexplored problem. Our work is dedicated to addressing this gap.
Contrastive Learning. Contrastive learning, a self-supervised technique that involves training a model to contrast between positive and negative pairs of data points, has rapidly evolved and been adapted in NLP tasks, such as sentence embedding (Gao et al., 2022), summarization (Liu et al., 2022),
named entity recognition (Layegh et al., 2023), and logical reasoning (Bao et al., 2023). Within the context of instruction tuning, contrastive learning has been used with prefix-training to enhance the controllability towards desired attributes of LLMs (Qian et al., 2022). However, the focus of the work remains on steering the generated outputs towards an attribute (such as being sentimentally positive) that is assumed to be known but is difficult to be specified given the diversity of tasks that LLMs may handle, and it does not explicitly tackle the challenge of LLMs’ robustness against variations in instruction expressions. Inspired by the observation that contrastive learning is suitable for aligning semantically related sentences (Gao et al., 2022), we encourage LLMs to learn the semantic invariance of varied instructions for the same task and aim to address LLMs’ imperfect robustness at all four levels: character, word, sentence, and semantic.

heading: 3 Contrastive Instruction Tuning
text: In this section, we first provide a formal definition of contrastive instruction tuning (§3.1). Then, we introduce contrastive sample selection (§3.2) and the contrastive loss (§3.3) in our method COIN.

heading: 3.1 Overview
text: Assume that we have a (autoregressive) language model M and a dataset D = {(Ii, xi, yi)}Ni=1, in which Ii denotes the task instruction, xi is the instance input, and yi is the desired output. For each original entry, we create a semantically equivalent entry (I+i , x + i , y + i ), where x + i = xi and y+i = yi. I + i is constructed by adding textual perturbations to the original instruction while ensuring the underlying semantic meaning remains the same. Our goal is to learn a model M such that its hidden representations of semantically equivalent instruction-instance pairs, denoted as hM(Ii, xi, yi) and hM(I+i , x + i , y + i ), are close to each other in M’s hidden representation space, thereby enhancing its robustness against instruction variations.
As explored by many previous studies, instruction-tuning with large-scale datasets mainly focuses on aligning the desired output for a given instruction-instance pair from various tasks (Sanh et al., 2022; Longpre et al., 2023; Wei et al., 2022). However, current LLMs exhibit a lack of robustness when facing the same instruction
expressed in different forms (Sun et al., 2023; Zhu et al., 2023; Liang et al., 2023), causing LLMs to be unreliable when being deployed in the real world. To mitigate this limitation, our method COIN further leverages contrastive learning to maximize the similarity between hidden representations of semantically equivalent instruction-instance pairs. This approach enhances models’ robustness and consistency to variations in instruction expressions.

heading: 3.2 Contrastive Data Selection
text: Selecting effective positive and negative samples for each instruction is critical to contrastive learning. In COIN, we construct positive samples by varying the phrasing or template structure of original instructions, ensuring that the positive samples still share the same input and output with the original instance. This approach helps the model learn to align semantically similar instructions despite differences in phrasing.
For negative samples, we observe that the contrastive loss converges quickly when using instruction-input pairs of different tasks (i.e., normal negatives), leading to minor improvement in robustness. This observation is consistent with the findings in prior studies (Liu et al., 2023a): LLMs can distinguish between instructions of different tasks such that their hidden representations already have low cosine similarity. To collect hard negatives, we draw inspiration from near-OOD samples, which are data that come from the same task but with different classes (Winkens et al., 2020; Fort et al., 2021; Liu et al., 2023a). Prior studies found that it is more difficult for models to detect near-OOD samples than samples from other tasks (far-OOD). This finding indicates that the hidden representations of near-OOD samples may not be distinguishable enough and thus can provide informative supervision signals for contrastive learning. Accordingly, we choose such a sample (I−i , x − i , y − i ) that shares the same instruction as the original instance (I−i = Ii) but is paired with different input (x−i ̸= xi) and output (y−i ̸= yi) as a negative sample. For example, if yi is "yes", then y−i can be "no", ensuring the fundamental intent of the instruction-instance pair is different from the original one. Based on this approach, COIN encourages the model to align semantically equivalent instructions with different phrasings while contrasting inputs with different user intents.

heading: 3.3 Learning Objective
text: Our method COIN is illustrated in Fig. 2. We construct the training batch such that each original sample is matched with a perturbed instruction and an identical instance as a positive sample. All other in-batch samples are hard negatives selected according to §3.2, i.e. share the same instruction but paired with different instances.
Let hi, h+i , and h − i indicate model M’s hidden representation of the original, positive, and negative instruction-instance pairs, respectively. Since each original pair may have multiple in-batch negatives, here we use h−ij to indicate the hidden representation of the negative samples. To align the hidden representation hi and h+i , we optimize the model M with the contrastive loss Lictr, which is defined as
Lictr = − log esim(hi,h + i )/τ
esim(hi,h + i )/τ + ∑ j e sim(hi,h−ij)/τ ,
where sim(h1, h2) is the cosine similarity hT1 h2 ||h1||·||h2|| , and τ is a temperature hyperparameter. In COIN, we obtain the hidden representations by using the hidden state of the last token2 from the decoder of the language model.
2We also experimented with other pooling methods such as max and average pooling but found that using the last token’s hidden state yielded better results.
To preserve the generation ability of the language model, we follow Liu et al. (2022) to include the standard cross entropy loss for each instruction pair, which can be defined as follows:
Lient = 1
l
l∑
k=1
− log p(yk|Ii, xi, y<k)
where l is the length of the desired output for instruction-input pair (Ii, xi). This loss is computed for all samples in the batch.
Combining the above two parts, the overall learning objective is
LiCOIN = L i ent +max(λ, detach( Lient Lictr ))Lictr,
where detach(·) indicates that the loss value is detached from the computation graph and thus is treated only as a scalar. λ is the upper bound of the weight that is assigned to the contrastive loss. Based on empirical results, we found that setting λ too high, thereby significantly increasing the magnitude of the contrastive loss Lctr relative to the generation loss Lent, adversely affects the models’ generation ability. To mitigate this issue, we scale the contrastive loss to the same magnitude as the generation loss while setting an upper bound to the weighting, ensuring a balanced influence between enhancing robustness and maintaining generative performance. For more details on the weighting choice of the contrastive loss, refer to 5.3.

heading: 4 Experiment
text: In this section, we evaluate COIN’s performance on enhancing LLMs’ robustness to instruction variations on PromptBench, specifically 10 GLUE datasets with unseen3 instructions perturbed at different levels. We first provide an overview of the experiment settings (§4.1, §4.2, and §4.3) and then present a detailed analysis of the experiment results §4.4.

heading: 4.1 Training Datasets
text: In this work, we conduct experiments on a widely used instruction tuning dataset: the FLAN Collection (Wei et al., 2022). FLAN Collection (Wei et al., 2022) is a large-scale data collection that encompasses a wide range of tasks, including natural language inference, common sense reasoning, sentiment analysis, paraphrase identification, etc. This data collection is created by transforming 62 publicly available text datasets into instructional formats. 10 unique instruction templates are manually composed for each dataset. In this work, we choose 25 datasets with deterministic answers from the collection. To ensure each dataset has an equal chance of being sampled into the training set of COIN, we iterate through the training split of each dataset with a round-robin approach. For each entry, we create a positive sample by randomly selecting a predefined instruction template not used by the entry to paraphrase the instruction. Only paraphrasing is used for creating training data while various types of perturbations are included for evaluation (refer to §4.3). Avoiding assumptions about specific types of noise in instructions is crucial due to the high uncertainty LLMs face in real-world deployment. Hence, a robustness training method that can generalize to other types of perturbations is more desirable. We then select one entry from the remaining dataset as a negative sample, following the strategy in §3.2. Refer to Appx. §A for more details of the processed dataset.

heading: 4.2 Implementation Details
text: We use Alpaca (Taori et al., 2023), a model instruction-tuned from the LLaMA model (Tou-
3In this paper, “unseen instructions” refer to those whose textual expressions do not appear in the instruction-tuning dataset. Note that if the model exhibits inadequate robustness when handling unseen instructions for known tasks, its performance is likely to decrease further when confronted with unknown tasks. We consider the former as a rigorous evaluation setting without additional confounding factors.
vron et al., 2023) on the 52k Self-Instruct dataset, as the base model. When training models on the augmented FLAN collection, we use the same set of hyper-parameters, with the learning rate, batch size, and cut-off length set to 1 ∗ 10−4, 64, and 256 respectively. Since we observe that the magnitude of the contrastive loss can be small during the later phase of training and following Gao et al. (2022), we set the temperature τ and λ to 0.05 and 1000. All experiments are run on 2 NVIDIA RTX A5000 GPUs.

heading: 4.3 Evaluation Setting
text: To evaluate models’ robustness against variations in expression of instructions, we adopt the PromptBench benchmark (Zhu et al., 2023). Incorporating a diverse set of tasks, such as sentiment analysis, grammar correctness, duplicate sentence detection, and natural language inference, PromptBench introduces perturbation to task instructions at various levels: character, word, sentence, and semantic. Regarding the data used for evaluation, we sample 300 instruction-instance pairs from each GLUE task wherever the validation set exceeds this size.4 For each dataset, PromptBench predefines 20 instructions. We ensure that all selected and perturbed instructions for each dataset are not seen during the training time. Given that all instructions are unseen while GLUE tasks are seen during training time, this setting allows a more focused evaluation of LLMs’ robustness against variations in instructions without the confounding factor of task generalization.
Instruction Variations. Regarding instructions, we select six clean instructions predefined for each task. Then, we create perturbed versions of each instruction. Following PromptBench, we use DeepWordBug (Gao et al., 2018) to introduce character-level perturbations for certain words, and use TextFooler (Jin et al., 2020) to replace words with contextually similar words. At the sentence level, we implement the CheckList (Ribeiro et al., 2020) and append randomly generated sequences, which all have a length of 10 and consist of alphabets and digits, at the end of an instruction to distract LLMs. For the semantic-level perturbation, PromptBench defines 10 instructions that paraphrase the original instruction for each task while
4Due to the extensive computational requirement of evaluating the models on the entire benchmark, we sample a subset of instructions and data from all possible instructions and datasets.
following the linguistic behavior of six languages: Chinese, French, Arabic, Spanish, Japanese, and Korean. To keep the number of instructions the same as other types of perturbation, we randomly select one instruction from each language defined for each task, which are all different from the clean instructions. We also ensure that instructions used for evaluation differ from all instructions in the training dataset and thus are unseen by the model, preventing data contamination.
Metrics. For each type of perturbation, we report average accuracy and standard deviations of six instructions created for each GLUE dataset.

heading: 4.4 Results
text: In Fig. 3, we evaluate the base model, continual instruction tuning (i.e., base model fine-tuned on the same data as COIN with cross entropy loss only), and COIN on five groups of instructions across 10 GLUE datasets. Except for the clean group, which includes the original instructions defined for each dataset, each group contains instructions with the same type of perturbation, including character, word, sentence, and semantic perturbations.
The base model exhibits low accuracy and large performance variance when given instructions with different perturbations or instructions within the same perturbation group. With only around 52% accuracy on the clean instructions, the base model’s performance further decreases when the instructions are perturbed in all character, word, and sentence levels. The largest accuracy gap across different groups is 7.7%, observed between the word and the semantic groups. For instructions within the same group, the base model exhibits a variance ranging from 16.9% to 19.0%. These observations demonstrate that the base model is sensitive to how
instructions are formulated for different tasks. Compared to the base model, the continually instruction-tuned model shows increases in accuracy, which is expected as the model is exposed to more data and trained with more steps. Nevertheless, the performance gap between different groups can still be as large as 6.1% observed between the clean group and the group with wordlevel perturbation. This shows that the continually instruction-tuned model still lacks robustness to unseen instructions with variations across different levels.
Compared to continual instruction tuning, COIN further reduces performance variance and consistently improves accuracy for instructions within and across different groups without introducing any new data and training steps. As it can be seen from Fig. 3, COIN achieves improvements in accuracy for all types of perturbation, up to 4.4% for word-level perturbations where the continually instruction-tuned model exhibits its largest drop in performance. The largest performance gap is reduced to 3.6%. The consistent improvement across all types of perturbations demonstrates the generalizability of COIN at enhancing models’ robustness against variations in instructions at different levels. COIN also decreases the performance variance on instructions from the five groups by 1.6%, 1.9%, 2.1%, 2.5%, and 1.2%. This also shows that COIN can effectively help the model become less sensitive to specific instructions for each task and more consistent in its performance. For more detailed results, refer to Tab. 2.

heading: 5 Analyses
text: To provide a more comprehensive view of the impact of COIN on the model’s robustness to instruc-
tion variations, we further analyze the results of our method by examining the hidden representations of instruction variants (§5.1), task category (§5.2), and the weighting choice for the contrastive loss (§5.3).

heading: 5.1 Closer Representations of Instruction Variants
text: To understand the impact of COIN on the representations of instructions with variations at different levels, we visualize the hidden states of the last output tokens from the decoder’s last Transformer layer. Specifically, we select 300 data points from CoLA (Warstadt et al., 2019), choose one of its instructions, add perturbations at different levels to the instruction, and obtain the hidden states from the model.
As observed in Fig. 4, COIN’s hidden representations of inputs with instruction variations at different levels are much closer than those of the continually instruction-tuned model. In the embedding space of the continually instruction-tuned model, the representation of instructions with different perturbations, especially at character and word levels, are clustered almost into distinct groups. This may indicate that the model treats data points with the same instruction varied at different levels differently and thus is more sensitive to how the same instruction is formulated.
In contrast, the representations of data points with character, word, and sentence level variations are less distinguishable in COIN’s embedding space, with representations of instructions varied
at the word level (red) having greater overlap with those of the clean group (blue). This observation can be associated with COIN’s varied improvement in performance across different perturbations. As shown in Fig. 3, COIN achieves more evident improvement on instructions with word, character, and sentence level perturbations. It can be concluded from the two figures that when COIN effectively aligns the representations of perturbed instructions to those of the clean instructions, the model becomes more capable of capturing the original semantic meaning of the instructions. Thus, it becomes less sensitive to perturbations in instructions.
It can be observed that the representations of instructions with semantic level perturbation are located relatively far away from those of instructions with other types of perturbation. This is expected as paraphrasing introduces new structure and wording to the original instruction, which may lead to varied hidden representations. Nonetheless, COIN stabilizes the representation of the original and paraphrased instructions, demonstrating COIN can effectively align the representation of instruction variants with each other and thus enhance the model’s robustness to instruction variations.

heading: 5.2 Impact on Different Tasks
text: We examine COIN’s influence on the model’s performance for different tasks. Based on the task category defined in the PromptBench benchmark, we split the 10 GLUE datasets into four categories: (1) sentiment analysis, (2) natural language infer-
ence (NLI), (3) paraphrase identification, and (4) grammar correctness. Refer to Tab. 5 for specific datasets classified to each category.
As shown in §5.2, COIN achieves evident improvements in accuracy by +5.4% and +6.3% on paraphrase identification and grammar correctness tasks. Intuitively, these tasks can benefit more directly from COIN that aims to enhance the similarity of representations of semantically equivalent instruction-input pairs. For example, paraphrase identification can directly benefit from the model’s more refined ability to group textual inputs with similar semantic meanings, as COIN pushes representations of inputs with different meanings away from each other. Similarly, grammar correctness can also benefit from the contrastive loss, which may group hidden representations of grammatically correct inputs closer to each other and thus enable the model to become better at detecting inputs with invalid syntactic structures and grammatical rules.
On the other hand, COIN gains modest enhancement in accuracy on sentiment analysis and NLI tasks by +1.4% and +1.7% compared to the continual instruction-tuned model. For the sentiment analysis task, the continually instruction-tuned model has already achieved an accuracy of 89.0%. Obtaining further improvements can be challenging given that the model is already capable at distinguishing between sentences with different sentiments. Regarding NLI, the task requires a comprehensive understanding of the relationship between two sentences, which can depend on the model’s knowledge of various domains or reasoning ability to infer implicit meanings that are not directly stated. The complex relation between two sentences may not be explicitly captured by the hidden representations, meaning that COIN may not explicitly further enhance the model’s reasoning ability. However, COIN still obtains an improvement of +1.4% and +1.7% on the two tasks, demonstrating COIN’s ef-
fectiveness at enhancing the model’s ability to discern the nuanced inferential relation that underlies the overall semantic meaning of the instructioninput pairs.

heading: 5.3 Weighting of Contrastive Loss
text: As the weight of the contrastive loss may affect the extent to which COIN align representations of instruction variants (Liu et al., 2022), we examine how different values assigned to λ can affect COIN’s performance across different perturbation levels.
As shown in Fig. 5, COIN achieves its best average performance when λ = 1, 000. When λ is small, contrastive loss does not have significant impact on the model due to its small magnitude. The resulting model has similar performance and sensitivity to instruction variations as the continual instruction-tuned model. As λ increases, COIN’s performance increases across different types of perturbations, indicating that the contrastive loss is guiding the model to align representations of instruction variations closer to each other and thus
become more robust to the introduced perturbations.
However, when λ is too large, COIN’s performance decreases significantly, Therefore, based on the empirical results, we choose λ = 1, 000 for higher accuracy and smaller standard deviation. Refer to Tab. 4 for detailed experiment results of models with different contrastive loss weighting.

heading: 6 Conclusion
text: In this paper, we proposed COIN that aligns hidden representations of semantically equivalent instruction-instance pairs. Evaluation results on PromptBench, with instructions that differ at character, word, sentence, and semantic levels, demonstrate COIN’s effectiveness of enhancing LLMs’ robustness to semantic-invariant instruction variations. Future work can apply contrastive instruction tuning to enhance the robustness of models and tasks in other modalities, and on other prompt components such as few-shot demonstrations and system prompts.
Limitation
We summarize the limitations of this work as follows: First, the current contrastive data selection method only considers paraphrasing for positive instruction augmentation. More semantic-invariant data augmentation methods could be explored. Second, the experiment scale could be enlarged to include more instruction tuning datasets, instructiontuned models, and downstream tasks. This would provide additional evidence about COIN’s effectiveness. Third, while we use a rigorous evaluation setting to measure model robustness, evaluating the influence of COIN from other perspectives could
enhance understanding of contrastive instruction tuning.

heading: Acknowledgement
text: We appreciate the reviewers for their insightful comments and suggestions. Tianyi Yan was supported by the Center for Undergraduate Research in Viterbi Engineering (CURVE) Fellowship. Fei Wang was supported by the Amazon ML Fellowship. James Y. Huang was supported by a gift fund from the Amazon Center on Secure & Trusted ML. Muhao Chen was supported by the NSF Grant IIS 2105329, the NSF Grant ITE 2333736, the DARPA AIE Grant HR0011-24-9-0370, and an Amazon Research Award.

heading: A Datasets
text: For the training dataset sampled from the FLAN collection released under Apache-2.0 license, we select 25 datasets with answer options, which can be classified into 7 categories:
1. Natural Language Inference (NLI): how two sentences are related. The following datasets are used:
(a) ANLI (Nie et al., 2020) (b) CB (Marneffe et al., 2019) (c) MNLI (Williams et al., 2018) (d) QNLI (Rajpurkar et al., 2018) (e) RTE (Dagan et al., 2006; Bar-Haim et al.,
2006; Giampiccolo et al., 2007; Bentivogli et al., 2009)
2. Sentiment Analysis: whether the input text has positive or negative sentiment. The following datasets are used:
(a) IMDB (Maas et al., 2011) (b) Sent140 (Go et al., 2009) (c) SST2 (Socher et al., 2013) (d) Yelp (Zhang et al., 2015)
3. Paraphrase Detection: whether two sentences are semantically equivalent. The following datasets are used:
(a) MRPC (Dolan and Brockett, 2005) (b) QQP (Wang et al., 2018) (c) Paws Wiki (Zhang et al., 2019) (d) STS-B (Cer et al., 2017)
4. Reading Comprehension: answer questions based on passages that contain the answers. The following datasets are used:
(a) BoolQ (Clark et al., 2019) (b) MultiRC (Khashabi et al., 2018)
5. Coreference: find expressions that refer to the same entity in the input text. WSC273 dataset is used (Levesque et al., 2012).
6. Summarization: produce an abbreviated summary of the input text. For input with answer options, the model is asked to, for instance, choose the broader topic or the best summary among all choices provided. AG news dataaset is used (Zhang et al., 2015).
7. Miscellaneous:
(a) TREC (Li and Roth, 2002; Hovy et al., 2001): Classify questions into specified categories, such as whether the question is related to human, location, abbreviations, etc.
(b) CoLA (Warstadt et al., 2019): Linguistic acceptability.
(c) WIC (Pilehvar and Camacho-Collados, 2019): Evaluate intended meaning of a word within a context.
Refer to Tab. 3 for number of entries filtered and selected out from each dataset following the rules described in §4.1.

heading: B Detailed Experiment Results
text: For the results of models trained with different contrastive loss weighting, refer to Tab. 4.

heading: C GLUE Datasets Category
text: Following the task category defined in PromptBench benchmark, we split the GLUE datasets into four categories as shown in Tab. 5.

heading: Future Work
text: Future work can apply contrastive instruction tuning to enhance the robustness of models and tasks in other modalities, and on other prompt components such as few-shot demonstrations and system prompts. Limitation
We summarize the limitations of this work as follows: First, the current contrastive data selection method only considers paraphrasing for positive instruction augmentation. More semantic-invariant data augmentation methods could be explored. Second, the experiment scale could be enlarged to include more instruction tuning datasets, instructiontuned models, and downstream tasks. This would provide additional evidence about COIN’s effectiveness. Third, while we use a rigorous evaluation setting to measure model robustness, evaluating the influence of COIN from other perspectives could
enhance understanding of contrastive instruction tuning