{"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/achieving-model-robustness-through-discrete","title":"Achieving Model Robustness through Discrete Adversarial Training","arxiv_id":"2104.05062","date":"2021-04-11","proceeding":"EMNLP 2021 11","authors":["Maor Ivgi","Jonathan Berant"],"abstract":"Discrete adversarial attacks are symbolic perturbations to a language input that preserve the output label but lead to a prediction error. While such attacks have been extensively explored for the purpose of evaluating model robustness, their utility for improving robustness has been limited to offline augmentation only. Concretely, given a trained model, attacks are used to generate perturbed (adversarial) examples, and the model is re-trained exactly once. In this work, we address this gap and leverage discrete attacks for online augmentation, where adversarial examples are generated at every training step, adapting to the changing nature of the model. We propose (i) a new discrete attack, based on best-first search, and (ii) random sampling attacks that unlike prior work are not based on expensive search-based procedures. Surprisingly, we find that random sampling leads to impressive gains in robustness, outperforming the commonly-used offline augmentation, while leading to a speedup at training time of ~10x. Furthermore, online augmentation with search-based attacks justifies the higher training cost, significantly improving robustness on three datasets. Last, we show that our new attack substantially improves robustness compared to prior methods.","url_abs":"https://arxiv.org/abs/2104.05062v2","url_pdf":"https://arxiv.org/pdf/2104.05062v2.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":"achieving-model-robustness-through-discrete","repo_url":"https://github.com/Mivg/robust_transformers","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"model","task_name":"model"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2104.05062","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2104.05062"}},"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/Mivg/robust_transformers","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"deterministic:regex_extraction","url":"https://github.com/nesl/nlp_adversarial_","reach":{"status":"gone","observed_at":"2026-09-17","how":"tree_404+repo_404"}}],"summary":{"unverified":5},"by_repo_kind":{"official":{"samples":5,"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":0,"samples":[{"code_sha256_prefix":"40b7f6585036a3c3","entry":"batch_to_inputs","repo":"Mivg/robust_transformers","repo_kind":"official","path":"hf_transformers/adv_utils.py","file_url":"https://github.com/Mivg/robust_transformers/blob/HEAD/hf_transformers/adv_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"40b7f6585036a3c3"}},{"code_sha256_prefix":"926691fbb4b9dd98","entry":"estimate_dataset_attack_space","repo":"Mivg/robust_transformers","repo_kind":"official","path":"attacks/glue_datasets.py","file_url":"https://github.com/Mivg/robust_transformers/blob/HEAD/attacks/glue_datasets.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"926691fbb4b9dd98"}},{"code_sha256_prefix":"526c577a8df3eb64","entry":"get_dataset_dir_name","repo":"Mivg/robust_transformers","repo_kind":"official","path":"attacks/glue_datasets.py","file_url":"https://github.com/Mivg/robust_transformers/blob/HEAD/attacks/glue_datasets.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"526c577a8df3eb64"}},{"code_sha256_prefix":"dc2d4b2605f2082b","entry":"merge_outs","repo":"Mivg/robust_transformers","repo_kind":"official","path":"attacks/analyze_robustness.py","file_url":"https://github.com/Mivg/robust_transformers/blob/HEAD/attacks/analyze_robustness.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"dc2d4b2605f2082b"}},{"code_sha256_prefix":"03e914602748c399","entry":"prep_text","repo":"Mivg/robust_transformers","repo_kind":"official","path":"hf_transformers/adv_utils.py","file_url":"https://github.com/Mivg/robust_transformers/blob/HEAD/hf_transformers/adv_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"03e914602748c399"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}