What is few shot prompting in AI?
Few shot prompting in AI means you show the model a few examples of the task done correctly, then ask it to do the same for a new input.
Think of how a teacher explains a new type of maths problem. She solves two on the board, then gives you the third. Few-shot prompting does the same for a large language model. Each example is called a "shot", so two examples is a two-shot prompt.
The important part: the model is not retrained. Its parameters stay exactly the same. It simply reads the examples inside its context window and picks up the pattern for that one conversation. Researchers call this in-context learning.
Few-shot prompting sits one step above zero-shot prompting, where you give only an instruction and no examples.
Few shot prompting example (with 3 shots)
A few shot prompting example has three parts: a short instruction, a few solved input and output pairs, and the new input left unanswered.
Say you run a college canteen app and want customer messages tagged with your own labels:
Tag each message as MENU, PAYMENT or COMPLAINT. Message: Is veg biryani available today? Tag: MENU Message: My UPI payment got deducted but the order failed. Tag: PAYMENT Message: The samosa was cold and the tea was spilled. Tag: COMPLAINT Message: Can I pay with a canteen card instead of cash? Tag:
The model will very likely answer PAYMENT, in exactly one word, because the examples showed both the labels and the format. Without the examples, it might reply with a full sentence or invent a label like "Query".
Few-shot works for formats too. Two examples of a product description written in a friendly, 40-word style will shape the third far better than the instruction "be friendly and short".
Few shot prompting: how many examples should you use?
Most tasks need two to five examples, and you should add more only if testing shows the output improving.
- Start with 2 or 3. Enough to show the pattern without bloating the prompt.
- Cover the variety. Include each label or case at least once, plus one tricky edge case.
- Keep the format identical. Same labels, same spacing, same order every time. Models copy inconsistency too.
- Watch the cost. Every example adds tokens, which means longer prompts and higher API bills.
Order and balance matter. If four of your five examples are COMPLAINT, the model may lean towards that label. Mix them up.
My tip from teaching beginners: write your examples by hand instead of copying the first ones you find. Clean, carefully chosen examples beat a long list of messy ones.
Few shot prompting vs chain of thought
Few-shot prompting shows the model examples of answers, while chain-of-thought prompting asks the model to show its reasoning steps before the answer.
They solve different problems:
- Few-shot fixes format, labels and style. Use it when the model does not know what your output should look like.
- Chain-of-thought fixes reasoning. Use it when the model rushes to a wrong answer on maths or logic.
They also combine well. The original chain-of-thought research used few-shot prompts where each example included worked-out reasoning, not just the final answer. So "few-shot chain-of-thought" means your examples demonstrate the thinking, and the model copies that habit.
Which research paper introduced few shot prompting?
The paper most linked to few shot prompting is "Language Models are Few-Shot Learners" by Brown and colleagues at OpenAI, published in 2020, which introduced GPT-3.
The paper showed that a large enough model (GPT-3 had 175 billion parameters) could perform many tasks just from examples placed in the prompt, without any extra training. It compared three settings side by side: zero-shot, one-shot and few-shot. On many tasks, adding examples improved results, and the benefit tended to be larger for bigger models.
That paper made prompting a serious skill. Before it, adapting a model to a new task usually meant fine-tuning. After it, many tasks could be handled by writing a better prompt. Few-shot prompting is now a standard topic in prompt engineer interviews.