Sentiment analysis prompt builder
A single “positive / negative” label throws away most of what a review or support ticket is telling you. This builder writes an LLM prompt that performs aspect-based sentiment analysis: it scores each facet you care about, estimates emotional intensity, identifies the opinion target, and returns the result in a structured format you can parse. You define the dimensions; the prompt enforces them.
How it works
You supply the text type, the aspects to evaluate, a numeric scale, and an output format. The builder assembles a system-style instruction that defines the scale precisely, lists the aspects to score, and pins the output schema — JSON or a table. It also adds standing rules: report per-aspect polarity, flag sarcasm, give an intensity score, and use a neutral midpoint rather than forcing a positive/negative choice. The result is a reusable prompt you drop into a batch pipeline or a one-off analysis.
Why aspect-level scoring beats a single label
A 4-star product review might say: “The product itself is excellent but delivery took two weeks and customer support never responded.” A single “positive” label misses everything useful here. Aspect scoring gives you:
- Product quality: positive
- Delivery speed: negative
- Customer support: negative
- Overall: mixed
This is the data that drives action: a supply chain team fixing delivery speed needs to see delivery-sentiment trending negative across hundreds of reviews, not “overall sentiment is 3.2 out of 5.” The generated prompt asks the model to score each aspect you define, so the output is directly usable for operational decisions.
Designing your aspect taxonomy
The aspects to score should match the levers you actually control. Common frameworks for different use cases:
| Use case | Typical aspects |
|---|---|
| E-commerce product | Quality, value for money, delivery, packaging, returns |
| SaaS product | Onboarding, performance, support, pricing, integrations |
| Restaurant review | Food quality, service, ambience, value, wait time |
| Support ticket | Resolution speed, agent helpfulness, solution accuracy |
Start with four to six aspects. More than eight is usually noise and makes the output harder to aggregate. You can always add aspects later as you see patterns in your data.
Handling sarcasm and mixed sentiment
The prompt includes an explicit instruction for sarcasm detection and mixed sentiment. These are genuinely hard for LLMs without it:
Sarcasm: “Oh, great, it arrived in pieces — just what I wanted.” Without the sarcasm flag, this reads as positive. The prompt asks the model to flag suspected sarcasm and note the interpreted sentiment.
Mixed sentiment: A single review sentence can be positive and negative for the same aspect: “The battery lasts forever, but it takes nine hours to charge.” The prompt handles this with a per-aspect confidence score alongside the polarity label.
Tips and example
- Name aspects the way customers do. “Shipping speed” and “delivery” may need to be separate columns depending on your product.
- Pick the smallest scale that captures variance. A 5-point scale is usually enough; 10-point only helps when you need fine-grained ranking.
- Use JSON for pipelines, tables for eyeballing. JSON parses cleanly into a database; the table format is easier to skim by hand.
- Batch it. Feed many reviews at once and ask for one JSON array — the prompt already requests one object per input.
- Validate on a labeled sample first. Pick 20 reviews where you know the correct aspect sentiment and check the model’s accuracy before scaling up.