stop tokens
**Stop tokens** is the **special token IDs that instruct the decoder to terminate generation immediately when emitted** - they provide low-level termination control at token granularity.
**What Is Stop tokens?**
- **Definition**: Model-recognized token markers treated as hard completion boundaries.
- **Typical Examples**: EOS markers and custom control tokens reserved by tokenizer vocabulary.
- **Execution Behavior**: When generated, decoding loop exits without adding further tokens.
- **Scope**: Used internally by runtimes and exposed through API configuration in some systems.
**Why Stop tokens Matters**
- **Termination Precision**: Enables deterministic ending behavior independent of text matching.
- **Format Integrity**: Helps close structured outputs cleanly at expected boundaries.
- **Runtime Simplicity**: Token-based checks are fast and reliable compared with string scans.
- **Safety**: Supports strict cutoffs for guarded completion flows.
- **Interoperability**: Aligns behavior across serving backends using shared token IDs.
**How It Is Used in Practice**
- **Vocabulary Mapping**: Verify stop-token IDs against tokenizer version and model checkpoint.
- **Priority Rules**: Define interactions between stop tokens and stop sequences.
- **Regression Tests**: Validate no premature stops under multilingual and code-generation prompts.
Stop tokens is **a foundational primitive for deterministic decode termination** - correct token mapping is essential to avoid truncation or runaway output.