提示的结构剖析:指令、上下文、示例与输出格式
把每个有效的提示拆解为它的四个核心组件,并学习何时使用每一个。
- 理解并应用本课涵盖的核心概念
每个有效提示的四个组件
每个提示——从简单的一行,到复杂的多步指令——都是由四个组件构建而成。你并非总是需要全部四个,但理解它们能帮你诊断一个提示为何失败、以及如何修复它。
1. 指令(Instruction)
指令是你希望模型去做的事。要显式且具体。
弱: Summarize this.
强: Write a 3-sentence executive summary focusing on the business impact.
2. 上下文(Context)
上下文是模型完成任务所需的背景信息。没有上下文,模型会猜——而且猜错。
You are reviewing a support ticket. The customer has been with us for 3 years and has a premium subscription.
Ticket: [TICKET TEXT]
Draft a response that acknowledges their loyalty and resolves their issue.
3. 示例(Examples)
示例(few-shot)向模型精确展示你想要什么。这通常比描述它更有效。
Classify the sentiment. Reply with only the label.
Review: "Fast delivery, great product" → Positive
Review: "Broken on arrival" → Negative
Review: "It's fine, nothing special" →
4. 输出格式(Output Format)
显式指定格式——长度、结构、语气与媒介。
- 「Respond in exactly 3 bullet points」
- 「Return valid JSON only, no explanation」
- 「Write in second person, present tense」
整合起来
一个用于代码审查任务的完整提示:
You are a senior software engineer doing a code review. [ROLE]
The PR adds a new user authentication endpoint. Security is the top priority. [CONTEXT]
For each issue found, format your response as:
- **Severity**: Critical / High / Medium / Low
- **Location**: file:line
- **Issue**: one sentence
- **Fix**: one sentence
[FORMAT]
#AI#tutorial#superml#prompt#prompting#anatomy