BIO Tagging › BIO Tagging
Language AI HandbookAll chapters BIO Tagging › BIO TaggingOne section · Sections in this chapter1 / 14 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Sequence labeling tasks like named entity recognition face a fundamental challenge: how do you represent multi-word entities using per-token labels? The sentence "New York City is beautiful" contains three tokens that together form a single location entity. Assigning all three the label "LOC" creates ambiguity. Does "New" start a new entity, or does it continue one that began earlier? Are "New," "York," and "City" three separate locations, or one?
BIO tagging solves this problem elegantly. The scheme uses a small set of prefixes to encode entity boundaries directly in the labels. B marks the beginning of an entity, I marks inside (continuation), and O marks outside (no entity). With BIO tags, "New York City" becomes B-LOC I-LOC I-LOC, unambiguously marking a single three-token entity.
The idea is deceptively simple. Three letters carry enough information to reconstruct any flat entity annotation from scratch. Any system reading the tag sequence can tell exactly where each entity starts, where it continues, and where the text returns to non-entity territory, without any additional context or lookup table. That parsimony, combined with perfect expressiveness for non-overlapping spans, explains why BIO tagging became the standard format for nearly every NER dataset and evaluation benchmark produced in the past two decades.
This chapter explores BIO tagging from its basic mechanics through practical implementation. You will learn the standard BIO scheme and its variants, implement converters between span annotations and BIO tags, build decoders that extract entities from tagged sequences, and handle the edge cases that arise in real-world tagging scenarios. Building on the entity types from the Named Entity Recognition chapter, here we focus on the encoding mechanism that makes those entity types usable in sequence models. The concepts here apply directly to the Hidden Markov Model and Conditional Random Field chapters, where you will see how these tag sequences get used as training targets and how transition constraints between tags can be learned from data.