Log inStart free
LESSON 8.05 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Special tokens and chat templates

Watch two chats become one padded batch of token IDs.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 8.05 · TOKENIZER BAY2 CHATS · 4 MESSAGES
01
Stage 1 of 6 · The messages
A chat is a list of messages. Each message has a role and text.
Explain it simply

You see two short chats, A and B. Each card is one message, with its role on the left. The role says who speaks: the user or the assistant.

Two chats, A and B. Each has a user message and an assistant answer.

wordsspecial tokensUNKPADtoken IDs, targets, next token
ABuserName a red fruit.assistantAn apple.userHej!assistantHello!the messageschat = [(user, text), (assistant, text)]ABuserName a red fruit.assistantAn apple.userHej!assistantHello!the messageschat = [(user, text), (assistant, text)]
Toy: 2 chats, a 24-token word vocabulary
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
mi=(rolei, texti)\sy{m}{data}{m_i} = (\text{role}_i,\ \text{text}_i)
m1=(user, Name a red fruit.)m_1 = (\text{user},\ \text{Name a red fruit.})

Each message pairs a role with its text.

Common mix-ups

MYTHA special token splits into pieces like normal text.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01Which template adds no BOS token at the start?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.