{"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/twin-merging-dynamic-integration-of-modular","title":"Twin-Merging: Dynamic Integration of Modular Expertise in Model Merging","arxiv_id":"2406.15479","date":"2024-06-17","proceeding":null,"authors":["Zhenyi Lu","Chenghao Fan","Wei Wei","Xiaoye Qu","Dangyang Chen","Yu Cheng"],"abstract":"In the era of large language models, model merging is a promising way to combine multiple task-specific models into a single multitask model without extra training. However, two challenges remain: (a) interference between different models and (b) heterogeneous data during testing. Traditional model merging methods often show significant performance gaps compared to fine-tuned models due to these issues. Additionally, a one-size-fits-all model lacks flexibility for diverse test data, leading to performance degradation. We show that both shared and exclusive task-specific knowledge are crucial for merging performance, but directly merging exclusive knowledge hinders overall performance. In view of this, we propose Twin-Merging, a method that encompasses two principal stages: (1) modularizing knowledge into shared and exclusive components, with compression to reduce redundancy and enhance efficiency; (2) dynamically merging shared and task-specific knowledge based on the input. This approach narrows the performance gap between merged and fine-tuned models and improves adaptability to heterogeneous data. Extensive experiments on $20$ datasets for both language and vision tasks demonstrate the effectiveness of our method, showing an average improvement of $28.34\\%$ in absolute normalized score for discriminative tasks and even surpassing the fine-tuned upper bound on the generative tasks. Our implementation is available in \\url{https://github.com/LZY-the-boys/Twin-Merging}","url_abs":"https://arxiv.org/abs/2406.15479v2","url_pdf":"https://arxiv.org/pdf/2406.15479v2.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":"twin-merging-dynamic-integration-of-modular","repo_url":"https://github.com/LZY-the-boys/Twin-Merging","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2406.15479","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2406.15479"}},"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/LZY-the-boys/Twin-Merging","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":7,"unverified":4},"by_repo_kind":{"official":{"samples":11,"ran":7,"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":"68332c06437c45b3","entry":"args_inspector","repo":"LZY-the-boys/Twin-Merging","repo_kind":"official","path":"discriminative/utils.py","file_url":"https://github.com/LZY-the-boys/Twin-Merging/blob/HEAD/discriminative/utils.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"68332c06437c45b3"}},{"code_sha256_prefix":"f5f78d9bf8dfb1b1","entry":"bernoulli","repo":"LZY-the-boys/Twin-Merging","repo_kind":"official","path":"discriminative/sparsify.py","file_url":"https://github.com/LZY-the-boys/Twin-Merging/blob/HEAD/discriminative/sparsify.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f5f78d9bf8dfb1b1"}},{"code_sha256_prefix":"670b577dd9aa8aa8","entry":"deprecated","repo":"LZY-the-boys/Twin-Merging","repo_kind":"official","path":"discriminative/utils.py","file_url":"https://github.com/LZY-the-boys/Twin-Merging/blob/HEAD/discriminative/utils.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"670b577dd9aa8aa8"}},{"code_sha256_prefix":"32204061bb656051","entry":"from_yaml","repo":"LZY-the-boys/Twin-Merging","repo_kind":"official","path":"discriminative/utils.py","file_url":"https://github.com/LZY-the-boys/Twin-Merging/blob/HEAD/discriminative/utils.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"32204061bb656051"}},{"code_sha256_prefix":"9ceff24e89da3b6e","entry":"get_ori_datasets","repo":"LZY-the-boys/Twin-Merging","repo_kind":"official","path":"discriminative/router.py","file_url":"https://github.com/LZY-the-boys/Twin-Merging/blob/HEAD/discriminative/router.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9ceff24e89da3b6e"}},{"code_sha256_prefix":"b6e10ff5abcddad1","entry":"magnitude","repo":"LZY-the-boys/Twin-Merging","repo_kind":"official","path":"discriminative/sparsify.py","file_url":"https://github.com/LZY-the-boys/Twin-Merging/blob/HEAD/discriminative/sparsify.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b6e10ff5abcddad1"}},{"code_sha256_prefix":"5dfa439bd79443ac","entry":"svd","repo":"LZY-the-boys/Twin-Merging","repo_kind":"official","path":"discriminative/sparsify.py","file_url":"https://github.com/LZY-the-boys/Twin-Merging/blob/HEAD/discriminative/sparsify.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5dfa439bd79443ac"}},{"code_sha256_prefix":"5a42da8e258e5c0d","entry":"load_causallm","repo":"LZY-the-boys/Twin-Merging","repo_kind":"official","path":"generative/model.py","file_url":"https://github.com/LZY-the-boys/Twin-Merging/blob/HEAD/generative/model.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":"5a42da8e258e5c0d"}},{"code_sha256_prefix":"ebc5519f98dc7c94","entry":"load_classifier","repo":"LZY-the-boys/Twin-Merging","repo_kind":"official","path":"generative/model.py","file_url":"https://github.com/LZY-the-boys/Twin-Merging/blob/HEAD/generative/model.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":"ebc5519f98dc7c94"}},{"code_sha256_prefix":"b27d590fb18bf106","entry":"load_glue","repo":"LZY-the-boys/Twin-Merging","repo_kind":"official","path":"discriminative/router.py","file_url":"https://github.com/LZY-the-boys/Twin-Merging/blob/HEAD/discriminative/router.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":"b27d590fb18bf106"}},{"code_sha256_prefix":"8c91b2b57ae37256","entry":"load_seq2seqlm","repo":"LZY-the-boys/Twin-Merging","repo_kind":"official","path":"generative/model.py","file_url":"https://github.com/LZY-the-boys/Twin-Merging/blob/HEAD/generative/model.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":"8c91b2b57ae37256"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}