跳到主要内容Skip to main content

怎么把提示词写结构How to Structure a Prompt

微型指南 · 约 7 分钟Guide · about 7 min · 引用核验 2026-11-03(仅引用链接与日期) · refs checked 2026-11-03 (reference links and dates only)

「怎么向 AI 提问」讲问前交代什么;这篇讲把这些交代放进什么形状:角色、任务、约束、格式,四块分开写。"How to Ask AI" covers what to state before asking; this guide covers what shape to put it in: role, task, constraints, and format, written as separate blocks.

怎么做How to

分块写,别写成一整段散文:角色与背景一块、任务一块、约束一块、输出格式一块,模型对分块指令的遵循更稳。

系统提示放长期规则(语气、边界),用户消息放本次任务——两层各司其职,别把一次性要求塞进系统提示。

用标题或标签划界(如「背景:」「要求:」),长输入时把待处理原文与指令明确隔开,防止模型把材料当指令。

约束写成可检查的条目:「不超过 300 字」「面向零基础」「给出来源」,比「简短一点」「专业一点」可执行。

输出格式单独一块并给例子:一段样例输出胜过三段描述。

改提示词一次只改一处并对比效果,同时改多处就说不清是哪处起了作用。

Write in blocks, not one wall of prose: role and background in one block, the task in another, constraints in another, output format in another — models follow blocked instructions more reliably.

Put standing rules (tone, boundaries) in the system prompt and the current task in the user message — each layer does its job; don't stuff one-off requests into the system prompt.

Mark sections with headings or tags (e.g. "Background:", "Requirements:"), and on long inputs clearly separate the material to process from the instructions, so the model doesn't treat data as directives.

Write constraints as checkable items: "under 300 words", "for absolute beginners", "cite sources" — these beat "shorter" or "more professional".

Give the output format its own block plus one worked example: a single sample output beats three paragraphs describing it.

Change one thing at a time when editing a prompt and compare results; change five at once and you can't tell which one worked.

例子与判断Example and interpretation

以下是教学情境,不是本站运行或实测记录。A teaching scenario, not a measured or executed site test.

将任务拆成三块:资料“周六 14:00、阅览室、旧书交换”;要求“不增加事实,缺失项写未知”;格式“标题和两句正文”。若输出补了联系电话,直接对照第二块指出违反了哪条要求。Use three blocks: source facts (Saturday 14:00, reading room, book exchange), constraints (no invented facts; unknown for missing facts), and format (title plus two sentences). An invented contact number violates the constraints block.

出处Sources
  • Anthropic 提示工程总览Anthropic Prompt engineering overview ↗
  • Anthropic Claude 提示最佳实践Anthropic Claude prompting best practices ↗
  • Google Gemini 提示策略Google Gemini prompting strategies ↗
  • OpenAI 提示工程指南OpenAI Prompt engineering guide ↗