Few-Shot Learning in AI

From the AI Prompting cheat sheet · Advanced Prompting Patterns · verified Jul 2026

Few-Shot Learning

Provide examples to guide desired behavior

javascript
NAME: Example-Based Learning
PURPOSE: Train the AI with examples of desired input-output patterns
TEMPLATE:
I'll show you some examples of what I need, then ask you to follow the same pattern.

Example 1:
Input: [INPUT 1]
Output: [OUTPUT 1]

Example 2:
Input: [INPUT 2]
Output: [OUTPUT 2]

Example 3:
Input: [INPUT 3]
Output: [OUTPUT 3]

Now, following the same pattern:
Input: [YOUR INPUT]
Output: [AI SHOULD COMPLETE THIS]
EXAMPLE:
I'll show you some examples of what I need, then ask you to follow the same pattern.

Example 1:
Input: "Database connection timeout"
Output: "CRITICAL: Database connectivity issue detected. Action required: Check connection pool settings, verify network connectivity, and review database server logs. Priority: P1"

Example 2:
Input: "Slow page load times"
Output: "WARNING: Performance degradation detected. Action required: Analyze query performance, check cache hit rates, and review CDN configuration. Priority: P2"

Example 3:
Input: "Failed login attempt from unknown IP"
Output: "INFO: Security event logged. Action required: Monitor for patterns, check geo-blocking rules, and review authentication logs. Priority: P3"

Now, following the same pattern:
Input: "Memory usage at 95%"
Output: [AI SHOULD COMPLETE THIS]
OUTPUT:
CRITICAL: Memory exhaustion imminent. Action required: Identify memory-consuming processes, implement immediate garbage collection, and scale infrastructure if needed. Priority: P1
🎯 Provide 3-5 examples for best results
⚡ Keep examples consistent in format
💡 Include edge cases in your examples

More AI tasks

Back to the full AI Prompting cheat sheet