liveBook · Manning

Special token

As explained in Build AI-Enhanced Web Apps

A control token is a reserved token that marks boundaries or conveys instructions about the structure, behavior, or formatting of a language-model sequence.

A special token is a reserved control token that marks sequence boundaries or conveys instructions about behavior, structure, or formatting. It gives developers a way to shape how an LLM interprets and produces a prompt sequence. section 5.1.1 section 5.6

Use special tokens to:

  • Mark transitions between sequence content, such as the beginning or end of a prompt. section 5.1.1
  • Identify conversational roles, such as user and assistant messages. section 5.1.1
  • Communicate rules or instructions that guide model behavior and output. section 5.6

A marked conversation sequence

A sequence can use markers such as <|startoftext|>, <|user|>, <|assistant|>, and <|endoftext|> around a question and answer. These markers make the sequence structure explicit before the model processes it. section 5.1.1

<|startoftext|>
<|user|> What is the capital of France?
<|assistant|> The capital of France is Paris.
<|endoftext|>

Inspect the concrete sequence of start, role, and end markers used to illustrate control-token formatting. section 5.1.1

How Build AI-Enhanced Web Apps covers it

How deep it goes
Defines control tokens and shows a formatted sequence, but stops short of implementation details for creating or registering them.
Examples
Uses start-of-text, user, assistant, and end-of-text markers in a formatted question-and-answer sequence.
What it assumes
Assumes familiarity with prompts and tokenization while connecting numerical token IDs with LLM processing and human-readable output.
What you can do after
Apply it by structuring prompt sequences with markers that communicate boundaries, roles, rules, or output behavior.
How it connects
Connects special tokens with tokenization, prompts, system prompts, message prompts, and maximum token limits.

Also explained in

Compare how 5 books explain special token →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI-Enhanced Web Apps. The section links point to the parts of the book it draws on.