Few-shot prompting means putting a small set of worked examples inside your prompt so an AI model can follow the pattern on a new input. Each example shows both the input and the answer you want. It is useful when an instruction such as "keep it concise" leaves too much room for interpretation, especially for classification, rewriting and extracting information into a fixed format.
Google's official Gemini prompt design guide explains that examples can guide formatting, phrasing and scope. The examples below are original templates for everyday Indian study and office tasks. They are not recorded model responses or a claim that any model will always follow the pattern.
| Approach | What the prompt contains | Use it when |
|---|---|---|
| Zero-shot | A task without worked examples | The instruction is already straightforward |
| Few-shot | A task plus several input and answer pairs | You need a specific, repeatable pattern |
What is the difference between zero-shot and few-shot prompting?
A zero-shot request might say: "Classify this library message as a renewal request, an availability question or something else." It tells the model the categories but leaves their boundaries unstated. A few-shot version adds examples showing which messages belong in each category, then supplies a fresh message to classify.
The distinction concerns what you include in that prompt. You are demonstrating a task, rather than building a training dataset and running a separate model training process. For an explanation of that separate process, see our guide to fine tuning in AI.
Few-shot prompting example for sorting messages
Before: "Sort these library messages." That request does not define the labels or say whether the answer should include an explanation. After, use this template to demonstrate a short classification task. The messages are fictional and contain no personal records.
Classify the final message. Allowed labels: RENEWAL, AVAILABILITY, OTHER. Return only one label. Use these examples:
Message: Can I keep my borrowed book for another week?
Label: RENEWAL
Message: Is the history atlas available to borrow?
Label: AVAILABILITY
Message: What time does the library close?
Label: OTHER
Now classify:
Message: Please extend the return date for my novel.
Label:
The examples do three jobs: define the categories, demonstrate the output labels and show that no commentary is required. A useful manual check is whether the new response contains exactly one allowed label. If it gives a paragraph, revise the instruction about the answer format before adding more examples.
Few-shot prompting example for rewriting a notice
For a class representative, "make this polite" may produce a message that is too long or adds an apology. This version demonstrates a brief tone while preserving the action. Its purpose is rewriting supplied text, not inventing an announcement.
Rewrite the final notice as one courteous sentence. Preserve its facts. Add no dates, reasons or promises.
Original: Send your project outline by Friday.
Rewrite: Please send your project outline by Friday.
Original: Bring your library card to the meeting.
Rewrite: Please bring your library card to the meeting.
Original: Submit the signed consent form before the workshop.
Rewrite:
Check the answer against the original sentence. It should preserve the signed form and the workshop deadline without adding a calendar date. If the notice has two separate actions, supply an example with two actions too. Otherwise, the model has only seen a simpler pattern than the one you need.
How do you choose good few-shot examples?
Google recommends specific, varied examples and consistent formatting. Keep the same labels and separators throughout. If one example says "Answer:" and another uses an unrelated table, it becomes harder to tell which structure is intended. Choose examples that cover meaningful differences in the task, rather than repeating the same easy case with different names.
For extracting information from short notices, demonstrate what happens when something is missing. Here is an original pattern for a student society's event list. The word "missing" is deliberate: it shows that an absent time should stay absent.
Extract event, day and time. Use only supplied information.
Notice: Poetry reading on Tuesday at 4 pm.
Answer: Poetry reading | Tuesday | 4 pm
Notice: Debate practice on Thursday. Time will be announced later.
Answer: Debate practice | Thursday | missing
Notice: Book discussion on Saturday at 11 am.
Answer:
Manually compare each extracted field with its notice. Examples specify a pattern; they do not verify facts. Our guide to checking AI hallucinations explains why a plausible answer still needs comparison with the source.
How many examples should you include?
There is no single number prescribed for every task in Google's guide. It advises experimenting and warns that too many examples can make responses fit those examples too closely. Begin with a small set that demonstrates your actual rules, then test a new case that is not already answered in the prompt.
Change one thing at a time: an unclear instruction, an inconsistent label or an unrepresented case. Keep a copy of the prompt and note which cases failed. For broader task wording, our prompt writing framework covers context and output requirements. Use examples when they clarify the job, and keep checking whether the new answer follows both the pattern and the supplied facts.









