Eliciting Language Model Behaviors using Reverse Language Models

Jacob Pfau, Alex Infanger, Abhay Sheshadri, Ayush Panda, Julian Michael, Curtis HuebnerSoLaR @ NeurIPS 2023

TL;DR

This paper introduces "reverse language models" (RLMs) as a novel method for automatically discovering adversarial prompts that elicit undesirable behaviors (like toxic outputs) from large language models (LLMs). RLMs, trained on reversed token sequences, outperform existing methods like GCG in finding natural-sounding prompts that successfully trigger these behaviors, and these prompts are more transferable to other LLMs.

What Problem Does This Paper Address?

Despite significant advancements in training LLMs, they still exhibit problematic behaviors, particularly when presented with carefully crafted "worst-case" inputs. These inputs, often referred to as adversarial attacks or "jailbreaks," can cause LLMs to generate toxic, harmful, or nonsensical content. Existing automated red-teaming methods, while capable of finding these vulnerabilities, often produce grammatically awkward or unnatural prompts. The challenge is to develop methods that can discover these problematic inputs while maintaining natural language fluency, making the LLM robust to prompts that a human might realistically use.

Methods

The core innovation is the concept of a reverse language model (RLM). Instead of predicting the next token in a sequence (like standard LLMs), an RLM is trained to predict tokens in reverse order. This allows it to model the "reverse dynamics" of an LLM, essentially learning to generate prefixes that are likely to precede a given problematic suffix.

The authors propose using this RLM in a beam search process. They prompt the RLM with a target suffix and sample multiple potential prefixes. These sampled prefixes are then fed into the original "forwards" LLM to evaluate how likely they are to generate the target suffix. The prefix that maximizes this probability is selected as the adversarial prompt.

The paper also explores two direct methods for reversing LLM dynamics without training a separate RLM:

  1. Fixed Context Brute Force Reversal: This method uses Bayes' law and requires an exponential number of forward passes, making it computationally infeasible for practical use.
  2. Bayesian Reversal: This approach uses a prior distribution and updates it based on the observed suffix, allowing for sampling one token at a time. While more computationally tractable than brute force, it still involves significant computation.

The primary method discussed and evaluated is the trained RLM.

Datasets

  • The Pile: Used for training the reverse language model and for evaluating its performance in generating adversarial prompts.
  • RealToxicityPrompts: A dataset specifically designed for evaluating toxicity generation in LLMs, used for testing the effectiveness of the discovered prompts.
  • Synthetic Dataset: A custom dataset generated by the authors to create prefix-suffix pairs that are low-probability continuations for a given final token, designed to be challenging for adversarial attacks.

Key Insights and Ideas

  • Reverse Dynamics as a Tool for Elicitation: The core insight is that modeling the reverse dynamics of an LLM provides a powerful mechanism for discovering inputs that elicit specific behaviors. By learning to predict what comes before a problematic output, we can generate prompts that lead to that output.
  • Naturalness as a Side Constraint: The paper emphasizes the importance of natural language fluency in adversarial prompts. RLMs, by their nature of generating sequences, tend to produce more natural-sounding prefixes compared to methods that optimize solely for elicitation probability.
  • Transferability of Prompts: Prompts discovered using an RLM trained on one model (Pythia) were found to be more effective at eliciting similar behaviors from a different model (Llama 2) than prompts generated by the state-of-the-art GCG method. This suggests a more generalizable vulnerability detection.
  • RLM Training Efficiency: The authors found that training an RLM on reversed data achieved comparable training loss to a forwards model of the same size, indicating that learning these reverse dynamics is feasible.

Key Results

  • Outperforming GCG: The 160M parameter reverse LM consistently outperformed the state-of-the-art GCG method in eliciting toxic continuations from the Pythia-160m LM, achieving higher elicitation probabilities while maintaining lower prefix perplexity (i.e., more natural prefixes).
  • Improved Transferability: Prompts generated by the RLM transferred better to Llama 2, eliciting toxic responses more effectively than GCG-generated prompts.
  • Pareto Dominance: In terms of the trade-off between elicitation probability and prefix naturalness, the RLM Pareto-dominates GCG, meaning it achieves better results on both metrics simultaneously.
  • Computational Efficiency: While GCG takes significantly longer to converge, the RLM approach is more computationally efficient for achieving comparable or better results.

Limitations and Future Work

  • Computational Cost of Direct Reversal: The direct reversal methods (brute force and Bayesian) are computationally expensive, especially for longer prefixes, limiting their practical application compared to training a dedicated RLM.
  • Approximation in Bayesian Reversal: The Bayesian reversal method relies on approximations for certain probability terms, which might impact its effectiveness.
  • Fine-tuning for Chat Models: The paper focuses on base LLMs. Future work should explore adapting RLMs for chat-tuned models, which might require fine-tuning the RLM on reversed, model-generated data.
  • Combining Methods: Further research is needed to determine if combining forward decoding, reverse LM decoding, and gradient-based search can yield even better results.
  • Societal Impact and Safety: The authors acknowledge that methods for adversarial optimization can be used for jailbreaking chat LMs, potentially for malicious purposes. They recommend pre-deployment red-teaming using techniques like RLMs to mitigate these risks.

Summary updated

BibTeX
@inproceedings{pfau2023eliciting,
  author = {Jacob Pfau and Alex Infanger and Abhay Sheshadri and Ayush Panda and Julian Michael and Curtis Huebner},
  title = {{Eliciting Language Model Behaviors using Reverse Language Models}},
  booktitle = {SoLaR @ NeurIPS},
  year = {2023},
  url = {https://openreview.net/forum?id=m6xyTie61H},
}
Figure