The Instruction Hierarchy: Training LLMs to Prioritize Privileged Instructions
The post argues that current LLMs are vulnerable to prompt injections and jailbreaks because they treat system prompts from application developers with the same priority as text from untrusted users and third parties. The authors propose an explicit instruction hierarchy that defines how models should act when instructions of different priorities conflict. They show that training GPT-3.5 to follow this hierarchy substantially improves robustness, including against attack types not seen during training, with minimal loss in standard capabilities. ## The Vulnerability: Flat Instruction Priority - Attacks such as prompt injections and jailbreaks work by overwriting a model's original instructions with adversarial prompts. - A core cause is that models give developer-written system prompts the same weight as user messages and third-party content. - Because of this, a malicious instruction embedded in user input or retrieved content can override the developer's intended behavior. ## Proposed Solution: An Instruction Hierarchy - The authors define an explicit hierarchy that ranks instructions by privilege, so the model knows which instructions take precedence when they conflict. - The hierarchy gives higher-privileged sources, such as system prompts, authority over lower-privileged sources, such as user messages and third-party text. ## Training Method - The authors present a data generation method that teaches the model hierarchical instruction following. - The training teaches the model to selectively ignore lower-privileged instructions that conflict with higher-privileged ones, while still following lower-privileged instructions that don't conflict. ## Results on GPT-3.5 - Applying the method to GPT-3.5 drastically increased robustness against attacks. - The gains extended to attack types that were not included in training, which suggests the model learned a general principle rather than memorizing specific attacks. - Standard capabilities were only minimally degraded.