<claudexml/>
Classification · beginner

Sentiment classifier

Classify customer reviews as positive, neutral, or negative with few-shot examples.

You have an inbound stream of free-text reviews and want a single sentiment label per item for routing or analytics.

The prompt

Copy this verbatim. Replace the {{ … }} placeholders with your values.

<instructions>
Classify the review's sentiment. Return exactly one of: positive, neutral, negative.
Return only the lowercase label, no punctuation, no explanation.
</instructions>

<examples>
  <example><input>Loved it, will be back!</input><output>positive</output></example>
  <example><input>It was fine.</input><output>neutral</output></example>
  <example><input>Total waste of money.</input><output>negative</output></example>
</examples>

<review>{{ review_text }}</review>

Sample input

The food took 45 minutes to arrive cold.

Expected output

negative

Notes & tuning tips

  • Calibration: include at least one example per output class; skew in examples → skew in outputs.
  • Add a fourth class ("mixed") only if you need it — extra classes always hurt accuracy on the existing ones.
  • For a production version, also ask for confidence and route low-confidence items to humans.

What this example uses

Tags: <instructions> <examples> <example>

Patterns: few shot

Cite this page
Sentiment classifier. claudexml.com. https://claudexml.com/examples/sentiment-classifier/