Index Ai Academy
Phase 1 · Building with LLMs · Prompting

Examples in prompts

Show the model what good looks like (few-shot prompting).

About 25 minutes · Free account required

Open this lesson Create a free account

Why it matters

Some things are easier to show than to describe: a house style, a fiddly output format, the line where one category ends and the next begins. Putting examples in the prompt, called few-shot prompting, is the quickest way to get a model to match what you have in mind. It's the same move as handing a new team member three past emails and saying "like these".

What you'll be able to do

  • Explain what examples teach a model, and when they help more than instructions alone
  • Choose a small, varied set of examples that covers every label and the tricky cases
  • Format examples in tags so the model can't confuse them with the real input
  • Build a few-shot prompt from a list of labeled examples in code

Before this lesson

Next in this phase: Structured output