Sentiment classification, but with examples baked into the prompt:
prompt = '''Classify each as positive, negative, or neutral.
Examples:
"Best purchase ever" → positive
"Total disappointment" → negative
"It's fine I guess" → neutral
Now classify: "meh, it works"
'''
result = Agent(model).run_sync(prompt)
print(result.output.strip().lower())The examples teach the model the pattern — three labels, the format →, your classification style. The new input slots into the same shape.
Why is this better than just listing labels?
Two reasons:
→ label shape, you nudge the model away from prose like "This is a negative review because...".Few-shot = include 1-5 examples in the prompt. Zero-shot = no examples, just the directive. The examples teach the model the pattern you want.
prompt = f'''<task description>
Examples:
<input 1> → <output 1>
<input 2> → <output 2>
<input 3> → <output 3>
Now classify: <new input>
'''The → is conventional; you can use any consistent separator (:, =>, etc.).
3-5 examples is usually enough. More than 5-7 starts diminishing returns. Choose examples that span the range of inputs you'll see (typical case + 1-2 edge cases) rather than 10 typical cases.
Sentiment classification, but with examples baked into the prompt:
prompt = '''Classify each as positive, negative, or neutral.
Examples:
"Best purchase ever" → positive
"Total disappointment" → negative
"It's fine I guess" → neutral
Now classify: "meh, it works"
'''
result = Agent(model).run_sync(prompt)
print(result.output.strip().lower())The examples teach the model the pattern — three labels, the format →, your classification style. The new input slots into the same shape.
Why is this better than just listing labels?
Two reasons:
→ label shape, you nudge the model away from prose like "This is a negative review because...".Few-shot = include 1-5 examples in the prompt. Zero-shot = no examples, just the directive. The examples teach the model the pattern you want.
prompt = f'''<task description>
Examples:
<input 1> → <output 1>
<input 2> → <output 2>
<input 3> → <output 3>
Now classify: <new input>
'''The → is conventional; you can use any consistent separator (:, =>, etc.).
3-5 examples is usually enough. More than 5-7 starts diminishing returns. Choose examples that span the range of inputs you'll see (typical case + 1-2 edge cases) rather than 10 typical cases.
Create a free account to get started. Paid plans unlock all tracks.