{"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/harmful-fine-tuning-attacks-and-defenses-for","title":"Harmful Fine-tuning Attacks and Defenses for Large Language Models: A Survey","arxiv_id":"2409.18169","date":"2024-09-26","proceeding":null,"authors":["Tiansheng Huang","Sihao Hu","Fatih Ilhan","Selim Furkan Tekin","Ling Liu"],"abstract":"Recent research demonstrates that the nascent fine-tuning-as-a-service business model exposes serious safety concerns -- fine-tuning over a few harmful data uploaded by the users can compromise the safety alignment of the model. The attack, known as harmful fine-tuning attack, has raised a broad research interest among the community. However, as the attack is still new, \\textbf{we observe that there are general misunderstandings within the research community.} To clear up concern, this paper provide a comprehensive overview to three aspects of harmful fine-tuning: attacks setting, defense design and evaluation methodology. Specifically, we first present the threat model of the problem, and introduce the harmful fine-tuning attack and its variants. Then we systematically survey the existing literature on attacks/defenses/mechanical analysis of the problem. Finally, we introduce the evaluation methodology and outline future research directions that might contribute to the development of the field. Additionally, we present a list of questions of interest, which might be useful to refer to when reviewers in the peer review process question the realism of the experiment/attack/defense setting. A curated list of relevant papers is maintained and made accessible at: https://github.com/git-disl/awesome_LLM-harmful-fine-tuning-papers.","url_abs":"https://arxiv.org/abs/2409.18169v5","url_pdf":"https://arxiv.org/pdf/2409.18169v5.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":"harmful-fine-tuning-attacks-and-defenses-for","repo_url":"https://github.com/git-disl/awesome_llm-harmful-fine-tuning-papers","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok"}},{"paper_slug":"harmful-fine-tuning-attacks-and-defenses-for","repo_url":"https://github.com/git-disl/booster","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"safety-alignment","task_name":"Safety Alignment"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2409.18169","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2409.18169"}},"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/git-disl/booster","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/git-disl/awesome_llm-harmful-fine-tuning-papers","reach":{"status":"ok"}}],"summary":{"ran_honours":1,"ran":2,"ran_draft_wrong":3,"unverified":3},"by_repo_kind":{"listed":{"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":"175778f00233af46","entry":"adapt_dimension_b2a","repo":"git-disl/booster","repo_kind":"listed","path":"loss_func/repnoise_loss.py","file_url":"https://github.com/git-disl/booster/blob/HEAD/loss_func/repnoise_loss.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"175778f00233af46"}},{"code_sha256_prefix":"1e9e4d30c8f0cc73","entry":"coherence_check","repo":"git-disl/booster","repo_kind":"listed","path":"poison/evaluation/eval_sentiment.py","file_url":"https://github.com/git-disl/booster/blob/HEAD/poison/evaluation/eval_sentiment.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":"1e9e4d30c8f0cc73"}},{"code_sha256_prefix":"c9b7e712eaf8afe1","entry":"extract_answer_number","repo":"git-disl/booster","repo_kind":"listed","path":"gsm8k/pred_eval.py","file_url":"https://github.com/git-disl/booster/blob/HEAD/gsm8k/pred_eval.py","link_basis":"first_harvest_node","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":"c9b7e712eaf8afe1"}},{"code_sha256_prefix":"d07d04439cd1d44f","entry":"jload","repo":"git-disl/booster","repo_kind":"listed","path":"utils.py","file_url":"https://github.com/git-disl/booster/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"d07d04439cd1d44f"}},{"code_sha256_prefix":"dbc0448520ee9257","entry":"masked_token_ce_loss","repo":"git-disl/booster","repo_kind":"listed","path":"loss_func/repnoise_loss.py","file_url":"https://github.com/git-disl/booster/blob/HEAD/loss_func/repnoise_loss.py","link_basis":"harvester_set","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":"dbc0448520ee9257"}},{"code_sha256_prefix":"c605efc9460b6c33","entry":"register_activation_hook","repo":"git-disl/booster","repo_kind":"listed","path":"loss_func/repnoise_loss.py","file_url":"https://github.com/git-disl/booster/blob/HEAD/loss_func/repnoise_loss.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c605efc9460b6c33"}},{"code_sha256_prefix":"5f4323e1e87dc83b","entry":"calculate_drift2first_embedding","repo":"git-disl/booster","repo_kind":"listed","path":"utils.py","file_url":"https://github.com/git-disl/booster/blob/HEAD/utils.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":"5f4323e1e87dc83b"}},{"code_sha256_prefix":"88c8a24923c625a1","entry":"get_leaf_modules_with_grad","repo":"git-disl/booster","repo_kind":"listed","path":"trainer.py","file_url":"https://github.com/git-disl/booster/blob/HEAD/trainer.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":"88c8a24923c625a1"}},{"code_sha256_prefix":"bda772180d04ada3","entry":"track_embedding","repo":"git-disl/booster","repo_kind":"listed","path":"utils.py","file_url":"https://github.com/git-disl/booster/blob/HEAD/utils.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":"bda772180d04ada3"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}