You are signed in. Close

You are signed out. Close

Thank you. Your subscription has started. Close

Thank you. You will get an email when a new comic comes out. Close

We could not confirm your payment. If you paid, use the link "Sign in" at the bottom of the page. Close

Something went wrong on our side. Please try again in a moment. Close

Previous episode System prompt: the hidden text an AI chatbot adds to your question

How ChatGPT and other AI chatbots answer your question

Tokens: the pieces an AI model gets instead of your words

An AI model never sees your words. First, a program cuts your message into small pieces called tokens. A token is not always a whole word. Why cut text into pieces at all?

  1. 1 Luckily, a program on the company's computers gets to the prompt first and cuts it into small pieces. Each piece is called a token.My plant is losing its leaves.Should I water it more?Myplantislosingitsleaves.ShouldIwateritmore?your question, in tokens

    Luckily, a program on the company's computers gets to the prompt first and cuts it into small pieces. Each piece is called a token.

  2. 2 A common word like "plant" stays whole. A rare one is cut wherever known pieces fit, even in the middle of a syllable.plantone tokenphilodendronphilodendronthree tokens

    A common word like "plant" stays whole. A rare one is cut wherever known pieces fit, even in the middle of a syllable.

  3. 3 Every piece, "phil" included, comes from one fixed list: the vocabulary. It holds whole words, word parts and single letters, each at a numbered place, its token ID.the vocabularytoken IDtoken13.30?6804plant15657leavesplant

    Every piece, "phil" included, comes from one fixed list: the vocabulary. It holds whole words, word parts and single letters, each at a numbered place, its token ID.

  4. 4 The program swaps each token for its token ID. Your question reaches the model as a row of numbers, after those of the system prompt.system promptyour question54446804382211591617156571318057357341148094530Numbersat last!

    The program swaps each token for its token ID. Your question reaches the model as a row of numbers, after those of the system prompt.

  5. 5 You picture a plant with leaves and soil. The model gets 6804, a place in a list, whose neighbour 6803 is "pected", the end of "unsuspected". Nothing in 6804 says that a plant has leaves.you6803pected6804plantall the modelgets

    You picture a plant with leaves and soil. The model gets 6804, a place in a list, whose neighbour 6803 is "pected", the end of "unsuspected". Nothing in 6804 says that a plant has leaves.

  6. Quick check

    A word no list holds.You type a brand-newword, "Zorblex".No list holds it.Can it still reachthe model?

    A word no list holds.

    Show the answer

    Yes. It is cut into smaller pieces that the vocabulary holds, down to single letters if needed.

  7. Go further

    Whose list it is, and what comes back out of the model.plantone list per companyEach company has its ownvocabulary. The one OpenAIpublished in 2024 holdsabout 200,000 tokens. Thepieces here come from itsoilthe answer, in tokensThe answer also comes outof the model as token IDs,turned back into text onthe way to you

    Whose list it is, and what comes back out of the model.

Next episode Embeddings: how a list of numbers can hold the meaning of a word

Share this comic

More comics