{"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/arxiv-2603-10243","title":"GR-SAP: Generative Replay for Safety Alignment Preservation during Fine-Tuning","arxiv_id":"2603.10243","date":"2026-03-10","proceeding":null,"authors":["Zhouxiang Fang","Jiawei Zhou","Hanjie Chen"],"abstract":"Recent studies show that the safety alignment of large language models (LLMs) can be easily compromised even by seemingly non-adversarial fine-tuning. To preserve safety alignment during fine-tuning, a widely used strategy is to jointly optimize safety and task objectives by mixing in the original alignment data, which is typically inaccessible even for open-weight LLMs. Inspired by generative replay in continual learning, we propose Generative Replay for Safety Alignment Preservation (GR-SAP), a unified framework that synthesizes domain-specific alignment data from LLMs and integrate them during downstream adaption to preserve safety alignment. Theoretical and empirical analyses demonstrate this synthetic data serves as a reliable proxy for the original alignment data. Experiments across various models and downstream tasks show that GR-SAP substantially mitigates fine-tuning-induced safety degradation while maintaining comparable downstream performance. Our code is available at https://github.com/chili-lab/gr-sap.","url_abs":"https://arxiv.org/abs/2603.10243","url_pdf":"https://arxiv.org/pdf/2603.10243","source":{"archive":null,"snapshot":"2025-07-28","note":"not in the Papers with Code archive (frozen at the snapshot)","row_kind":"graph","title_abstract_authors_date":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)"},"code_links":[],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2603.10243","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2603.10243"}},"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":[{"mentioned_in_github":null,"is_official":null,"provenance":"deterministic:regex_extraction","mentioned_in_paper":null,"url":"https://github.com/chili-lab/gr-sap","reach":null}],"summary":{"unverified":10},"by_repo_kind":{"found_in_text":{"samples":10,"ran":0,"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":10,"samples":[{"code_sha256_prefix":"194e1b3e495f6b12","entry":"calculate_ppl","repo":"chili-lab/gr-sap","repo_kind":"found_in_text","path":"postprocess.py","file_url":"https://github.com/chili-lab/gr-sap/blob/HEAD/postprocess.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":"194e1b3e495f6b12"}},{"code_sha256_prefix":"54a18fdeab73d347","entry":"extract_answer_gsm8k","repo":"chili-lab/gr-sap","repo_kind":"found_in_text","path":"score.py","file_url":"https://github.com/chili-lab/gr-sap/blob/HEAD/score.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":"54a18fdeab73d347"}},{"code_sha256_prefix":"976ad562cea3dcd7","entry":"extract_answer_math","repo":"chili-lab/gr-sap","repo_kind":"found_in_text","path":"score.py","file_url":"https://github.com/chili-lab/gr-sap/blob/HEAD/score.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":"976ad562cea3dcd7"}},{"code_sha256_prefix":"c4c540c2c11ce5ee","entry":"extract_number","repo":"chili-lab/gr-sap","repo_kind":"found_in_text","path":"score_dir.py","file_url":"https://github.com/chili-lab/gr-sap/blob/HEAD/score_dir.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":"c4c540c2c11ce5ee"}},{"code_sha256_prefix":"1125c62b455dbf10","entry":"extract_query_response","repo":"chili-lab/gr-sap","repo_kind":"found_in_text","path":"extract_tulu_subdatasets.py","file_url":"https://github.com/chili-lab/gr-sap/blob/HEAD/extract_tulu_subdatasets.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":"1125c62b455dbf10"}},{"code_sha256_prefix":"d3a28fb070d81244","entry":"generate_jailbreak","repo":"chili-lab/gr-sap","repo_kind":"found_in_text","path":"extract_data.py","file_url":"https://github.com/chili-lab/gr-sap/blob/HEAD/extract_data.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":"d3a28fb070d81244"}},{"code_sha256_prefix":"401960054aca94d6","entry":"parse_number","repo":"chili-lab/gr-sap","repo_kind":"found_in_text","path":"score.py","file_url":"https://github.com/chili-lab/gr-sap/blob/HEAD/score.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":"401960054aca94d6"}},{"code_sha256_prefix":"9327da954a51300d","entry":"process_source_tulu","repo":"chili-lab/gr-sap","repo_kind":"found_in_text","path":"measure_similarity.py","file_url":"https://github.com/chili-lab/gr-sap/blob/HEAD/measure_similarity.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":"9327da954a51300d"}},{"code_sha256_prefix":"8e0c3698e44c7a98","entry":"process_target","repo":"chili-lab/gr-sap","repo_kind":"found_in_text","path":"measure_similarity.py","file_url":"https://github.com/chili-lab/gr-sap/blob/HEAD/measure_similarity.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":"8e0c3698e44c7a98"}},{"code_sha256_prefix":"b583d8287631b258","entry":"split_messages","repo":"chili-lab/gr-sap","repo_kind":"found_in_text","path":"helper.py","file_url":"https://github.com/chili-lab/gr-sap/blob/HEAD/helper.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":"b583d8287631b258"}}]},"arxiv_metadata":{"licence":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)","fields":["title","abstract","authors","date"],"primary_category":"cs.CL","source":"arxiv_2026.jsonl"},"syntology_extracted_results":null}