BIO Tagging › Summary
Language AI HandbookAll chapters BIO Tagging › SummaryOne section · Sections in this chapter13 / 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
BIO tagging provides a standardized format for representing entity boundaries in sequence labeling tasks. The key concepts from this chapter:
The BIO scheme uses three prefixes: B (beginning) marks the first token of an entity, I (inside) marks continuation tokens, and O (outside) marks non-entity tokens. This encoding unambiguously represents entity boundaries, handling adjacent same-type entities correctly. The scheme's success stems from its completeness: three bits of information are both necessary and sufficient to reconstruct any flat entity annotation.
Extended schemes like BIOES add explicit end markers (E) and single-token markers (S) for stronger supervision and easier validation. BIOES trades a slightly larger label vocabulary for clearer boundary signals, which research has shown produces modest but consistent accuracy improvements in boundary-sensitive evaluations. The choice between BIO and BIOES involves a tradeoff between simplicity and boundary precision.
Conversion utilities transform between span annotations and per-token BIO tags. Reliable converters handle edge cases like single-token entities, adjacent entities, and sequence boundaries. Decoders must gracefully handle malformed sequences from model predictions, applying recovery strategies that maximize recall for downstream error analysis.
Validation and repair catch common errors like orphan I tags and type mismatches. Repair strategies can automatically fix many issues, improving downstream usability. Logging every repair is as important as applying it, because the repair log reveals systemic problems in annotation pipelines or model behavior.
Multi-label scenarios require extensions like multiple tag columns or layered encoding for nested entities. Standard BIO assumes non-overlapping annotations, and domains with extensive nesting, such as biomedical NER, often benefit from span-based approaches that handle overlaps natively.
Evaluation at the span level requires exact matching of both boundaries and type. A partial boundary error scores zero, which motivates careful attention to boundary conventions in annotation guidelines and BIOES encoding for models where boundary precision is critical.
Transformer integration requires aligning word-level BIO tags with subword tokenization by labeling only the first subword piece of each word and ignoring continuation pieces during loss computation. This alignment step is a required preprocessing component for any BERT-style NER system.
The next chapters apply BIO tagging to chunking and introduce the probabilistic models, Hidden Markov Models and Conditional Random Fields, that power production sequence labeling systems.
Key Parameters
When working with BIO tagging utilities, these parameters control conversion and validation behavior:
- tokens: List of string tokens representing the input sequence. Must align with span indices for correct conversion.
- spans: List of tuples in
(start_idx, end_idx, entity_type)format. Uses Python's exclusive end convention whereend_idxpoints to the position after the last entity token. - tags: List of BIO tag strings, one per token. Valid formats are
B-TYPE,I-TYPE, andO. - entity_type: String identifier for the entity category such as
PER,LOC, orORG. Appears as the suffix after the hyphen in BIO tags.
For BIOES conversion, two additional prefixes apply:
- S-TYPE: Marks single-token entities that do not need a B/I/E structure.
- E-TYPE: Marks the final token of multi-token entities.