๐ Examples Inside Prompt
Including examples in your prompt is one of the most powerful ways to guide the AI. Instead of describing what you want in abstract terms, you show the AI what good output looks like. One concrete example is worth a hundred words of explanation.
This technique is called demonstration-based instruction โ you demonstrate the pattern, and the AI follows it.
Why This Mattersโ
Humans learn by example. So does AI. When you include an example in your prompt, you're doing two things at once:
- Clarifying your intent โ the AI sees exactly what you mean
- Setting the pattern โ the AI matches the style, format, and tone of your example
Without examples, the AI guesses at your desired format. With examples, it knows precisely what you expect. This dramatically reduces the need to regenerate or edit responses.
How to Use Examples Effectivelyโ
1. Show the Input-Output Patternโ
Give the AI an example of input and what the output should look like:
Convert these company names to ticker symbols.
Example:
- Apple Inc. โ AAPL
- Microsoft Corporation โ MSFT
Now convert:
- Amazon.com Inc.
- Tesla Inc.
- Alphabet Inc.
2. Demonstrate the Tone and Styleโ
If you want a specific writing style, show it:
Write product descriptions in this style:
Example: "The CloudWalk Pro isn't just a shoe โ it's a declaration that
your feet deserve better. Memory foam insoles meet breathable mesh in a
package that weighs less than your morning guilt about skipping the gym."
Now write a description for: A stainless steel water bottle that keeps
drinks cold for 24 hours.
3. Show the Classification Patternโ
For categorization tasks, examples eliminate ambiguity:
Categorize these support tickets by urgency.
Examples:
- "Website is completely down" โ Critical
- "Button color looks wrong on mobile" โ Low
- "Users can't complete checkout" โ High
- "Can you add a dark mode?" โ Feature Request
Now categorize:
- "Payment processing is failing for all credit cards"
- "The logo is slightly pixelated on retina displays"
- "App crashes when uploading files larger than 10MB"
4. Define Edge Casesโ
Examples help clarify how to handle tricky situations:
Extract the city name from these addresses. If no city is found, return "Unknown."
Examples:
- "123 Main St, Portland, OR 97201" โ Portland
- "PO Box 456" โ Unknown
- "Suite 100, 789 Oak Ave, Denver, CO" โ Denver
Now extract from:
- "42 Elm Road, Austin, TX 78701"
- "Building 5, Floor 3"
- "1600 Pennsylvania Avenue NW, Washington, DC 20500"
Prompt Exampleโ
I need you to summarize customer reviews into structured feedback.
Example:
Review: "I love how fast the delivery was, but the packaging was damaged
and two items were missing from my order."
Summary:
- Positive: Fast delivery speed
- Negative: Damaged packaging, missing items
- Priority: Order accuracy
Now summarize these reviews in the same format:
Review 1: "The product quality is amazing and exactly as described.
However, customer service took 3 days to respond to my question."
Review 2: "Everything was perfect โ great product, fast shipping,
and the price was unbeatable. Will definitely order again."
โ Bad Exampleโ
Classify these reviews
Classify into what categories? Using what format? What counts as positive vs. negative? The AI has to guess everything, and it will likely choose a format and classification system that doesn't match your needs.
โ Improved Exampleโ
Classify these customer reviews as Positive, Negative, or Mixed.
Examples:
- "Great product, works perfectly!" โ Positive
- "Terrible quality, broke after one day" โ Negative
- "Good features but too expensive" โ Mixed
Now classify these:
1. "Absolutely love it! Best purchase this year."
2. "The item arrived late and was the wrong color."
3. "Decent product for the price, but the instructions were confusing."
4. "Fast shipping, great packaging, and the product exceeded expectations."
5. "Would not recommend. Poor build quality and no customer support."
๐งช Try It Yourself
Edit the prompt and click Run to see the AI response.
Practice Challengeโ
Task: You want the AI to generate creative product names for a new energy drink.
- First, write a prompt WITHOUT any examples and see what names you get
- Then, write a prompt WITH 3 example names that match the style you want:
- Example: "ThunderBolt Rush," "IceStorm Energy," "NitroBlaze Fuel"
- Compare the two sets of results
Notice how the examples steer the AI toward a specific naming style (aggressive, energetic) vs. the generic names you get without examples.
Bonus: Change your examples to a different style (calm, natural: "Pure Flow," "Zen Boost," "Morning Glow") and see how the output changes entirely.
Real-World Scenarioโ
Scenario: You're building a data pipeline and need the AI to help you transform messy customer data into a clean, standardized format.
Without examples:
"Clean up this customer data."
The AI doesn't know what "clean" means to you. Should names be capitalized? Should phone numbers have dashes? What format for dates?
With examples:
"Standardize this customer data. Follow these examples:
Input:
john doe, 555.123.4567, 03/15/1990, new yorkOutput:John Doe | (555) 123-4567 | 1990-03-15 | New York, NYInput:
JANE SMITH, 5559876543, 1985-07-22, los angeles caOutput:Jane Smith | (555) 987-6543 | 1985-07-22 | Los Angeles, CANow standardize these entries:
bob wilson, 555-444-3333, 12/01/1995, chicago illinoisMARIA GARCIA, 5552221111, 1988.11.30, miamialex chen, (555) 6667777, Jan 5 1992, san francisco ca"
The examples define every formatting rule without you having to write them out as a list of instructions.
Interview Questionโ
Q: How do examples in a prompt improve AI output, and what makes an effective example?
A: Including examples in a prompt improves output by eliminating ambiguity โ they show the AI the exact format, style, tone, and classification logic you expect, rather than relying on abstract descriptions. Effective examples share these traits: (1) they clearly show the input-output relationship, (2) they cover normal cases and edge cases, (3) they're consistent in format with each other, and (4) they represent the variety of inputs the AI will encounter. This technique works because AI models are pattern-matching engines โ when you show a pattern, the model continues it. The approach bridges the gap between what you imagine and what the AI produces, often reducing the need for multiple iterations.
Summaryโ
- Including examples in your prompt is one of the most effective ways to guide AI output
- Examples clarify intent, set patterns, and define edge cases all at once
- Show the input-output pattern โ the AI will continue the pattern you demonstrate
- Use examples to define style, tone, format, and classification logic
- One concrete example is worth a hundred words of abstract description
- Examples work because AI models are pattern-matching engines
- Include 2-3 examples for most tasks โ enough to establish a pattern
- Make sure examples are consistent with each other in format and style
- Include edge cases in your examples to handle tricky situations