{"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/editing-models-with-task-arithmetic","title":"Editing Models with Task Arithmetic","arxiv_id":"2212.04089","date":"2022-12-08","proceeding":null,"authors":["Gabriel Ilharco","Marco Tulio Ribeiro","Mitchell Wortsman","Suchin Gururangan","Ludwig Schmidt","Hannaneh Hajishirzi","Ali Farhadi"],"abstract":"Changing how pre-trained models behave -- e.g., improving their performance on a downstream task or mitigating biases learned during pre-training -- is a common practice when developing machine learning systems. In this work, we propose a new paradigm for steering the behavior of neural networks, centered around \\textit{task vectors}. A task vector specifies a direction in the weight space of a pre-trained model, such that movement in that direction improves performance on the task. We build task vectors by subtracting the weights of a pre-trained model from the weights of the same model after fine-tuning on a task. We show that these task vectors can be modified and combined together through arithmetic operations such as negation and addition, and the behavior of the resulting model is steered accordingly. Negating a task vector decreases performance on the target task, with little change in model behavior on control tasks. Moreover, adding task vectors together can improve performance on multiple tasks at once. Finally, when tasks are linked by an analogy relationship of the form ``A is to B as C is to D\", combining task vectors from three of the tasks can improve performance on the fourth, even when no data from the fourth task is used for training. Overall, our experiments with several models, modalities and tasks show that task arithmetic is a simple, efficient and effective way of editing models.","url_abs":"https://arxiv.org/abs/2212.04089v3","url_pdf":"https://arxiv.org/pdf/2212.04089v3.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":"editing-models-with-task-arithmetic","repo_url":"https://github.com/mlfoundations/task_vectors","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"editing-models-with-task-arithmetic","repo_url":"https://github.com/AntoAndGar/task_singular_vectors","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"editing-models-with-task-arithmetic","repo_url":"https://github.com/EnnengYang/AdaMerging","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"editing-models-with-task-arithmetic","repo_url":"https://github.com/flowritecom/flow-merge","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"editing-models-with-task-arithmetic","repo_url":"https://github.com/idankinderman/fs_merge","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"editing-models-with-task-arithmetic","repo_url":"https://github.com/iurada/talos-task-arithmetic","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"editing-models-with-task-arithmetic","repo_url":"https://github.com/thennal10/fisher-nodes-merging","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"editing-models-with-task-arithmetic","repo_url":"https://github.com/yanyang19/ImPart","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"editing-models-with-task-arithmetic","repo_url":"https://github.com/zibojia/COCOCO","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"negation","task_name":"Negation"},{"task_slug":"task-arithmetic","task_name":"Task Arithmetic"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2212.04089","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2212.04089"}},"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/iurada/talos-task-arithmetic","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/mlfoundations/task_vectors","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/zibojia/COCOCO","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/thennal10/fisher-nodes-merging","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/EnnengYang/AdaMerging","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/flowritecom/flow-merge","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/idankinderman/fs_merge","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/AntoAndGar/task_singular_vectors","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/yanyang19/ImPart","reach":null}],"summary":{"ran":3,"ran_draft_wrong":2,"unverified":10},"by_repo_kind":{"listed":{"samples":14,"ran":4,"repositories":6}},"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":4,"samples":[{"code_sha256_prefix":"f075638111e309f6","entry":"Model","repo":"flowritecom/flow-merge","repo_kind":"listed","path":"flow_merge/lib/merge_methods/task_arithmetic.py","file_url":"https://github.com/flowritecom/flow-merge/blob/HEAD/flow_merge/lib/merge_methods/task_arithmetic.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":"f075638111e309f6"}},{"code_sha256_prefix":"d4eaf7b390d8c9b0","entry":"ModelWeight","repo":"flowritecom/flow-merge","repo_kind":"listed","path":"flow_merge/lib/merge_methods/task_arithmetic.py","file_url":"https://github.com/flowritecom/flow-merge/blob/HEAD/flow_merge/lib/merge_methods/task_arithmetic.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":"d4eaf7b390d8c9b0"}},{"code_sha256_prefix":"1856c2a053748d8a","entry":"TaskVector","repo":"yanyang19/ImPart","repo_kind":"listed","path":"merge/task_vector.py","file_url":"https://github.com/yanyang19/ImPart/blob/HEAD/merge/task_vector.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1856c2a053748d8a"}},{"code_sha256_prefix":"dcafd602728bc51e","entry":"get_param_names_to_merge","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"dcafd602728bc51e"}},{"code_sha256_prefix":"55e4b4e72a5278b6","entry":"symmetric_difference","repo":"AntoAndGar/task_singular_vectors","repo_kind":"listed","path":"src/models/task_vectors.py","file_url":"https://github.com/AntoAndGar/task_singular_vectors/blob/HEAD/src/models/task_vectors.py","link_basis":"first_harvest_node","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":"55e4b4e72a5278b6"}},{"code_sha256_prefix":"14d47affd7a90bf1","entry":"BaseMergeMethodSettings","repo":"flowritecom/flow-merge","repo_kind":"listed","path":"flow_merge/lib/merge_methods/task_arithmetic.py","file_url":"https://github.com/flowritecom/flow-merge/blob/HEAD/flow_merge/lib/merge_methods/task_arithmetic.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":"14d47affd7a90bf1"}},{"code_sha256_prefix":"69c09a0f38cec086","entry":"DareTiesMergingSettings","repo":"flowritecom/flow-merge","repo_kind":"listed","path":"flow_merge/lib/merge_methods/task_arithmetic.py","file_url":"https://github.com/flowritecom/flow-merge/blob/HEAD/flow_merge/lib/merge_methods/task_arithmetic.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":"69c09a0f38cec086"}},{"code_sha256_prefix":"6ed53c7b8f6e6d42","entry":"MergeMethod","repo":"flowritecom/flow-merge","repo_kind":"listed","path":"flow_merge/lib/merge_methods/task_arithmetic.py","file_url":"https://github.com/flowritecom/flow-merge/blob/HEAD/flow_merge/lib/merge_methods/task_arithmetic.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":"6ed53c7b8f6e6d42"}},{"code_sha256_prefix":"9689fce839afa1ba","entry":"TaskArithmetic","repo":"flowritecom/flow-merge","repo_kind":"listed","path":"flow_merge/lib/merge_methods/task_arithmetic.py","file_url":"https://github.com/flowritecom/flow-merge/blob/HEAD/flow_merge/lib/merge_methods/task_arithmetic.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":"9689fce839afa1ba"}},{"code_sha256_prefix":"69cf6d6c6a4ba37c","entry":"TaskArithmeticSettings","repo":"flowritecom/flow-merge","repo_kind":"listed","path":"flow_merge/lib/merge_methods/task_arithmetic.py","file_url":"https://github.com/flowritecom/flow-merge/blob/HEAD/flow_merge/lib/merge_methods/task_arithmetic.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":"69cf6d6c6a4ba37c"}},{"code_sha256_prefix":"f893acd6847a295a","entry":"TaskVector","repo":"EnnengYang/AdaMerging","repo_kind":"listed","path":"src/task_vectors.py","file_url":"https://github.com/EnnengYang/AdaMerging/blob/HEAD/src/task_vectors.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f893acd6847a295a"}},{"code_sha256_prefix":"da649407a76a7991","entry":"TaskVector","repo":"idankinderman/fs_merge","repo_kind":"listed","path":"src/merges/task_vectors.py","file_url":"https://github.com/idankinderman/fs_merge/blob/HEAD/src/merges/task_vectors.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"da649407a76a7991"}},{"code_sha256_prefix":"1fbdfa9343efe4a0","entry":"TiesMergingSettings","repo":"flowritecom/flow-merge","repo_kind":"listed","path":"flow_merge/lib/merge_methods/task_arithmetic.py","file_url":"https://github.com/flowritecom/flow-merge/blob/HEAD/flow_merge/lib/merge_methods/task_arithmetic.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":"1fbdfa9343efe4a0"}},{"code_sha256_prefix":"b255d4dccd3371a7","entry":"_TaskVector","repo":"AntoAndGar/task_singular_vectors","repo_kind":"listed","path":"src/models/task_vectors.py","file_url":"https://github.com/AntoAndGar/task_singular_vectors/blob/HEAD/src/models/task_vectors.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":"b255d4dccd3371a7"}},{"code_sha256_prefix":"137de145e64658d2","entry":"_TaskVector","repo":"iurada/talos-task-arithmetic","repo_kind":"listed","path":"nlp/task_vectors.py","file_url":"https://github.com/iurada/talos-task-arithmetic/blob/HEAD/nlp/task_vectors.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"137de145e64658d2"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}