Notes

Sequence Labeling

Some prediction problems aren’t about assigning one label to a whole item—they’re about assigning a label to each step in a sequence. That’s what makes sequence labeling feel different: the “answer” is a string of labels that lines up with the input.

What it is and what makes it tricky

Sequence labeling is a supervised learning task where the input is an ordered sequence (tokens in text, time steps in sensor data, events in a log) and the target is a label for each position. The key challenge is that labels are not independent: the best label for one position depends on neighboring positions. For example, in named-entity recognition, “New” is much more likely to be part of a location if the next token is “York”. A model that predicts each label in isolation misses this structure and produces inconsistent outputs.

How models capture label dependencies

Classic approaches explicitly model transitions between labels. A Conditional Random Field (CRF) learns both (1) how input features suggest a label at each position and (2) which label sequences are plausible (e.g., “I-PER” shouldn’t start an entity). Modern neural systems often combine a contextual encoder (like a BiLSTM or Transformer) with a CRF decoding layer to enforce coherent sequences.

Where you see it in practice

  • Spam and email parsing: label each token as header, body, signature, URL, etc.
  • Medical text: tag symptoms, medications, and dosages token-by-token.
  • Fraud detection over time: label each transaction in a customer’s timeline as normal/suspicious.
  • Customer support: label each message in a chat as greeting, problem description, resolution step.

It matters because evaluation, decoding, and even the loss function depend on sequence structure; treating it like ordinary classification can inflate errors through impossible or inconsistent label patterns.

Sequence labeling is a supervised learning task that assigns a label to each element in an input sequence, producing an output sequence aligned with the input (e.g., tagging each word in a sentence with a part-of-speech or named-entity tag). It matters because many real-world problems require modeling dependencies across positions; treating elements independently breaks contextual consistency and reduces accuracy in tasks like NLP, bioinformatics, and time-series annotation.

Imagine you’re reading a sentence and putting little sticky notes above each word: “person,” “place,” “verb,” “date,” and so on. That’s the basic idea of Sequence Labeling: you take something that comes in order (a sequence), like words in a sentence, and you assign a label to each part.

In supervised learning, the AI learns from examples where the “right” labels are already provided. This matters because many real problems are naturally sequential: highlighting names in emails, tagging symptoms over time in medical notes, or marking which parts of a credit-card history look normal versus suspicious.