零样本与少样本提示
通过示例引导模型行为
零样本与少样本提示 是 CoddyKit 上的免费 NLP Academy 课时。 这是第 3 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 NLP Academy 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 NLP Academy 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
Prompting Is Programming
With LLMs, your main control is the words you send. The art of shaping those words is called prompting. ✍️
Zero-Shot Prompting
In zero-shot prompting you just describe the task in plain words, with no examples, and trust the model to figure it out.
prompt = "Classify this review as positive or negative: I loved it!"When Zero-Shot Works
Zero-shot is great for common tasks the model has seen often, like summarizing a paragraph or answering a simple question.
Show, Do Not Just Tell
When the task is unusual, examples help. Giving the model sample inputs and outputs is called few-shot prompting.
A Few-Shot Example
You list a couple of worked examples, then leave the final input blank so the model continues the same pattern.
Review: Great! -> positive
Review: Awful. -> negative
Review: I loved it! ->Examples Set the Format
Few-shot does more than teach the task; it also fixes the output format, so the model answers in exactly the shape you showed.
Pick Clear Examples
Choose examples that are correct, varied, and unambiguous. Sloppy or biased examples quietly teach the model the wrong pattern.
More Is Not Always Better
Each example eats into the context window and adds cost, so use the fewest examples that reliably get the job done.
Be Specific
Vague prompts give vague answers. Spell out the role, the task, the format, and any constraints you care about.
Think Step by Step
For tricky reasoning, ask the model to work it out step by step. This chain-of-thought hint often improves the final answer.
prompt = "Solve this and show your reasoning step by step: ..."Iterate and Test
Prompting is empirical. Try a version, check the outputs, then refine the wording until results are consistent.
Quick Check
What is the key difference between zero-shot and few-shot prompting?
Recap
Start zero-shot for common tasks. Add a few clear examples when you need a specific pattern or format, then iterate. ✅
常见问题解答
「零样本与少样本提示」课时是免费的吗?
是的 — 「零样本与少样本提示」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 NLP Academy 课程的其余内容,请升级到 CoddyKit PRO。 NLP Academy 课程共包含 4 节课。
「零样本与少样本提示」这节课中我会学到什么?
通过示例引导模型行为 你通过在浏览器中直接运行的动手代码来练习 NLP Academy,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 NLP Academy 需要有经验吗?
无需任何先前经验。CoddyKit 上的 NLP Academy 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 3 节课,共 4 节。
「零样本与少样本提示」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 NLP Academy 课中编写并运行代码吗?
能。每节 NLP Academy 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- 模型为何会变大
- 从 Python 调用 LLM
- 零样本与少样本提示
- 结构化输出与防护机制