AI / A CONCEPT NOTE

Few-Shot Prompting

providing examples to guide the model

~65 sec read

Overview · mechanism
pitfall · examples

01 / THE SHORT VERSION

The idea in a few sentences.

Injecting a few examples (inputs and expected outputs) inside the prompt template to show the model the target format and style before asking the actual question.

02 / FOLLOW THE MECHANISM

How few-shot instructs run

  1. Pattern examples

    prompt sets: 'Input: cat -> Output: feline. Input: dog -> Output: canine.'

  2. Query link

    appends the real query: 'Input: horse -> Output:'.

  3. Prediction

    LLM detects pattern matches and output format, generating: 'equine'.

04 / COMMAND NOTES

Read the command, then the result.

Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.

EXAMPLE 01 · REFERENCE

test few-shot template accuracy

promptfoo eval --config my-few-shot.yaml

Explore command anatomy in the CLI lab