{"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/safe-pruning-lora-robust-distance-guided","title":"Safe Pruning LoRA: Robust Distance-Guided Pruning for Safety Alignment in Adaptation of LLMs","arxiv_id":"2506.18931","date":"2025-06-21","proceeding":null,"authors":["Shuang Ao","Yi Dong","Jinwei Hu","Sarvapali Ramchurn"],"abstract":"Fine-tuning Large Language Models (LLMs) with Low-Rank Adaptation (LoRA) enhances adaptability while reducing computational costs. However, fine-tuning can compromise safety alignment, even with benign data, increasing susceptibility to harmful outputs. Existing safety alignment methods struggle to capture complex parameter shifts, leading to suboptimal safety-utility trade-offs. To address this issue, we propose Safe Pruning LoRA (SPLoRA), a novel pruning-based approach that selectively removes LoRA layers that weaken safety alignment, improving safety while preserving performance. At its core, we introduce Empirical-DIEM (E-DIEM), a dimension-insensitive similarity metric that effectively detects safety misalignment in LoRA-adapted models. We conduct extensive experiments on LLMs fine-tuned with mixed of benign and malicious data, and purely benign datasets, evaluating SPLoRA across utility, safety, and reliability metrics. Results demonstrate that SPLoRA outperforms state-of-the-art safety alignment techniques, significantly reducing safety risks while maintaining or improving model performance and reliability. Additionally, SPLoRA reduces inference overhead, making it a scalable and efficient solution for deploying safer and more reliable LLMs. The code is available at https://github.com/AoShuang92/SPLoRA.","url_abs":"https://arxiv.org/abs/2506.18931v1","url_pdf":"https://arxiv.org/pdf/2506.18931v1.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":"safe-pruning-lora-robust-distance-guided","repo_url":"https://github.com/aoshuang92/splora","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"safety-alignment","task_name":"Safety Alignment"}],"methods":[{"method_slug":"pruning","method_name":"Pruning"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2506.18931","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2506.18931"}},"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/aoshuang92/splora","reach":{"status":"ok"}}],"summary":{"unverified":8},"by_repo_kind":{"official":{"samples":8,"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":8,"samples":[{"code_sha256_prefix":"3053998047069bec","entry":"collate_fn","repo":"aoshuang92/splora","repo_kind":"official","path":"llama2_alpaca_pd_lora.py","file_url":"https://github.com/aoshuang92/splora/blob/HEAD/llama2_alpaca_pd_lora.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":"3053998047069bec"}},{"code_sha256_prefix":"5d36e80b7dd32b6d","entry":"compute_diem","repo":"aoshuang92/splora","repo_kind":"official","path":"similarity.py","file_url":"https://github.com/aoshuang92/splora/blob/HEAD/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":"5d36e80b7dd32b6d"}},{"code_sha256_prefix":"b1c7b2c1236b08a7","entry":"mean_std_entropy","repo":"aoshuang92/splora","repo_kind":"official","path":"similarity.py","file_url":"https://github.com/aoshuang92/splora/blob/HEAD/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":"b1c7b2c1236b08a7"}},{"code_sha256_prefix":"4b44199efa36761a","entry":"median_absolute_deviation","repo":"aoshuang92/splora","repo_kind":"official","path":"similarity.py","file_url":"https://github.com/aoshuang92/splora/blob/HEAD/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":"4b44199efa36761a"}},{"code_sha256_prefix":"6caafdd232227d6c","entry":"preprocess_data","repo":"aoshuang92/splora","repo_kind":"official","path":"llama2_alpaca_pd_lora.py","file_url":"https://github.com/aoshuang92/splora/blob/HEAD/llama2_alpaca_pd_lora.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":"6caafdd232227d6c"}},{"code_sha256_prefix":"c232d8c347b3b6fa","entry":"preprocess_data","repo":"aoshuang92/splora","repo_kind":"official","path":"llama2_diagsum_pd_lora.py","file_url":"https://github.com/aoshuang92/splora/blob/HEAD/llama2_diagsum_pd_lora.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":"c232d8c347b3b6fa"}},{"code_sha256_prefix":"d9e73be65126b7ca","entry":"save_best_model","repo":"aoshuang92/splora","repo_kind":"official","path":"llama2_alpaca_pd_lora.py","file_url":"https://github.com/aoshuang92/splora/blob/HEAD/llama2_alpaca_pd_lora.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":"d9e73be65126b7ca"}},{"code_sha256_prefix":"e84c7197f998fc48","entry":"save_best_model","repo":"aoshuang92/splora","repo_kind":"official","path":"llama2_diagsum_pd_lora.py","file_url":"https://github.com/aoshuang92/splora/blob/HEAD/llama2_diagsum_pd_lora.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":"e84c7197f998fc48"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}