{"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/jailbreaking-black-box-large-language-models","title":"Jailbreaking Black Box Large Language Models in Twenty Queries","arxiv_id":"2310.08419","date":"2023-10-12","proceeding":null,"authors":["Patrick Chao","Alexander Robey","Edgar Dobriban","Hamed Hassani","George J. Pappas","Eric Wong"],"abstract":"There is growing interest in ensuring that large language models (LLMs) align with human values. However, the alignment of such models is vulnerable to adversarial jailbreaks, which coax LLMs into overriding their safety guardrails. The identification of these vulnerabilities is therefore instrumental in understanding inherent weaknesses and preventing future misuse. To this end, we propose Prompt Automatic Iterative Refinement (PAIR), an algorithm that generates semantic jailbreaks with only black-box access to an LLM. PAIR -- which is inspired by social engineering attacks -- uses an attacker LLM to automatically generate jailbreaks for a separate targeted LLM without human intervention. In this way, the attacker LLM iteratively queries the target LLM to update and refine a candidate jailbreak. Empirically, PAIR often requires fewer than twenty queries to produce a jailbreak, which is orders of magnitude more efficient than existing algorithms. PAIR also achieves competitive jailbreaking success rates and transferability on open and closed-source LLMs, including GPT-3.5/4, Vicuna, and Gemini.","url_abs":"https://arxiv.org/abs/2310.08419v4","url_pdf":"https://arxiv.org/pdf/2310.08419v4.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":"jailbreaking-black-box-large-language-models","repo_url":"https://github.com/patrickrchao/jailbreakingllms","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":null}],"tasks":[],"methods":[{"method_slug":"align","method_name":"ALIGN"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"cosine-annealing","method_name":"Cosine Annealing"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"gpt-3","method_name":"GPT-3"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-cosine-annealing","method_name":"Linear Warmup With Cosine Annealing"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"weight-decay","method_name":"Weight Decay"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2310.08419","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2310.08419"}},"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/patrickrchao/jailbreakingllms","reach":null}],"summary":{"ran":1,"ran_draft_wrong":1,"unverified":5},"by_repo_kind":{"official":{"samples":7,"ran":2,"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":"76a39a9b877bdc26","entry":"LanguageModel","repo":"patrickrchao/jailbreakingllms","repo_kind":"official","path":"conversers.py","file_url":"https://github.com/patrickrchao/jailbreakingllms/blob/HEAD/conversers.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"76a39a9b877bdc26"}},{"code_sha256_prefix":"7f22816d570dc592","entry":"extract_json","repo":"patrickrchao/jailbreakingllms","repo_kind":"official","path":"conversers.py","file_url":"https://github.com/patrickrchao/jailbreakingllms/blob/HEAD/conversers.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7f22816d570dc592"}},{"code_sha256_prefix":"92d45a9a35db84e8","entry":"APILiteLLM","repo":"patrickrchao/jailbreakingllms","repo_kind":"official","path":"conversers.py","file_url":"https://github.com/patrickrchao/jailbreakingllms/blob/HEAD/conversers.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":"92d45a9a35db84e8"}},{"code_sha256_prefix":"2e41b0b101a3cd30","entry":"AttackLM","repo":"patrickrchao/jailbreakingllms","repo_kind":"official","path":"conversers.py","file_url":"https://github.com/patrickrchao/jailbreakingllms/blob/HEAD/conversers.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":"2e41b0b101a3cd30"}},{"code_sha256_prefix":"fb6adeafc3fa5612","entry":"Model","repo":"patrickrchao/jailbreakingllms","repo_kind":"official","path":"conversers.py","file_url":"https://github.com/patrickrchao/jailbreakingllms/blob/HEAD/conversers.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":"fb6adeafc3fa5612"}},{"code_sha256_prefix":"c87fc7d15c6dc917","entry":"get_api_key","repo":"patrickrchao/jailbreakingllms","repo_kind":"official","path":"conversers.py","file_url":"https://github.com/patrickrchao/jailbreakingllms/blob/HEAD/conversers.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":"c87fc7d15c6dc917"}},{"code_sha256_prefix":"74c3bf723f6005fd","entry":"load_indiv_model","repo":"patrickrchao/jailbreakingllms","repo_kind":"official","path":"conversers.py","file_url":"https://github.com/patrickrchao/jailbreakingllms/blob/HEAD/conversers.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":"74c3bf723f6005fd"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}