Techniques

What is Few-Shot Learning?

Few-shot learning (in-context learning) is providing 2-5 examples of desired input-output pairs before your actual query. The LLM learns the pattern from examples without any training—dramatically improving consistency and accuracy for specialized tasks.

Why It Matters

Describing a complex output format in words is error-prone. Showing 3 examples of exactly what you want is clearer for both humans and LLMs. Few-shot prompts consistently outperform zero-shot for classification, extraction, and formatting tasks.

Shot Terminology

Zero-Shot

No examples. Just instructions. Relies on model's pretraining.

One-Shot

Single example. Minimal context, better than zero.

Few-Shot (2-5)

Multiple examples. Optimal for most tasks.

Example: Risk Classification

# Few-shot prompt for contract risk classification
Example 1:
Input: "Party shall indemnify against all claims"
Output: {"risk": "HIGH", "type": "unlimited_liability"}
Example 2:
Input: "30-day written notice required"
Output: {"risk": "LOW", "type": "standard_terms"}
Example 3:
Input: "Liability capped at fees paid"
Output: {"risk": "MEDIUM", "type": "capped_liability"}
Now classify: "Vendor assumes no liability for consequential damages"

Related Terms

← Back to Glossary