← Back to AI Engineering Mind Map
🤖 AI EngineeringID: instruction-hierarchy-system

Instruction Hierarchy & System Prompt

指令分层与 System Prompt 架构
🎯Core Definition
Instruction Hierarchy is a formal security architecture and prompt design framework that establishes strict privilege tiers across conflicting inputs; it establishes 3 distinct privilege levels: 1) System Instructions (Developer Messages: absolute highest authority defining identity, guardrails, and non-negotiable formats); 2) User Prompts (medium authority expressing user intent, strictly subordinate to system constraints); 3) Untrusted Third-party Context (Retrieved RAG passages, web snippets, tool outputs: zero privilege, strictly evaluated as passive data payload).
💡Use Cases
Production System Prompt engineering, defending against Indirect Prompt Injection lurking within RAG documents or tool payloads.
⚡Key Problems Solved
Flat prompt contexts treat all text tokens with equal authority, allowing adversarial strings like 'Ignore all previous instructions' to hijack execution; Instruction Hierarchy hardens top-level system commands against override attempts.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Instruction Hierarchy & System Prompt.
Use Cases
In production engineering, what are the primary use cases for Instruction Hierarchy & System Prompt and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
How do OpenAI and Anthropic train models during RLHF/SFT to enforce role priority boundaries across `system`, `user`, and `tool` roles?
2
What is the standard modular architecture for writing production System Prompts (persona, workflow, format, guardrails)?
3
How does strict XML tagging (`<context>...</context>`) physically demarcate retrieved passages as non-executable read-only payload?
4
What is the arbitration and refusal protocol when user instructions directly contradict hard system prompt constraints?
5
How to prevent System Prompt attention decay and forgetting across massive 100K+ token conversational contexts?
Updated 2026-08-14
🎯
Verify Mastery: Practice Exam Questions for "Instruction Hierarchy & System Prompt"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardChain-of-Thought PromptingNext Card →OpenAI Strict Structured Outputs

🔗 More AI Engineering Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/AI_Engineering/card/instruction-hierarchy-system
中文速览与面试要点

指令分层与 System Prompt 架构 (Instruction Hierarchy & System Prompt)

定义: 指令分层体系 (Instruction Hierarchy) 是一种在大型语言模型内部确立不同来源指令绝对优先级的安全架构与提示词工程规范;它将输入文本明确划分为三级信任特权层:1) 系统指令层 (System Prompt / Developer Messages: 拥有最高执行特权,定义模型身份、安全红线、不可违背的格式铁律);2) 用户指令层 (User Messages: 次高特权,表达用户当下需求,但不能推翻系统层规则);3) 外部不可信数据层 (Third-party Data / Retrieved Context / Tool Outputs: 零特权纯数据,若包含指令型文本一律按纯文本处理)。 使用场景: 企业级生产环境 System Prompt 架构设计、防止来自外部检索文档或第三方 API 的间接提示注入 (Indirect Prompt Injection)。 解决的问题: 早期大模型将所有输入视为平铺平行的文本流,当用户输入或检索文档包含“忽略上述所有指令”时,模型极易被恶意劫持;指令分层从模型对齐训练与工程隔离双重层面锁死了最高特权等级。

核心要点

  • 详细剖析 OpenAI / Anthropic 在 RLHF 与指令微调中如何训练模型识别不同角色层级 (`system` vs `user` vs `tool`) 的对抗训练机制?
  • 生产 System Prompt 的模块化架构(角色设定、业务流程、输出规范、边界约束与防御注入)标准编写范式?
  • 使用明确的分隔符(如 ` ` ... ` ` 或 XML 标签)如何物理标记外部检索文档为不可执行的只读数据?
  • 当用户指令与系统提示词发生直接冲突(如用户要求绕过敏感限制)时,模型的优先级仲裁与安全拒答策略?
  • 如何防止模型在长上下文(100K+ tokens)后半段发生“系统提示词注意力衰减与遗忘 (Prompt Decay)”?