概念
Prompting techniques
Zero-shot, few-shot, chain-of-thought, negative prompts, templates, roles, chaining and ReAct, with one clue each.
本课尚未翻译,暂以英文显示。
Zero-shot
- What it is
- The task only.
- Clue
- Classify this review as positive or negative.
Single-shot
- What it is
- The task and one example.
- Clue
- Same task, plus one labeled review.
Few-shot
- What it is
- The task and several examples.
- Clue
- Same task, plus five labeled reviews.
Chain-of-thought
- What it is
- A request to reason in steps.
- Clue
- Think step by step, then give the total.
Negative prompt
- What it is
- A line that says what to avoid.
- Clue
- Do not mention prices.
Prompt template
- What it is
- A reusable prompt with blanks.
- Clue
- Summarize {document} for {audience}.
| Technique | What it is | Clue |
|---|---|---|
| Zero-shot | The task only. | Classify this review as positive or negative. |
| Single-shot | The task and one example. | Same task, plus one labeled review. |
| Few-shot | The task and several examples. | Same task, plus five labeled reviews. |
| Chain-of-thought | A request to reason in steps. | Think step by step, then give the total. |
| Negative prompt | A line that says what to avoid. | Do not mention prices. |
| Prompt template | A reusable prompt with blanks. | Summarize {document} for {audience}. |
1 / 3
Zero-shot
- What it is
- The task only.
- Clue
- Classify this review as positive or negative.
Single-shot
- What it is
- The task and one example.
- Clue
- Same task, plus one labeled review.
Few-shot
- What it is
- The task and several examples.
- Clue
- Same task, plus five labeled reviews.
| Technique | What it is | Clue |
|---|---|---|
| Zero-shot | The task only. | Classify this review as positive or negative. |
| Single-shot | The task and one example. | Same task, plus one labeled review. |
| Few-shot | The task and several examples. | Same task, plus five labeled reviews. |
2 / 3
Chain-of-thought
- What it is
- A request to reason in steps.
- Clue
- Think step by step, then give the total.
Negative prompt
- What it is
- A line that says what to avoid.
- Clue
- Do not mention prices.
| Technique | What it is | Clue |
|---|---|---|
| Chain-of-thought | A request to reason in steps. | Think step by step, then give the total. |
| Negative prompt | A line that says what to avoid. | Do not mention prices. |
3 / 3
Prompt template
- What it is
- A reusable prompt with blanks.
- Clue
- Summarize {document} for {audience}.
| Technique | What it is | Clue |
|---|---|---|
| Prompt template | A reusable prompt with blanks. | Summarize {document} for {audience}. |
Role (persona)
- What it is
- Tells the model who to act as.
- Clue
- You are a travel agent.
System and user prompts
- What it is
- System: standing rules. User: the request.
- Clue
- Always answer in English.
Prompt chaining
- What it is
- One answer feeds the next prompt.
- Clue
- Summarize first, then translate the summary.
ReAct
- What it is
- Reason, act with a tool, observe, repeat.
- Clue
- Think, search the web, read the result.
Self-consistency
- What it is
- Try several reasoning paths, keep the common answer.
- Clue
- Name only.
Tree-of-thought
- What it is
- Explore branches of reasoning.
- Clue
- Name only.
| Technique | What it is | Clue |
|---|---|---|
| Role (persona) | Tells the model who to act as. | You are a travel agent. |
| System and user prompts | System: standing rules. User: the request. | Always answer in English. |
| Prompt chaining | One answer feeds the next prompt. | Summarize first, then translate the summary. |
| ReAct | Reason, act with a tool, observe, repeat. | Think, search the web, read the result. |
| Self-consistency | Try several reasoning paths, keep the common answer. | Name only. |
| Tree-of-thought | Explore branches of reasoning. | Name only. |
1 / 2
Role (persona)
- What it is
- Tells the model who to act as.
- Clue
- You are a travel agent.
System and user prompts
- What it is
- System: standing rules. User: the request.
- Clue
- Always answer in English.
Prompt chaining
- What it is
- One answer feeds the next prompt.
- Clue
- Summarize first, then translate the summary.
| Technique | What it is | Clue |
|---|---|---|
| Role (persona) | Tells the model who to act as. | You are a travel agent. |
| System and user prompts | System: standing rules. User: the request. | Always answer in English. |
| Prompt chaining | One answer feeds the next prompt. | Summarize first, then translate the summary. |
2 / 2
ReAct
- What it is
- Reason, act with a tool, observe, repeat.
- Clue
- Think, search the web, read the result.
Self-consistency
- What it is
- Try several reasoning paths, keep the common answer.
- Clue
- Name only.
Tree-of-thought
- What it is
- Explore branches of reasoning.
- Clue
- Name only.
| Technique | What it is | Clue |
|---|---|---|
| ReAct | Reason, act with a tool, observe, repeat. | Think, search the web, read the result. |
| Self-consistency | Try several reasoning paths, keep the common answer. | Name only. |
| Tree-of-thought | Explore branches of reasoning. | Name only. |
是什么
Prompting techniques are standard ways to shape a prompt. The first three differ in how many examples you show the model.
Zero-shot gives only the task. Single-shot (one-shot) gives one example. Few-shot gives several, which helps most when the answer needs a special format or tone. Chain-of-thought asks the model to reason step by step, which helps with maths, logic and multi-step questions. A negative prompt says what to leave out. A prompt template is a reusable prompt with blanks that your application fills in.
是什么
Other techniques change who the model is or how prompts connect. Role (persona) prompting tells the model who to act as. A system prompt holds standing rules, and the user prompt holds the request. Prompt chaining feeds the answer of one prompt into the next. ReAct lets the model alternate between reasoning and using tools, and many agents work this way. Self-consistency and tree-of-thought are two more names to know: the first tries several reasoning paths and keeps the most common answer, and the second explores branches of reasoning.
More examples cost more tokens on every call, so use only as many as you need.
要记住
- Zero-shot: the task only. Single-shot: one example. Few-shot: several examples, good for format and tone.
- Chain-of-thought: ask for step-by-step reasoning; good for logic and multi-step problems.
- Negative prompt: say what to avoid. Prompt template: a reusable prompt with placeholders. Tell it to treat user input as data, which resists prompt injection.
要记住
- Role prompting sets who the model acts as. A system prompt sets standing rules.
- Prompt chaining: the answer to one prompt becomes part of the next. ReAct: reasoning mixed with tool actions.
- Self-consistency and tree-of-thought: know the names. Examples add tokens, so they add cost.
考试中
- “Provide a few sample inputs and outputs in the prompt” points to few-shot prompting.
- “Ask the model to think step by step” points to chain-of-thought.
- “Reuse one prompt structure with different inputs” points to a prompt template.
- “Split a big task into prompts where each answer feeds the next” points to prompt chaining.
别和这些弄混
- Parts of a promptThe building blocks of a prompt: instruction, context, input data, output format and negative prompts.
- Prompt best practicesHabits that raise answer quality: be specific, keep it short, give examples, test and add guardrails.
- Amazon Bedrock Prompt ManagementSave, version and reuse prompts, and compare prompt variants, inside Amazon Bedrock.