← Lessons

quiz vs the machine

Silver1100

Machine Learning

Few Shot In Context Learning

Teaching a model a task by placing a few examples directly in the prompt.

4 min read · intro · beat Silver to climb

What it is

Few shot in context learning is the ability of a large language model to pick up a task from a handful of examples placed inside the prompt, with no weight updates at all. The model infers the pattern and applies it to a new input.

How it works

You show the model the pattern you want and then a fresh case.

  • Each example pairs an input with its desired output
  • The new query is added at the end, and the model continues the pattern
  • Zero shot gives no examples, one shot gives one, and few shot gives several

Nothing is trained here. The examples only steer the model at inference time, which is why it is called in context learning rather than fine tuning.

What matters

Results depend on how you present the examples.

  • Clear, consistent formatting across examples helps the model lock onto the pattern
  • Examples that resemble the real query work best
  • The prompt has a length limit, so you can only fit so many examples

Key idea

Few shot in context learning teaches a task through examples in the prompt, steering the model without changing any weights.

Check yourself

Answer to earn rating on the learn ladder.

1. What makes in context learning different from fine tuning?

2. What does few shot mean compared to zero shot?