{"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/fine-mixing-mitigating-backdoors-in-fine","title":"Fine-mixing: Mitigating Backdoors in Fine-tuned Language Models","arxiv_id":"2210.09545","date":"2022-10-18","proceeding":null,"authors":["Zhiyuan Zhang","Lingjuan Lyu","Xingjun Ma","Chenguang Wang","Xu sun"],"abstract":"Deep Neural Networks (DNNs) are known to be vulnerable to backdoor attacks. In Natural Language Processing (NLP), DNNs are often backdoored during the fine-tuning process of a large-scale Pre-trained Language Model (PLM) with poisoned samples. Although the clean weights of PLMs are readily available, existing methods have ignored this information in defending NLP models against backdoor attacks. In this work, we take the first step to exploit the pre-trained (unfine-tuned) weights to mitigate backdoors in fine-tuned language models. Specifically, we leverage the clean pre-trained weights via two complementary techniques: (1) a two-step Fine-mixing technique, which first mixes the backdoored weights (fine-tuned on poisoned data) with the pre-trained weights, then fine-tunes the mixed weights on a small subset of clean data; (2) an Embedding Purification (E-PUR) technique, which mitigates potential backdoors existing in the word embeddings. We compare Fine-mixing with typical backdoor mitigation methods on three single-sentence sentiment classification tasks and two sentence-pair classification tasks and show that it outperforms the baselines by a considerable margin in all scenarios. We also show that our E-PUR method can benefit existing mitigation methods. Our work establishes a simple but strong baseline defense for secure fine-tuned NLP models against backdoor attacks.","url_abs":"https://arxiv.org/abs/2210.09545v1","url_pdf":"https://arxiv.org/pdf/2210.09545v1.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":"fine-mixing-mitigating-backdoors-in-fine","repo_url":"https://github.com/huggingface/pytorch-transformers","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"sentence","task_name":"Sentence"},{"task_slug":"sentence-pair-classification","task_name":"Sentence-Pair Classification"},{"task_slug":"sentiment-analysis","task_name":"Sentiment Analysis"},{"task_slug":"sentiment-classification","task_name":"Sentiment Classification"},{"task_slug":"word-embeddings","task_name":"Word Embeddings"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/sentiment-analysis-on-sst-2-binary","task":"Sentiment Analysis","dataset":"SST-2 Binary classification","model":"Word+ES (Scratch)","rank_in_archive_order":87,"of":87,"metrics":{"Attack Success Rate":"100"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2210.09545","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2210.09545"}},"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/huggingface/pytorch-transformers","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"unverified":19},"by_repo_kind":{"official":{"samples":19,"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":19,"samples":[{"code_sha256_prefix":"6921551bf74e9179","entry":"apply_chunking_to_forward","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/pytorch_utils.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/pytorch_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":false,"mcp_get_code":{"code_sha256":"6921551bf74e9179"}},{"code_sha256_prefix":"96d11fb3d55a597b","entry":"convert_bigbird_pegasus","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/bigbird_pegasus/convert_bigbird_pegasus_tf_to_pytorch.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/bigbird_pegasus/convert_bigbird_pegasus_tf_to_pytorch.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":false,"mcp_get_code":{"code_sha256":"96d11fb3d55a597b"}},{"code_sha256_prefix":"5667539047103cbb","entry":"convert_checkpoint_to_pytorch","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/bert/convert_bert_token_dropping_original_tf2_checkpoint_to_pytorch.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/bert/convert_bert_token_dropping_original_tf2_checkpoint_to_pytorch.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":false,"mcp_get_code":{"code_sha256":"5667539047103cbb"}},{"code_sha256_prefix":"4d50cf32a98739b3","entry":"convert_old_keys_to_new_keys","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/aimv2/convert_aimv2_original_pytorch_to_hf.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/aimv2/convert_aimv2_original_pytorch_to_hf.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":false,"mcp_get_code":{"code_sha256":"4d50cf32a98739b3"}},{"code_sha256_prefix":"4855bdca41688f99","entry":"convert_state_dict","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/audio_spectrogram_transformer/convert_audio_spectrogram_transformer_original_to_pytorch.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/audio_spectrogram_transformer/convert_audio_spectrogram_transformer_original_to_pytorch.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":false,"mcp_get_code":{"code_sha256":"4855bdca41688f99"}},{"code_sha256_prefix":"c968c3df370ea581","entry":"create_rename_keys","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/beit/convert_beit_unilm_to_pytorch.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/beit/convert_beit_unilm_to_pytorch.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":false,"mcp_get_code":{"code_sha256":"c968c3df370ea581"}},{"code_sha256_prefix":"07a6bd7d13811e1c","entry":"get_audio_spectrogram_transformer_config","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/audio_spectrogram_transformer/convert_audio_spectrogram_transformer_original_to_pytorch.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/audio_spectrogram_transformer/convert_audio_spectrogram_transformer_original_to_pytorch.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":false,"mcp_get_code":{"code_sha256":"07a6bd7d13811e1c"}},{"code_sha256_prefix":"02e54c96807ac2e3","entry":"get_tf_weights_as_numpy","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/bigbird_pegasus/convert_bigbird_pegasus_tf_to_pytorch.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/bigbird_pegasus/convert_bigbird_pegasus_tf_to_pytorch.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":false,"mcp_get_code":{"code_sha256":"02e54c96807ac2e3"}},{"code_sha256_prefix":"90fd642869f21de7","entry":"load_original_state_dict","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/aimv2/convert_aimv2_original_pytorch_to_hf.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/aimv2/convert_aimv2_original_pytorch_to_hf.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":false,"mcp_get_code":{"code_sha256":"90fd642869f21de7"}},{"code_sha256_prefix":"1a208abd5c3cf8fe","entry":"load_tf2_weights_in_bert","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/bert/convert_bert_original_tf2_checkpoint_to_pytorch.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/bert/convert_bert_original_tf2_checkpoint_to_pytorch.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":false,"mcp_get_code":{"code_sha256":"1a208abd5c3cf8fe"}},{"code_sha256_prefix":"feaa062c40209eea","entry":"load_tf_weights_in_big_bird","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/big_bird/convert_bigbird_original_tf_checkpoint_to_pytorch.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/big_bird/convert_bigbird_original_tf_checkpoint_to_pytorch.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":false,"mcp_get_code":{"code_sha256":"feaa062c40209eea"}},{"code_sha256_prefix":"5ef841f72417ff20","entry":"load_xsum_checkpoint","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/bart/convert_bart_original_pytorch_checkpoint_to_pytorch.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/bart/convert_bart_original_pytorch_checkpoint_to_pytorch.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":false,"mcp_get_code":{"code_sha256":"5ef841f72417ff20"}},{"code_sha256_prefix":"5301174099bfa9fb","entry":"make_linear_from_emb","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/bart/convert_bart_original_pytorch_checkpoint_to_pytorch.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/bart/convert_bart_original_pytorch_checkpoint_to_pytorch.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":false,"mcp_get_code":{"code_sha256":"5301174099bfa9fb"}},{"code_sha256_prefix":"24ece331635f4b38","entry":"prune_linear_layer","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/pytorch_utils.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/pytorch_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":false,"mcp_get_code":{"code_sha256":"24ece331635f4b38"}},{"code_sha256_prefix":"9aeec6efae4fb215","entry":"read_field","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/modeling_gguf_pytorch_utils.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/modeling_gguf_pytorch_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":false,"mcp_get_code":{"code_sha256":"9aeec6efae4fb215"}},{"code_sha256_prefix":"a34730fcf1a8bed8","entry":"rename_key","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/audio_spectrogram_transformer/convert_audio_spectrogram_transformer_original_to_pytorch.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/audio_spectrogram_transformer/convert_audio_spectrogram_transformer_original_to_pytorch.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":false,"mcp_get_code":{"code_sha256":"a34730fcf1a8bed8"}},{"code_sha256_prefix":"c4cd25451273cf0a","entry":"rename_state_dict_key","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/bigbird_pegasus/convert_bigbird_pegasus_tf_to_pytorch.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/bigbird_pegasus/convert_bigbird_pegasus_tf_to_pytorch.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":false,"mcp_get_code":{"code_sha256":"c4cd25451273cf0a"}},{"code_sha256_prefix":"be3bebdd7de293b6","entry":"softmax_backward_data","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/pytorch_utils.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/pytorch_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":false,"mcp_get_code":{"code_sha256":"be3bebdd7de293b6"}},{"code_sha256_prefix":"71fbe82c279aa0ed","entry":"split_qkv_tensor","repo":"huggingface/pytorch-transformers","repo_kind":"official","path":"src/transformers/models/aimv2/convert_aimv2_original_pytorch_to_hf.py","file_url":"https://github.com/huggingface/pytorch-transformers/blob/HEAD/src/transformers/models/aimv2/convert_aimv2_original_pytorch_to_hf.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":false,"mcp_get_code":{"code_sha256":"71fbe82c279aa0ed"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}