少样本提示(Few-shot
Prompting)在提示中放入少量输入—输出示例,引导模型模仿任务格式或规律。它与监督微调都用示例,却发生在推理时。Few-shot prompting places a small set of input-output examples in the
prompt so a model can imitate a format or pattern. It uses examples
like supervised fine-tuning, but at inference time.
01 · 给一次范例,还是重新培训员工01 · Show an example or retrain the worker
只想让这一次回答遵循 JSON
格式,应该把四个示例放进当前提示,还是用它们去更新模型参数?You want this one response to follow JSON. Should four examples
enter the current prompt, or update the model parameters?
0→4
02把示例从 0 拖到
4,对照格式遵循率与上下文占用Move from 0 to 4 Examples and Compare Format Adherence with Context
Occupancy
推理时示例 · 反例干扰inference-time examples · conflicting example
状态 AMetric A
—
—
状态 BMetric B
—
—
状态 CMetric C
—
—
所有概率、命中率、得分与输出均为固定种子的教学模拟,不代表真实模型。拖回主变量即可复核结论。All probabilities, hit rates, scores, and outputs are fixed-seed
teaching simulations, not real model output. Move the main
variable back to verify the conclusion.
03把刚才的变化拆成 4 个零件Break the Change into Four Parts
Few-shot Prompting
TASK
同一任务Same task
测试输入与输出 Schema 保持不变。The test input and output Schema stay fixed.
EXAMPLES
上下文示例In-context examples
0–4 对输入—输出对只服务本次推理。Zero to four input-output pairs serve only this inference.
ADHERENCE
格式遵循Format adherence
一致示例通常提高格式命中,但收益会趋缓。Consistent examples often improve formatting, with diminishing
returns.
TOKENS
窗口占用Context occupancy
每加一例都持续消耗有限 token。Every additional example continues consuming limited
tokens.
04最小机制:主交互能逐项验证Minimal Mechanism: Verify Each Link in the Interaction
MECHANISM
prompt_tokens = instruction + query + Σ examplei
示例数增加时 token
单调上升;格式遵循率只有在示例一致时才稳定提高,冲突第
4 例可让曲线掉头。Token use rises monotonically with example count. Format
adherence improves reliably only when examples agree; a
conflicting fourth example can reverse the curve.
放入示例Add examples当前请求上下文current request context
模式模仿Imitate pattern格式遵循上升format adherence rises
权衡窗口Trade context收益趋缓 + token 增长diminishing gains + more tokens
05第 4 个示例突然改用冲突格式Make the Fourth Example Use a Conflicting Format
主动制造失败Create a failure
边界实验Boundary experiment
更多示例不自动更好。前三例要求
JSON,第四例要求纯文本时,模型收到的规律本身就冲突。More examples are not automatically better. If three request JSON
and the fourth requests plain text, the pattern itself
conflicts.
尚未执行。先在主交互中观察正常机制。Not run yet. Observe the normal mechanism in the main interaction
first.
✗ 少样本提示会永久改模型。Few-shot prompting permanently changes the
model.→ ✓ 示例只进入当前推理上下文,不更新参数。Examples enter this inference context; parameters are not
updated.
✗ 示例越多,效果必然越好。More examples always improve results.→ ✓ 收益会趋缓,冲突示例还会降低遵循率。Gains taper, and conflicting examples can reduce
adherence.
✗ 少样本提示与 SFT 是同一件事。Few-shot prompting and SFT are the same.→ ✓ 两者都用示例,但一个改上下文,一个改参数。Both use examples; one changes context, the other changes
parameters.
06 · 一句话带走06 · One line to keep
少样本提示在推理时用示例引导格式,不改参数;示例增加会占用更多窗口,且只有一致、高质量示例才可能稳定提升遵循率。Few-shot prompting guides format with inference-time examples and
does not update parameters. More examples consume context, and
only consistent, high-quality examples can improve adherence
reliably.