{"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/train-with-perturbation-infer-after-merging-a","title":"Train with Perturbation, Infer after Merging: A Two-Stage Framework for Continual Learning","arxiv_id":"2505.22389","date":"2025-05-28","proceeding":null,"authors":["Haomiao Qiu","Miao Zhang","Ziyue Qiao","Liqiang Nie"],"abstract":"Continual Learning (CL) aims to enable models to continuously acquire new knowledge from a sequence of tasks with avoiding the forgetting of learned information. However, existing CL methods only rely on the parameters of the most recent task for inference, which makes them susceptible to catastrophic forgetting. Inspired by the recent success of model merging techniques, we propose \\textbf{Perturb-and-Merge (P\\&M)}, a novel continual learning framework that integrates model merging into the CL paradigm to mitigate forgetting. Specifically, after training on each task, P\\&M constructs a new model by forming a convex combination of the previous model and the newly trained task-specific model. Through theoretical analysis, we minimize the total loss increase across all tasks and derive an analytical solution for the optimal merging coefficient. To further improve the performance of the merged model, we observe that the degradation introduced during merging can be alleviated by a regularization term composed of the task vector and the Hessian matrix of the loss function. Interestingly, we show that this term can be efficiently approximated using second-order symmetric finite differences, and a stochastic perturbation strategy along the task vector direction is accordingly devised which incurs no additional forward or backward passes while providing an effective approximation of the regularization term. Finally, we combine P\\&M with LoRA, a parameter-efficient fine-tuning method, to reduce memory overhead. Our proposed approach achieves state-of-the-art performance on several continual learning benchmark datasets.","url_abs":"https://arxiv.org/abs/2505.22389v2","url_pdf":"https://arxiv.org/pdf/2505.22389v2.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":[],"tasks":[{"task_slug":"continual-learning","task_name":"Continual Learning"},{"task_slug":"parameter-efficient-fine-tuning","task_name":"parameter-efficient fine-tuning"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2505.22389","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2505.22389"}},"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":"deterministic:regex_extraction","url":"https://github.com/qhmiao/P-M-for-Continual-Learning","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran":6,"unverified":3},"by_repo_kind":{"found_in_text":{"samples":9,"ran":6,"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":"971c46b0aa73eb28","entry":"calc_accuracy","repo":"qhmiao/P-M-for-Continual-Learning","repo_kind":"found_in_text","path":"utils/misc.py","file_url":"https://github.com/qhmiao/P-M-for-Continual-Learning/blob/HEAD/utils/misc.py","link_basis":"harvester_set","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":"971c46b0aa73eb28"}},{"code_sha256_prefix":"d06fe57a613a4c54","entry":"format_duration","repo":"qhmiao/P-M-for-Continual-Learning","repo_kind":"found_in_text","path":"utils/misc.py","file_url":"https://github.com/qhmiao/P-M-for-Continual-Learning/blob/HEAD/utils/misc.py","link_basis":"harvester_set","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":"d06fe57a613a4c54"}},{"code_sha256_prefix":"398c127f958b7a62","entry":"get_init_weights_vit","repo":"qhmiao/P-M-for-Continual-Learning","repo_kind":"found_in_text","path":"utils/vit_builder.py","file_url":"https://github.com/qhmiao/P-M-for-Continual-Learning/blob/HEAD/utils/vit_builder.py","link_basis":"harvester_set","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":"398c127f958b7a62"}},{"code_sha256_prefix":"660073ae6862ac6e","entry":"lora_state_dict","repo":"qhmiao/P-M-for-Continual-Learning","repo_kind":"found_in_text","path":"lora/utils.py","file_url":"https://github.com/qhmiao/P-M-for-Continual-Learning/blob/HEAD/lora/utils.py","link_basis":"harvester_set","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":"660073ae6862ac6e"}},{"code_sha256_prefix":"aba59faf86f45da9","entry":"resize_pos_embed","repo":"qhmiao/P-M-for-Continual-Learning","repo_kind":"found_in_text","path":"utils/vit_builder.py","file_url":"https://github.com/qhmiao/P-M-for-Continual-Learning/blob/HEAD/utils/vit_builder.py","link_basis":"harvester_set","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":"aba59faf86f45da9"}},{"code_sha256_prefix":"29848dd47d2443ef","entry":"str2bool","repo":"qhmiao/P-M-for-Continual-Learning","repo_kind":"found_in_text","path":"utils/misc.py","file_url":"https://github.com/qhmiao/P-M-for-Continual-Learning/blob/HEAD/utils/misc.py","link_basis":"harvester_set","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":"29848dd47d2443ef"}},{"code_sha256_prefix":"35a10325e8443f2e","entry":"define_dataset","repo":"qhmiao/P-M-for-Continual-Learning","repo_kind":"found_in_text","path":"utils/dataset_builder.py","file_url":"https://github.com/qhmiao/P-M-for-Continual-Learning/blob/HEAD/utils/dataset_builder.py","link_basis":"harvester_set","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":"35a10325e8443f2e"}},{"code_sha256_prefix":"5df638207a6149a9","entry":"get_lora_parameters","repo":"qhmiao/P-M-for-Continual-Learning","repo_kind":"found_in_text","path":"lora/utils.py","file_url":"https://github.com/qhmiao/P-M-for-Continual-Learning/blob/HEAD/lora/utils.py","link_basis":"harvester_set","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":"5df638207a6149a9"}},{"code_sha256_prefix":"e39f18623c2d033c","entry":"set_param","repo":"qhmiao/P-M-for-Continual-Learning","repo_kind":"found_in_text","path":"lora/layers.py","file_url":"https://github.com/qhmiao/P-M-for-Continual-Learning/blob/HEAD/lora/layers.py","link_basis":"harvester_set","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":"e39f18623c2d033c"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}