← Back to docs

Few-shot examples

Show the model exactly what you want by providing input-output pairs before your actual prompt. The model will follow the pattern.

Example 1: Sentiment classification

User:

Classify the sentiment as positive, negative, or neutral.

Text: "I absolutely loved the new update."
Sentiment: positive

Text: "This is the worst experience I've ever had."
Sentiment: negative

Text: "The meeting is scheduled for 3pm."
Sentiment:

Assistant:

neutral

Example 2: Structured JSON output

User:

Extract the name, price, and category from the product description. Return valid JSON.

Input: "Nimbus Pro — $29.99/mo — security software"
Output: {"name": "Nimbus Pro", "price": "$29.99/mo", "category": "security software"}

Input: "Meridian Dashboard — free tier — analytics platform"
Output:

Assistant:

{"name": "Meridian Dashboard", "price": "free tier", "category": "analytics platform"}

Example 3: Code review style

User:

Review this code for bugs. Be concise.

Code: { }
Review: Empty block — remove or add a comment explaining why it's intentionally empty.

Code: if (user == null) { return; }
Review:

Assistant:

Use strict equality (===). Otherwise fine — early return guards against null user.

Tip: Place your few-shot examples immediately before the final input. The model pays most attention to the most recent messages in the conversation. Two to four examples are usually enough — more can dilute the pattern.