Sub topic 1
Defining the annotation task
Every later step in an annotation project depends on the task definition: the label schema, the guidelines, annotator training, and the agreement scores. A vague task produces vague labels, and no statistic can repair that afterwards. This chapter covers how to define the task before any text is labeled.
Prerequisites
This chapter assumes you have:
- Basic Python, including lists, dictionaries and functions.
- Familiarity with common NLP tasks such as text classification and named entity recognition.
- Basic probability, such as the meaning of a proportion and of chance.
You do not need any annotation experience. Later chapters use the Python code from the plan to compute agreement. This chapter uses only small checks.
What an annotation task is
An annotation task is a precise statement of three things:
- The unit. This is the item an annotator labels, such as a whole review, a sentence, a token, or a character span.
- The question. This is what the annotator decides about the unit, such as "What is the sentiment toward the product?"
- The answer space. This is the set of allowed outputs. It is a fixed list of labels, a rating scale, or free-form spans.
Writing these down forces decisions that are otherwise made silently and differently by each person. Two annotators who both "label sentiment" may be answering different questions. One may judge the author's feeling and the other the effect on the reader.
Start from the downstream use
Define the task backwards from the model or analysis that will consume the labels. Ask these questions first:
- What decision will the labeled data support? Examples are routing support tickets, training a classifier, or measuring public opinion.
- Which errors are costly? Missing a complaint may matter more than mislabeling praise.
- What will the model see at prediction time? If the model sees only the text, do not ask annotators to use outside context that the model will never have.
A common failure is to label what is easy to label rather than what is needed. For example, a team wants to detect urgent support tickets but labels topic instead, because topic is easier to agree on. The resulting agreement is high and the data is useless.
Choose the unit of annotation
The unit affects both difficulty and how you measure agreement.
| Unit | Example task | Typical agreement measure |
|---|---|---|
| Whole document | Topic or sentiment of a review | Cohen's or Fleiss' kappa |
| Sentence | Claim vs. opinion | Cohen's or Fleiss' kappa |
| Token | Part-of-speech tag | Kappa per token |
| Span | Named entities | Span-level F1 |
| Pair of texts | Do two questions mean the same thing? | Kappa on the pair label |
Three points about units matter in practice.
- Fixed vs. open units. Kappa needs a fixed set of items that everyone labels. In span tasks, annotators choose the boundaries themselves, so the items are not fixed. That is why the plan treats spans separately.
- Context. Decide how much surrounding text an annotator sees. A sentence shown alone may be ambiguous, but showing the full thread makes the task slower. Record the choice, because it changes the labels.
- Length limits. Long documents tire annotators and lower quality. Consider splitting or truncating, and apply the same rule to every item.
Decide what kind of answer you need
The shape of the answer space determines which agreement measures apply.
- Nominal labels have no order, such as
pos,neg,neu. Plain kappa fits. - Ordinal labels have an order, such as a 1 to 5 rating. A disagreement of 1 versus 5 is worse than 4 versus 5, so a weighted measure fits better.
- Multi-label tasks let one item carry several labels at once. These need one yes/no decision per label, or a measure built for sets.
- Spans mark a region of text and give it a label. These need a matching rule for what counts as the same span.
Pick the simplest form that serves the downstream use. A five-point scale gives finer information than three classes, but annotators usually agree less on it.
Pin down the scope and edge cases
Most disagreement comes from the boundaries of the task, not from the clear cases. Before drafting a schema, list the situations that will test those boundaries. For a sentiment task they include:
- Sarcasm, where the surface words and the intended meaning conflict.
- Mixed opinions, such as "great screen, terrible battery".
- Questions and neutral reports of facts, such as "The phone ships Tuesday."
- Text in another language, or text that is too short or garbled to judge.
For each case, decide now whether it gets a label, a special tag such as unclear or skip, or exclusion from the dataset. An unclear option often helps. Without it, annotators guess, and guesses show up as noise.
Choose the sampling and size of the data
The set of items you annotate also belongs to the task definition.
- Source. State where the text comes from and over what dates. A model trained on product reviews from 2018 may fail on 2026 chat messages.
- Sampling. Random sampling keeps the natural label distribution. Targeted sampling, such as oversampling rare labels, gives you more examples of hard classes but changes the prevalence. Prevalence affects kappa, as a later chapter shows. Record which method you used.
- Size. Estimate the budget as items times annotators times seconds per item. Plan for several annotators per item, at least on a subset, because agreement can only be measured on items labeled more than once.
- Privacy and rights. Check that you may show the text to annotators. Remove or mask personal data when the task does not need it.
How the planning steps connect
The task definition is the first step in a chain. Each step produces something the next one needs.
The loop from agreement back to guidelines is the point of the pilot. You expect to revise the definition. A change to the task itself, such as the unit or the question, costs far more once annotators have started, so settle it as early as you can.
Write the task definition as a short spec
Keep the definition in one document that everyone can read. A short spec has these parts:
- Purpose. One sentence on what the labels will be used for.
- Unit and context. What is labeled and what the annotator can see.
- Question. The exact wording shown to annotators.
- Answer space. The labels, their type (nominal, ordinal, span), and special tags.
- Data. Source, sampling method, and expected size.
- Annotation plan. Number of annotators per item and the planned agreement measure.
You can also keep the spec in code so that tools and checks share a single source of truth. The following example records a task and validates a set of labels against it. It runs as shown.
from dataclasses import dataclass, field
@dataclass
class AnnotationTask:
name: str
unit: str
question: str
labels: list
scale: str = "nominal"
special_tags: list = field(default_factory=lambda: ["unclear"])
def allowed(self):
return set(self.labels) | set(self.special_tags)
def validate(self, annotations):
"""Return the (index, label) pairs that are not allowed."""
ok = self.allowed()
return [(i, a) for i, a in enumerate(annotations) if a not in ok]
task = AnnotationTask(
name="review-sentiment",
unit="one product review",
question="What is the overall sentiment of the review toward the product?",
labels=["pos", "neu", "neg"],
)
batch = ["pos", "neg", "neutral", "neu", "unclear", "NEG"]
print(task.validate(batch))The output is [(2, 'neutral'), (5, 'NEG')]. Catching a misspelled or differently cased label here is cheap. If such labels reach the agreement calculation, they count as extra categories and lower the score for no real reason.
Common mistakes
- Mixing questions. One task asks about sentiment and sarcasm and topic together. Split these into separate tasks or separate label sets.
- Unclear unit. Annotators label a whole thread in some cases and single messages in others.
- No exit label. Annotators with no
unclearoption force a guess. - Defining by the model's needs only. The task is unanswerable for humans, such as predicting a hidden author trait from one sentence.
- Changing the task mid-project. Labels from before and after the change cannot be pooled without relabeling.
- Skipping the downstream check. The team measures agreement but never checks that the labels answer the original need.
Test the definition before building on it
Before moving to the schema, try the definition on yourself and one colleague.
- Pick 20 items at random.
- Label them independently, each using only the written spec.
- Compare the answers and list every place you differ.
Each difference points to a gap in the spec. If you cannot agree on more than a few items, the question is probably too broad or the answer space is wrong. This informal check is not the formal pilot round, which comes later with trained annotators and agreement measurement. It only keeps obvious flaws from reaching it.
Exercise
A team wants to train a model that flags urgent customer-support emails. They define the task as "label each email's topic: billing, shipping, or account." Annotators agree well. What is wrong with this task definition, and how would you revise it?
Show answer
The question does not match the downstream use. Topic is easy to agree on, but it does not tell the model which emails are urgent. The team should start from the decision the labels support and ask annotators about urgency, for example with the labels urgent, not_urgent and unclear, plus written criteria for what makes an email urgent (a deadline, a service outage, a safety issue). They should also fix the unit (one email or a whole thread) and decide whether the annotator sees the subject line.
Exercise
Why does the unit of annotation affect which agreement measure you can use? Give one example where kappa does not apply directly.
Show answer
Kappa needs a fixed set of items that every annotator labels, so that each item has a pair of labels to compare. When the unit is a document or sentence, the items are fixed and kappa applies. In a span task such as named entity recognition, annotators choose the boundaries themselves, so there is no fixed item list. One annotator may mark "New York City" and another "New York". Such tasks use a span-matching rule and an F1 score instead.