[Paper Review] Detecting Language Model Attacks with Perplexity
The paper shows that GPT-2 perplexity alone poorly detects adversarial prompts, but a two-feature classifier using perplexity and token length (via LightGBM) effectively identifies machine-generated adversarial suffix attacks; human-crafted jailbreaks remain challenging.
A novel hack involving Large Language Models (LLMs) has emerged, exploiting adversarial suffixes to deceive models into generating perilous responses. Such jailbreaks can trick LLMs into providing intricate instructions to a malicious user for creating explosives, orchestrating a bank heist, or facilitating the creation of offensive content. By evaluating the perplexity of queries with adversarial suffixes using an open-source LLM (GPT-2), we found that they have exceedingly high perplexity values. As we explored a broad range of regular (non-adversarial) prompt varieties, we concluded that false positives are a significant challenge for plain perplexity filtering. A Light-GBM trained on perplexity and token length resolved the false positives and correctly detected most adversarial attacks in the test set.
Motivation & Objective
- Evaluate whether perplexity can detect adversarial suffix attacks generated for LLM jailbreaking.
- Investigate distributions of perplexity for adversarial versus regular prompts.
- Develop a classifier using perplexity and token sequence length to improve detection over plain perplexity filtering.
- Assess limits when facing human-crafted jailbreak prompts.
Proposed method
- Compute perplexity of prompts using GPT-2 for both adversarial and non-adversarial prompts.
- Visualize perplexity vs. sequence length to assess class separation.
- Train a LightGBM classifier on features {perplexity, token length} with a 50/25/25 split (adv/non-adv) for train/validation/test and optimize F2 score.
- Use F-beta score with beta=2 to emphasize recall for threat detection goals.
- Compare two-feature classifier against a simple perplexity-threshold baseline.
- Report results separately for machine-generated versus human-crafted adversarial prompts.
Experimental results
Research questions
- RQ1Can perplexity distributions separate adversarial prompts from regular prompts, especially for machine-generated suffix attacks?
- RQ2Does including token length with perplexity improve detection performance over perplexity alone?
- RQ3Are human-crafted jailbreak prompts detectable with the proposed classifier?
- RQ4What is the detector performance under different evaluation splits and thresholds?
- RQ5What limitations arise when defenses face human-crafted jailbreaks vs. machine-generated attacks?
Key findings
- Machine-generated adversarial prompts have high perplexity values, with most above 1000, aiding separation from regular prompts.
- The two-feature classifier (perplexity + token length) achieves F2 scores of 95.6% on validation and 94.2% on test with human-crafted prompts included.
- Excluding human-crafted prompts raises F2 to 99.1% on test.
- A simple perplexity threshold (e.g., 400 or 1000) yields substantially lower F2 scores (83.3–87.2% vs. 94.2% with GBM).
- Human-crafted jailbreak prompts from Jaramillo (GPT-4 jailbreaks) are not effectively detected by the approach, indicating limitations for non-machine-generated attacks.
- Plain perplexity filtering suffers from notable false positives and negatives due to overlap with regular prompts in perplexity space.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.