Certifying LLM Safety against Adversarial Prompting
By Aounon Kumar, Chirag Agarwal, Suraj Srinivas, Aaron J. Li, Soheil Feizi, Himabindu Lakkaraju. arXiv.org, 2023
333 citations recorded by the source corpus.
Large language models (LLMs) are vulnerable to adversarial attacks that add malicious tokens to an input prompt to bypass the safety guardrails of an LLM and cause it to produce harmful content. In this work, we introduce erase-and-check, the first framework for defending against adversarial prompts with certifiable safety guarantees. Given a prompt, our procedure erases tokens individually and inspects the resulting subsequences using a safety filter. Our safety certificate guarantees that harmful prompts are not mislabeled as safe due to an adversarial attack up to a certain size. We implement the safety filter in two ways, using Llama 2 and DistilBERT, and compare the performance of erase-and-check for the two cases. We defend against three attack modes: i) adversarial suffix, where an adversarial sequence is appended at the end of a harmful prompt; ii) adversarial insertion, where the adversarial sequence is inserted anywhere in the middle of the prompt; and iii) adversarial infusion, where adversarial tokens are inserted at arbitrary positions in the prompt, not necessarily as a contiguous block. Our experimental results demonstrate that this procedure can obtain strong certified safety guarantees on harmful prompts while maintaining good empirical performance on safe prompts. Additionally, we propose three efficient empirical defenses: i) RandEC, a randomized subsampling version of erase-and-check; ii) GreedyEC, which greedily erases tokens that maximize the softmax score of the harmful class; and iii) GradEC, which uses gradient information to optimize tokens to erase. We demonstrate their effectiveness against adversarial prompts generated by the Greedy Coordinate Gradient (GCG) attack algorithm. The code for our experiments is available at https://github.com/aounon/certified-llm-safety.
Subfields: Artificial Intelligence
View Paper: https://www.semanticscholar.org/paper/1ab91d6ac7afc1a0121487a9089fa70edc1634d4
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Artificial Intelligence
- Francesco Croce
- Maksym Andriushchenko
- Nicolas Flammarion
- Vikash Sehwag
- Edoardo Debenedetti
- George Pappas
- Zeming Wei
- Eric Wong
Citations in the corpus
- JailbreakBench: An Open Robustness Benchmark for Jailbreaking Large Language Models (2024, methodology): “Currently, we include five baseline defenses: (1) SmoothLLM (Robey et al., 2023), (2) perplexity filtering (Jain et al., 2023), and (3) Erase-and-Check (Kumar et al., 2023), (4) synonym substitution, (5) removing non-dictionary items.”
- Large language models empowered agent-based modeling and simulation: a survey and perspectives (2023, neutral): “For example, researchers propose to certify LLM safety with an erase-and-check fi lter that detects adversarial prompts (Kumar et al., 2023).”
- How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMs (2024, positive): “To evaluate the results’ harmfulness before and after perturbation, we follow their evaluation setting and inspect a keyword set from Zou et al. (2023) during output inspection.”
- SmoothLLM: Defending Large Language Models Against Jailbreaking Attacks (2023, neutral): “[27] Aounon Kumar, Chirag Agarwal, Suraj Srinivas, Soheil Feizi, and Hima Lakkaraju.”
- Jailbreak and Guard Aligned Language Models With Only Few In-Context Demonstrations (2023, positive): “, 2023] and erase-and-check [Kumar et al., 2023], further showing its practicality of being deployed as a defense method for LLMs.”
- Security and Privacy Challenges of Large Language Models: A Survey (2024, neutral): “A framework has been proposed named VistaGPT to deal with the problems caused by information barriers from heterogeneity at both system and module levels in a wide range of heterogeneous vehicle automation systems [202].”
- AgentPoison: Red-teaming LLM Agents via Poisoning Memory or Knowledge Bases (2024, neutral): “We study two types of defense: Perplexity Filter [2] and Query Rephrasing [15] (here we rephrase the whole query which is different from Table 3) which are often used to prevent LLMs from injection attack.”
- Jailbreaking LLMs' Safeguard with Universal Magic Words for Text Embedding Models (2025, unknown): “…previous in-structions” (Perez & Ribeiro, 2022); 3) Perturbing the user’s prompt into multiple versions before feeding it to the LLM to detect harmful requests (Kumar et al., 2023; Robey et al., 2023), which is costly; 4) Classifying whether the prompt is harmful with a model (Kim et al., 2023).”