{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/contrastive-instruction-tuning","title":"Contrastive Instruction Tuning","arxiv_id":"2402.11138","date":"2024-02-17","proceeding":null,"authors":["Tianyi Lorena Yan","Fei Wang","James Y. Huang","Wenxuan Zhou","Fan Yin","Aram Galstyan","Wenpeng Yin","Muhao Chen"],"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.","url_abs":"https://arxiv.org/abs/2402.11138v2","url_pdf":"https://arxiv.org/pdf/2402.11138v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"contrastive-instruction-tuning","repo_url":"https://github.com/luka-group/CoIN","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"sentence","task_name":"Sentence"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2402.11138","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.11138"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/luka-group/CoIN","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran":10,"ran_draft_wrong":1,"unverified":1},"by_repo_kind":{"official":{"samples":12,"ran":11,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"8428b74a83050be7","entry":"batch_concat","repo":"luka-group/CoIN","repo_kind":"official","path":"ContrastiveDataCollator.py","file_url":"https://github.com/luka-group/CoIN/blob/HEAD/ContrastiveDataCollator.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"8428b74a83050be7"}},{"code_sha256_prefix":"161e3ffde5559cc2","entry":"calc_avg_std","repo":"luka-group/CoIN","repo_kind":"official","path":"promptbench/postprocessing.py","file_url":"https://github.com/luka-group/CoIN/blob/HEAD/promptbench/postprocessing.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"161e3ffde5559cc2"}},{"code_sha256_prefix":"5bba9fd93c67d653","entry":"generate_flan_input","repo":"luka-group/CoIN","repo_kind":"official","path":"utils/common_utils.py","file_url":"https://github.com/luka-group/CoIN/blob/HEAD/utils/common_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5bba9fd93c67d653"}},{"code_sha256_prefix":"8e607e82d12be46e","entry":"get_perturb_key_name","repo":"luka-group/CoIN","repo_kind":"official","path":"promptbench/postprocessing.py","file_url":"https://github.com/luka-group/CoIN/blob/HEAD/promptbench/postprocessing.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"8e607e82d12be46e"}},{"code_sha256_prefix":"09be23529d48b7bd","entry":"load_contrastive_dataset","repo":"luka-group/CoIN","repo_kind":"official","path":"utils/common_utils.py","file_url":"https://github.com/luka-group/CoIN/blob/HEAD/utils/common_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"09be23529d48b7bd"}},{"code_sha256_prefix":"3ac33615ed8caaa5","entry":"load_data_from_pkl","repo":"luka-group/CoIN","repo_kind":"official","path":"utils/common_utils.py","file_url":"https://github.com/luka-group/CoIN/blob/HEAD/utils/common_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"3ac33615ed8caaa5"}},{"code_sha256_prefix":"c6b522eb3c5cd206","entry":"merge_batch_prompts","repo":"luka-group/CoIN","repo_kind":"official","path":"ContrastiveDataCollator.py","file_url":"https://github.com/luka-group/CoIN/blob/HEAD/ContrastiveDataCollator.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c6b522eb3c5cd206"}},{"code_sha256_prefix":"bce2eca67602b56d","entry":"save_importance","repo":"luka-group/CoIN","repo_kind":"official","path":"promptbench/visualize.py","file_url":"https://github.com/luka-group/CoIN/blob/HEAD/promptbench/visualize.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"bce2eca67602b56d"}},{"code_sha256_prefix":"56739640fa432aa6","entry":"separate_batch_prompts","repo":"luka-group/CoIN","repo_kind":"official","path":"ContrastiveDataCollator.py","file_url":"https://github.com/luka-group/CoIN/blob/HEAD/ContrastiveDataCollator.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"56739640fa432aa6"}},{"code_sha256_prefix":"bfd54763b0c09524","entry":"vis_by_delete","repo":"luka-group/CoIN","repo_kind":"official","path":"promptbench/visualize.py","file_url":"https://github.com/luka-group/CoIN/blob/HEAD/promptbench/visualize.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"bfd54763b0c09524"}},{"code_sha256_prefix":"da651a51337729cf","entry":"vis_by_grad","repo":"luka-group/CoIN","repo_kind":"official","path":"promptbench/visualize.py","file_url":"https://github.com/luka-group/CoIN/blob/HEAD/promptbench/visualize.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"da651a51337729cf"}},{"code_sha256_prefix":"beb8b40b0c4a53c8","entry":"create_dataset","repo":"luka-group/CoIN","repo_kind":"official","path":"promptbench/dataload.py","file_url":"https://github.com/luka-group/CoIN/blob/HEAD/promptbench/dataload.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"beb8b40b0c4a53c8"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}