Contrastive Instruction Tuning
Tianyi Lorena Yan, Fei Wang, James Y. Huang, Wenxuan Zhou, Fan Yin, Aram Galstyan, Wenpeng Yin, Muhao Chen
TL;DR
This work tackles the lack of robustness in instruction-tuned LLMs to variations in user instructions. It introduces Contrastive Instruction Tuning (CoIN), which uses paraphrase-based positives and same-instruction, different-input negatives to align hidden representations of semantically equivalent instruction–instance pairs, optimizing a combined loss that pairs generation with a temperature-scaled contrastive term. Evaluated on PromptBench with seven perturbation types across ten GLUE tasks, CoIN yields an average accuracy improvement of $+2.5\%$ over continual instruction tuning and reduces output variance, with larger gains on paraphrase identification and grammar correctness. The approach is complemented by augmenting the FLAN dataset with 52k paraphrase-based entries, offering a practical boost to robustness without extra data or training steps beyond the contrastive objective, and suggesting broad applicability to robustness across modalities and prompts.
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, 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. Code is available at https://github.com/luka-group/CoIN.
