Do you really follow me? Adversarial Instructions for Evaluating the Robustness of Large Language Models

Zekun Li, Baolin Peng, Pengcheng He, Xifeng Yan · OpenReview

Abstract

Large Language Models (LLMs) have shown remarkable proficiency in following instructions, making them valuable in customer-facing applications. However, their impressive capabilities also raise concerns about the amplification of risks posed by adversarial instructions, which can be injected into the model input by third-party attackers to manipulate LLMs' original instructions and prompt unintended actions and content. Therefore, it is crucial to understand LLMs' ability to accurately discern which instructions to follow to ensure their safe deployment in real-world scenarios. In this paper, we propose a pioneering benchmark for automatically evaluating the robustness of LLMs against adversarial instructions. The objective of this benchmark is to quantify the extent to which LLMs are influenced by injected adversarial instructions and assess their ability to differentiate between these adversarial instructions and original user instructions. Through experiments conducted with state-of-the-art instruction-following LLMs, we uncover significant limitations in their robustness against adversarial instruction attacks. Furthermore, our findings indicate that prevalent instruction-tuned models are prone to being overfitted to follow any instruction phrase in the prompt without truly understanding which instructions should be followed. This highlights the need to address the challenge of training models to comprehend prompts instead of merely following instruction phrases and completing the text.

Introduction: The Threat of Indirect Prompt Injection

As Large Language Models (LLMs) are increasingly integrated with external tools like web search and plugins, they face a new threat: indirect prompt injection. The very feature that makes LLMs useful—their ability to follow natural language instructions—is also a significant security flaw. When an LLM is used in an "open-book" setting (like Bing Chat or a Retrieval-Augmented Generation (RAG) system), it retrieves external text to answer a user's query.

An attacker can embed "adversarial instructions" into that external text. If the LLM cannot distinguish between the user's legitimate instruction and the attacker's injected instruction, it might perform unintended actions, such as leaking private data or spreading misinformation.

Illustration of an indirect prompt injection attack where a model follows a third-party instruction embedded in search results.

Methodology

The researchers developed a controlled evaluation framework based on Open-Book Question Answering (QA).

  1. The Setup: A model is given a user question ($q$) and a context paragraph ($c$) retrieved from the web.
  2. The Attack: The researchers inject a second, different question ($q'$) into the context. This injected question is "benign" (it asks for information present in the text) but competes with the original user query.
  3. The Defense: They employed a standard "system prompt" defense, explicitly telling the model to ignore any instructions found within the XML-tagged context.
  4. The Metrics:
    • Performance Drop Rate (PDR): Measures how much the model's accuracy on the original question decreases when an attack is present.
  5. Instruction Discrimination Rate (IDR): Measures the model's ability to prioritize the original instruction over the injected one.

Datasets

The benchmark utilizes four representative QA datasets: NaturalQuestions, TriviaQA, SQuAD, and HotpotQA. For datasets that originally only had one question per paragraph, the authors used GPT-4 to generate high-quality, distinct adversarial question-answer pairs based on the same context.

Key Insights and Results

The study revealed several critical vulnerabilities in current LLMs:

  • Proprietary vs. Open-Source: GPT-3.5-Turbo and Claude-2 were significantly more robust than open-source counterparts.
  • The "Recency Bias" Trap: Many models, particularly smaller open-source ones, tend to follow the instruction that appears last in the prompt, effectively forgetting the user's original goal.
  • Performance ≠ Robustness: A model's ability to follow instructions does not correlate with its robustness. For example, Zephyr-7B performs well on general tasks but is highly vulnerable to prompt injection.
  • Vulnerability to Position: Injecting the adversarial instruction at the end of the context was the most effective attack across almost all models.
Instruction Discrimination Rate (IDR) across different models on the SQuAD dataset, highlighting the gap in robustness.

Conclusion

The findings indicate that prevalent instruction-tuned models are prone to being overfitted to follow any instruction phrase in the prompt without truly understanding which instructions should be followed. This highlights the need to address the challenge of training models to comprehend prompts instead of merely following instruction phrases and completing the text. Future research should focus on improving LLMs' "discernment"—the ability to evaluate the appropriateness of an instruction based on its source and context within the prompt.

Summary updated

BibTeX
@misc{li2023do,
  author = {Zekun Li and Baolin Peng and Pengcheng He and Xifeng Yan},
  title = {{Do you really follow me? Adversarial Instructions for Evaluating the Robustness of Large Language Models}},
  year = {2023},
  eprint = {2308.10819},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.10819},
}
Figure