Lesson 5 of 25
The Secret of Silent Suggestion (Few-Shot Prompting)
Instead of describing the output you want, show two or three finished examples and let the model infer the pattern. This works because a worked example carries decisions that adjectives cannot - exactly where the line falls between two categories, how an edge case is handled, how long a sentence should be. It is the difference between telling someone to write concisely and handing them a paragraph you consider concise.
Wrap each demonstration in <example> tags, with the input and output labelled inside. This is the single most useful habit on Claude: tagged examples are unambiguously reference material, so none of your sample text gets mistaken for the item to process - which is the usual way few-shot prompts go wrong when the examples are long. Put all the examples first and the actual item last, and add a <rules> block stating what the examples are meant to teach.
- Wrap each demonstration in <example> with input and output.
- Examples first, the real item last.
- Add a <rules> block naming what the examples teach.
- Check your examples do not contradict each other.
- Include an example of the edge case and of refusal.
Instead of
Look at this customer review and tell me if it's positive, negative, or neutral. The review is: 'The product arrived on time, but the quality wasn't what I expected.'
Perplexity version
<examples> <example> <review>I absolutely love this product. It has changed my daily routine.</review> <sentiment>Positive</sentiment> </example> <example> <review>Complete waste of money. Broke after one day.</review> <sentiment>Negative</sentiment> </example> <example> <review>Delivery was fast and the item matched the description, but it is overpriced for what it is.</review> <sentiment>Mixed</sentiment> </example> <example> <review>Received the order.</review> <sentiment>Neutral</sentiment> </example> <example> <review>The kurta fit perfectly but the colour had faded by the second wash.</review> <sentiment>Mixed</sentiment> </example> <example> <review>Delivery to Hyderabad took eleven days. Product itself is fine.</review> <sentiment>Mixed</sentiment> </example> </examples> <rules> - Praise and complaint in the same review is Mixed, never Neutral. - Neutral is only for reviews expressing no opinion at all. - A delivery complaint with a satisfactory product is Mixed. - Output the label alone. No explanation unless I ask. - If a review genuinely does not fit any of the four labels, return Unclear rather than forcing it. I would rather review twenty Unclears than trust a wrong label. </rules> <task> Classify this review using the pattern and rules above: <review>The product arrived on time, but the quality wasn't what I expected.</review> Then tell me, in one line, which of the examples you relied on most to decide - I want to know whether my examples are actually teaching what I think they are. </task>
Instead of
Please extract the person's name, the company they work for, and their job title from this sentence: 'We are pleased to announce that Priya Sharma will be joining our team as the new Head of Marketing at Innovate Corp.'
Perplexity version
<examples>
<example>
<text>The keynote will be given by Raj Patel, CEO of FutureTech Solutions.</text>
<output>{"name": "Raj Patel", "company": "FutureTech Solutions", "title": "CEO"}</output>
</example>
<example>
<text>Our quarterly review will be led by Anita Desai, our firm's Managing Director.</text>
<output>{"name": "Anita Desai", "company": null, "title": "Managing Director"}</output>
</example>
<example>
<text>Welcome to Vikram Reddy and Sneha Kulkarni, who join Zephyr Labs as Design Lead and Head of Product respectively.</text>
<output>[{"name": "Vikram Reddy", "company": "Zephyr Labs", "title": "Design Lead"}, {"name": "Sneha Kulkarni", "company": "Zephyr Labs", "title": "Head of Product"}]</output>
</example>
<example>
<text>Dr. S. Ramanathan has been appointed to the board.</text>
<output>{"name": "Dr. S. Ramanathan", "company": null, "title": "Board Member"}</output>
</example>
<example>
<text>The event was a great success and we thank everyone who attended.</text>
<output>null</output>
</example>
</examples>
<rules>
- company is JSON null, unquoted, when the text does not name it - never the string "null".
- Several people produce an array; one person produces an object.
- No person named produces null.
- Never infer a company the text does not state, even where it is obvious from context.
- Preserve names exactly as written, including honorifics and initials.
- Output valid JSON only. No prose, no code fence, no commentary.
</rules>
<task>
Extract from this text, following the examples and rules above:
<text>We are pleased to announce that Priya Sharma will be joining our team as the new Head of Marketing at Innovate Corp.</text>
</task>
Instead of
Rewrite the following sentence in a very short, simple, and powerful style, like Ernest Hemingway. The sentence is: 'Despite the fact that he was feeling quite tired, he knew that he had to continue on his journey if he wanted to reach his destination by morning.'
Perplexity version
<style_examples> <example>The sun was hot. The road was long. He walked on.</example> <example>The coffee was bitter. Rain beat the window. The phone did not ring.</example> <example>She did not look back. The train left. That was all.</example> </style_examples> <anti_examples> <example reason="overwrought - decorates instead of stating">The scorching, merciless sun beat down relentlessly upon the endless, winding road that stretched before him.</example> <example reason="empty - terse but has thrown away the concrete detail">It was hot. He walked. He was tired.</example> </anti_examples> <rules> - The anti-examples define the two failure modes. The second matters most: this style is spare, not vacant. It keeps concrete physical detail and refuses to decorate it. - Do not use the sample sentences' own images - no sun, no road, no coffee, no train. Match the method, not the furniture. </rules> <task> First, state the three rules you have inferred from the style examples - sentence length, what is cut, what is kept. I want to check your reading before you apply it. Then rewrite this sentence in that style: <target>Despite the fact that he was feeling quite tired, he knew that he had to continue on his journey if he wanted to reach his destination by morning.</target> Give three versions - about 8 words, about 15, about 25 - so I can see how the style holds as it loosens. For each, note in one line what you had to give up at that length. </task>