{"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/improved-techniques-for-optimization-based","title":"Improved Techniques for Optimization-Based Jailbreaking on Large Language Models","arxiv_id":"2405.21018","date":"2024-05-31","proceeding":null,"authors":["Xiaojun Jia","Tianyu Pang","Chao Du","Yihao Huang","Jindong Gu","Yang Liu","Xiaochun Cao","Min Lin"],"abstract":"Large language models (LLMs) are being rapidly developed, and a key component of their widespread deployment is their safety-related alignment. Many red-teaming efforts aim to jailbreak LLMs, where among these efforts, the Greedy Coordinate Gradient (GCG) attack's success has led to a growing interest in the study of optimization-based jailbreaking techniques. Although GCG is a significant milestone, its attacking efficiency remains unsatisfactory. In this paper, we present several improved (empirical) techniques for optimization-based jailbreaks like GCG. We first observe that the single target template of \"Sure\" largely limits the attacking performance of GCG; given this, we propose to apply diverse target templates containing harmful self-suggestion and/or guidance to mislead LLMs. Besides, from the optimization aspects, we propose an automatic multi-coordinate updating strategy in GCG (i.e., adaptively deciding how many tokens to replace in each step) to accelerate convergence, as well as tricks like easy-to-hard initialisation. Then, we combine these improved technologies to develop an efficient jailbreak method, dubbed I-GCG. In our experiments, we evaluate on a series of benchmarks (such as NeurIPS 2023 Red Teaming Track). The results demonstrate that our improved techniques can help GCG outperform state-of-the-art jailbreaking attacks and achieve nearly 100% attack success rate. The code is released at https://github.com/jiaxiaojunQAQ/I-GCG.","url_abs":"https://arxiv.org/abs/2405.21018v2","url_pdf":"https://arxiv.org/pdf/2405.21018v2.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":"improved-techniques-for-optimization-based","repo_url":"https://github.com/jiaxiaojunqaq/i-gcg","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"red-teaming","task_name":"Red Teaming"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2405.21018","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2405.21018"}},"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":"deterministic:regex_extraction","url":"https://github.com/jiaxiaojunQAQ/I-GCG","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jiaxiaojunqaq/i-gcg","reach":{"status":"ok"}}],"summary":{"ran_draft_wrong":2,"ran":1,"unverified":4},"by_repo_kind":{"official":{"samples":7,"ran":3,"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":7,"samples":[{"code_sha256_prefix":"3e43a8aedf0a2745","entry":"check_for_attack_success","repo":"jiaxiaojunQAQ/I-GCG","repo_kind":"official","path":"attack_llm_core_best_update_our_target.py","file_url":"https://github.com/jiaxiaojunQAQ/I-GCG/blob/HEAD/attack_llm_core_best_update_our_target.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3e43a8aedf0a2745"}},{"code_sha256_prefix":"6ad91f68f0c84d9c","entry":"generate","repo":"jiaxiaojunQAQ/I-GCG","repo_kind":"official","path":"attack_llm_core_best_update_our_target.py","file_url":"https://github.com/jiaxiaojunQAQ/I-GCG/blob/HEAD/attack_llm_core_best_update_our_target.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6ad91f68f0c84d9c"}},{"code_sha256_prefix":"9269f45bb368b489","entry":"get_filtered_cands","repo":"jiaxiaojunqaq/i-gcg","repo_kind":"official","path":"llm_attacks/minimal_gcg/opt_utils.py","file_url":"https://github.com/jiaxiaojunqaq/i-gcg/blob/HEAD/llm_attacks/minimal_gcg/opt_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9269f45bb368b489"}},{"code_sha256_prefix":"0bf2136a7171ae80","entry":"get_embedding_layer","repo":"jiaxiaojunqaq/i-gcg","repo_kind":"official","path":"llm_attacks/base/attack_manager.py","file_url":"https://github.com/jiaxiaojunqaq/i-gcg/blob/HEAD/llm_attacks/base/attack_manager.py","link_basis":"harvester_set","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":"0bf2136a7171ae80"}},{"code_sha256_prefix":"688aaeba506e3329","entry":"get_embedding_matrix","repo":"jiaxiaojunqaq/i-gcg","repo_kind":"official","path":"llm_attacks/base/attack_manager.py","file_url":"https://github.com/jiaxiaojunqaq/i-gcg/blob/HEAD/llm_attacks/base/attack_manager.py","link_basis":"harvester_set","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":"688aaeba506e3329"}},{"code_sha256_prefix":"f556dda0785f3c77","entry":"get_embeddings","repo":"jiaxiaojunqaq/i-gcg","repo_kind":"official","path":"llm_attacks/base/attack_manager.py","file_url":"https://github.com/jiaxiaojunqaq/i-gcg/blob/HEAD/llm_attacks/base/attack_manager.py","link_basis":"harvester_set","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":"f556dda0785f3c77"}},{"code_sha256_prefix":"94d7ddaf0169dbf1","entry":"sample_control","repo":"jiaxiaojunqaq/i-gcg","repo_kind":"official","path":"llm_attacks/minimal_gcg/opt_utils.py","file_url":"https://github.com/jiaxiaojunqaq/i-gcg/blob/HEAD/llm_attacks/minimal_gcg/opt_utils.py","link_basis":"harvester_set","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":"94d7ddaf0169dbf1"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}