Built as an interactive training module by TARAhut AI Labs
Generative AI & Prompt Engineering · Session 07: Few-Shot & Zero-Shot Prompting · tarahutailabs.com
© 2026 TARAhut AI Labs. All rights reserved.
Teach AI by showing it examples. Master classification, extraction, and formatting with accuracy tracking. Go from inconsistent output to production-ready precision. "AI nu examples dikhao, te oh pattern samajh jaanda hai."
"Teach me without words." Show 3 positive movie reviews labelled POSITIVE, then show an unlabelled review. Everyone gets it instantly. AI works the same way — it learns patterns from examples in your prompt. "Examples dikhao, AI samajh jaanda hai."
Last session you learned chain-of-thought (linear reasoning) and tree-of-thought (branching exploration). CoT teaches AI HOW to think. Today, few-shot teaches AI WHAT PATTERN to follow. Together with CRISP, you now have a complete prompt engineering toolkit. "CoT = soch da tarika, Few-Shot = pattern da tarika."
"Classify this email as spam or not spam." AI uses only its training knowledge. Works for simple tasks but fails on nuanced or ambiguous inputs. "Bina example de — AI guess karda hai."
"Example 1: 'Limited offer!' = Spam. Example 2: 'Your invoice' = Not Spam. Now classify..." AI follows the demonstrated pattern with precision. "Examples de naal — AI pattern follow karda hai."
No examples given. "Classify this customer review as positive, negative, or neutral." AI relies entirely on its training. Good for obvious cases. Fails on sarcasm like "Oh great, another Monday" — zero-shot might call this positive. "Koi udaharan nahi — AI apne training te depend karda hai."
One example given. "Example: 'Absolutely love it!' = Positive. Now classify: 'Not bad, could be better.'" Slight improvement. One example helps set the format but doesn't cover edge cases. Better than zero, but limited.
3-5 diverse examples. Include clear positive, clear negative, sarcastic, mixed, and neutral examples. AI now handles ambiguity because it has seen the RANGE. "3-5 examples de naal AI 90%+ accuracy de sakda hai." This is the sweet spot for most tasks.
Five rules for powerful few-shot examples: (1) Representative — cover the range of inputs. (2) Diverse — include edge cases, not just easy ones. (3) Consistent format — every example follows the exact same structure. (4) Correct — wrong examples teach wrong patterns. (5) Minimal but sufficient — usually 3-5 is enough; more than 7 rarely helps. "Sahi examples = sahi output."
"Mere paas real-world tasks ne jinnan te AI consistent output nahi denda." — That changes today. Few-shot prompting transforms AI from a guessing machine into a reliable classification and extraction engine. Consistency is the difference between a toy and a tool.
Copy this to ChatGPT or Claude WITHOUT any examples:
Next: Build your first classification system with few-shot examples.
Build few-shot classifiers for sentiment analysis, email categorization, and lead scoring. Measure accuracy gains from zero-shot to few-shot in real time. "Har task te zero-shot vs few-shot da comparison karo."
First, test WITHOUT examples. Note the accuracy:
NOW add 5 examples covering the full range, then classify the same 10 reviews:
Classify business emails using few-shot examples:
Your few-shot examples should reflect local business context. An email mentioning "Ludhiana manufacturing unit" is clearly an inquiry, not spam. Context-aware examples improve accuracy because AI learns the DOMAIN, not just the category. "Local context = better classification."
Next: Extract structured data from messy text — the business goldmine.
Few-shot is not just for classification. It is incredibly powerful for extracting structured data from unstructured text and converting formats. These are skills businesses pay for. "Messy data nu clean data vich badlo — businesses ede layi paise dende ne."
Extract structured data from messy invoice text using few-shot examples:
Extract candidate profiles from unstructured resume text:
Convert rambling meeting transcripts into structured action items with owners, deadlines, and priorities. A PA's dream tool. Few-shot examples ensure consistent output format every time.
Turn raw transaction descriptions into categorized expenses: "NEFT to Reliance Jio" becomes "Telecom/Internet, ₹999." Few-shot handles Punjabi business transaction patterns.
Extract Product Name, Rating, Key Praise, Key Complaint, and Recommendation from verbose reviews. Structured data that drives business decisions.
If you're building applications, ask for JSON output in your few-shot examples. Instead of table format, show one example as JSON: {"company": "Singh Manufacturing", "total": 708000}. AI will follow that structure for all subsequent extractions. This is how production AI pipelines work.
Next: Track and optimize your accuracy like a data scientist.
Professional prompt engineers don't just "feel" that their prompts work. They MEASURE accuracy, find the optimal example count, and iterate. "Professional prompt engineer measure karda hai — sirf feel nahi karda."
For each task: (1) Prepare 10 test inputs with known correct answers. (2) Run with 0, 1, 3, 5, and 7 examples. (3) Count correct answers at each level. (4) Calculate: Accuracy = Correct / Total x 100%. (5) Find the sweet spot where adding more examples stops helping. "Ground truth set banao, har level test karo, sweet spot labho."
Pick ONE classification task from your work (email sorting, lead scoring, support ticket categorization). Test with 1, 3, 5, and 7 examples on 10 test inputs.
All examples are "easy" positive cases. When AI encounters sarcasm or mixed sentiment, it defaults to positive. Fix: Include at least one edge case and one ambiguous example. "Sirf easy examples deo ge ta hard cases te fail hoga."
Example 1 outputs "POSITIVE" while Example 2 outputs "Pos." and Example 3 outputs "This is positive." Fix: Use EXACTLY the same output format in every example. Consistency is non-negotiable.
An example labels "The food was terrible" as POSITIVE. AI learns from YOUR mistakes. Fix: Double-check every example label before using it. One wrong example poisons the entire set. "Galat udaharan galat sikhiya denda hai."
Next: Quiz time! Prove your few-shot mastery.
8 questions picked randomly from a pool of 20. Advanced-level questions about few-shot prompting, classification, extraction, and accuracy optimization. "Har sawaal tuhadi samajh test karda hai."
Next: Your homework and Session 8 preview.
"Tusi aaj few-shot prompting master kar liya — AI nu examples naal sikhana." Here's what you learned and what's next.
✅ Difference between zero-shot, one-shot, and few-shot prompting
✅ How to build classifiers for sentiment, email, and lead scoring
✅ How to extract structured data from invoices and resumes
✅ The 5 rules for effective examples (representative, diverse, consistent, correct, minimal)
✅ How to measure and optimize accuracy (sweet spot: 3-5 examples)
✅ The 3 accuracy killers and how to avoid them
"Practice naal hi mastery aundi hai!"
"Kal assi AI personas banaange — system prompts naal. Same model, wildly different personality. Tusi 3 AI personas banaoge te stress test karoge. From individual prompts to permanent AI identities."