Sub topic 1
Start with the question: goals and a label taxonomy
Prerequisites
This chapter assumes you can read basic Python (lists, dictionaries, functions) and JSON. You should also have a general idea of what a large language model is. Later chapters use precision and recall, so you should know those terms. This chapter has no model calls.
Why start with the question
Feedback analysis fails most often because nobody decided what the output was for. A team runs sentiment scoring on 20,000 reviews and gets "68% positive." That number does not tell anyone what to change.
Start from a decision instead. Someone must be able to do something differently depending on the answer.
| Goal | Question the analysis answers | Who acts on it |
|---|---|---|
| Reduce support load | Which problems generate the most negative messages this month? | Support lead |
| Prioritise the roadmap | Which features do unhappy customers mention most? | Product manager |
| Track a release | Did complaints about delivery fall after the carrier change? | Operations |
Write each question as a sentence with a measurable answer, a time window, and a named owner. "What do customers think?" is too vague. "Which three themes account for most negative reviews in the last 30 days?" is usable.
From question to labels
A label taxonomy is the fixed list of categories you assign to each piece of feedback, with a written definition for each. The question tells you which labels you need. The question about delivery needs a delivery theme. It does not need a theme for every topic a customer might raise.
Most feedback projects use at least two label sets:
- Sentiment: how the writer feels overall. Choose one value per review.
- Themes: what the review is about. A review can have several.
Rules for a good taxonomy
- Make each label separate in meaning. If a reviewer cannot tell
product_qualityfromusability, a model cannot either. Write a one-line definition and an example for each. - Keep it small. Five to ten themes is a practical range. Every extra label lowers agreement between annotators and leaves fewer examples to check.
- Add an
otherlabel. Without it, the model forces unrelated feedback into the wrong theme. A growingothershare tells you the taxonomy needs revising. - Allow
mixedsentiment. "Love the screen, hate the delivery" is neither positive nor negative. - Decide the unit. Labelling a whole review, a sentence, or one aspect of a product are different tasks. Later chapters cover aspect-level labelling. Pick one unit for now.
A starting set for an online shop:
| Label set | Allowed values |
|---|---|
| sentiment | positive, negative, neutral, mixed |
| themes | pricing, delivery, product_quality, support, usability, other |
Put the taxonomy in code
Keep the taxonomy in one place in your code and validate against it. The same constants then serve the prompt, the output checks, and the evaluation later.
SENTIMENTS = {"positive", "negative", "neutral", "mixed"}
THEMES = {"pricing", "delivery", "product_quality", "support", "usability", "other"}
def validate_labels(record):
"""Return a list of problems found in one labelled review."""
problems = []
if record.get("sentiment") not in SENTIMENTS:
problems.append("bad sentiment: " + str(record.get("sentiment")))
themes = record.get("themes", [])
if not themes:
problems.append("no themes assigned")
for theme in themes:
if theme not in THEMES:
problems.append("unknown theme: " + str(theme))
return problems
print(validate_labels({"sentiment": "mixed", "themes": ["delivery", "pricing"]}))
print(validate_labels({"sentiment": "angry", "themes": ["shipping"]}))The first call prints an empty list. The second reports the invalid sentiment and the unknown theme.
Common errors
- Starting with the tool. Choosing a model before writing the question leads to outputs nobody uses.
- Overlapping labels. Two labels that cover similar content split the same complaint between them and hide its true size.
- Changing the taxonomy silently. If you rename or split a theme midway, trends before and after the change cannot be compared. Version the taxonomy and re-label old data when it changes.
- Treating the taxonomy as final. Review the
otherbucket each cycle and add a theme when it grows large.
Exercise
A product manager asks you to "analyse our app store reviews." Write one specific question, name its owner, and propose a sentiment label set and at least four themes. Explain why you included an other theme.
Show answer
One example: "Which themes appear most in negative reviews of the last 30 days, and did login complaints fall after version 4.2?" Owner: the product manager. Sentiment: positive, negative, neutral, mixed. Themes: login, performance, pricing, usability, support, other. The other theme stops the model from forcing unrelated feedback into a wrong theme. Its share also signals when a new theme is needed.