Sub topic 2
Designing a Label Schema
Assume you know basic Python, common NLP tasks such as text classification and named entity recognition, and basic probability. A label schema is the set of labels, definitions, and rules that annotators use to mark text. A good schema turns a vague question into decisions that different people can repeat.
Start with the annotation unit
First decide what one annotation covers. The unit might be:
- A whole document, such as a support ticket.
- A sentence, such as one sentence in a review.
- A token, such as one word.
- A text span, such as the characters that form a person's name.
- A relation between two spans, such as an employee belonging to a company.
The unit affects the labels and the agreement measure you can use later. For example, document classification gives each item one or more labels. Named entity recognition marks spans and assigns each span a type.
Write the task as a decision question:
> Given this item, what property should the annotator identify?
For sentiment classification, the question could be, “What is the overall sentiment expressed by this review?” Avoid combining several questions in one label unless the task requires it.
Define labels with boundaries
Each label needs a short name, a precise definition, and examples. State what qualifies and what does not qualify. Include difficult boundary cases, because common examples rarely cause disagreement.
For a three-class sentiment task, a schema might look like this:
| Label | Definition | Include | Exclude |
|---|---|---|---|
| `pos` | The writer expresses an overall favorable attitude | Praise, satisfaction, recommendation | A factual statement with no attitude |
| `neg` | The writer expresses an overall unfavorable attitude | Complaints, disappointment, warnings | A mention of a negative event without evaluation |
| `neu` | No clear favorable or unfavorable attitude is expressed | Factual descriptions, balanced statements | Weak praise or criticism that changes the overall judgment |
Decide whether labels are mutually exclusive. Mutually exclusive labels mean an item can receive only one label. They simplify analysis and are appropriate when the task asks for one overall category.
Decide whether the labels are exhaustive. An exhaustive schema gives every valid item a label. Add an unclear or other label only when annotators genuinely need it. Such labels can hide problems in the definitions if used too often.
Choose single-label or multi-label annotation
Use single-label annotation when categories represent alternatives. Use multi-label annotation when several properties can be true at the same time.
For example, a support message could be both billing and urgent. In that case, define whether annotators may select both labels and whether at least one label is required. Also specify whether one label takes priority when the interface allows only one answer.
For ordered categories, record the order explicitly. A rating schema such as 1 = very negative through 5 = very positive is ordinal: the distance between labels has meaning, even if the distances are not perfectly equal.
Validate the schema before full annotation
Test the draft schema on a small, varied sample. Ask annotators to explain not only their labels but also the rule they used. Revise definitions when disagreements reveal an ambiguity rather than treating every disagreement as annotator error.
A simple Python check can catch invalid single-label outputs:
allowed = {"pos", "neg", "neu"}
labels = ["pos", "neu", "neg", "positive"]
invalid = [label for label in labels if label not in allowed]
if invalid:
raise ValueError(f"Unknown labels: {invalid}")
print("All labels are valid.")The check validates spelling, not meaning. Meaning requires examples, written rules, and a pilot annotation round.
Exercise
You are labeling messages as bug, feature_request, or question. A message says, “Could you add dark mode, and is it available on mobile?” Should it receive one label or two? What schema decision must you document?
Show answer
It should receive two labels if the task allows multi-label annotation, because it contains both a feature request and a question. If the task requires one label, document a priority rule, such as labeling the user's main requested action, and apply that rule consistently.