AI Prompting Mastery

Examples, Few-Shot Prompting and Personas

25 мин

Few-shot prompting

When the style or format is hard to describe, show it. Two to five examples usually beat a paragraph of description.

Turn feature names into friendly changelog lines.

<examples>
<example>
Input: rate limiter on contact form
Output: The contact form now blocks spam bursts, so your inbox stays clean.
</example>
<example>
Input: dark mode toggle
Output: Prefer the dark? Switch themes from the header any time.
</example>
</examples>

Input: footer collapse with remembered state
Output:

Choosing good examples

  • Varied: cover different cases (short and long inputs, edge cases), or the model copies surface details of a single example.
  • Representative: match the real inputs you will send.
  • Correct: every example is a strong, exact demonstration; the model will mimic mistakes too.
  • Clearly marked: wrap them in tags so they are not confused with the real task.

If outputs start copying an example's exact wording, add more diverse examples or say "Match the style, not the content."

Personas and roles

A role focuses vocabulary and judgement: "You are a senior security engineer reviewing a pull request." It works best combined with concrete context about the audience and goal. A persona is not a substitute for information: "You are an expert lawyer" does not give the model your contract.

Audience as a lever

The same request at different audience levels:

Explain what a database index is.
- Audience A: a 12-year-old learning to code
- Audience B: a backend developer preparing for an interview
- Audience C: a CFO deciding whether to fund a performance project

Specifying the audience changes length, vocabulary and examples more reliably than "make it simple".

Exercise

Create a few-shot prompt that converts messy meeting notes into action items in the format - [Owner] Task (due date or "no date"). Use three varied examples, including one with no owner mentioned.

Check yourself

  • How many examples are typically enough?
  • What happens if all your examples look alike?
  • Why is a persona alone not enough context?

Ваш прогресс сохраняется только в этом браузере.

Отправить на проверку (10 баллов)