Home Knowledge Base BOS (Beginning of Sequence) Token

BOS (Beginning of Sequence) Token is a special token that marks the start of an input sequence in transformer models — providing a consistent initial context that enables the model to recognize sequence boundaries, initialize its hidden state from a known starting point, and distinguish between multiple independent sequences within the same batch, with different model families using different BOS conventions ([CLS] in BERT, in LLaMA, <|endoftext|> in GPT-2).

What Is the BOS Token?

BOS Tokens Across Model Families

ModelBOS TokenToken IDAlso Used As
BERT[CLS]101Classification head input
GPT-2<endoftext>50256Both BOS and EOS
LLaMA / LLaMA 21Sequence start only
T5(none explicit)N/AUses task prefix instead
Mistral1Same as LLaMA convention
Gemma2Sequence start
ChatML format<im_start>variesMessage boundary

BOS Token Functions

BOS tokens are the explicit sequence initialization markers that transformer models depend on for boundary detection and consistent starting context — a small but essential piece of the tokenization protocol that ensures models correctly process the beginning of every input sequence across batched inference, chat conversations, and classification tasks.

bos tokenbeginning of sequencespecial token

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.