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 Tokens: the pieces an AI model gets instead of your words

How ChatGPT and other AI chatbots answer your question

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

For an AI model, a token is only an ID number, like a line number in a long list. This number says nothing about what the word means. So how does the model know that "cat" and "dog" are close in meaning?

  1. 1 The model has a fix for that: a huge table, with one row for each token of the vocabulary. It uses a token ID for one thing only: to find that token's row.the model's table6804Row 6804.There you are.

    The model has a fix for that: a huge table, with one row for each token of the vocabulary. It uses a token ID for one thing only: to find that token's row.

  2. 2 That row holds a long list of numbers, and from now on, it stands for your "plant". Such a list is a vector, and a token's vector is its embedding.plant0.21−0.530.080.74−0.19the embedding of "plant"example numbers

    That row holds a long list of numbers, and from now on, it stands for your "plant". Such a list is a vector, and a token's vector is its embedding.

  3. 3 Tokens that turn up in the same kind of sentences get close embeddings. "plant" and "leaves" hold numbers near each other, and "invoice" holds very different ones.plant0.21−0.530.080.74leaves0.25−0.470.120.69invoice−0.810.36−0.640.02closefarexample numbers

    Tokens that turn up in the same kind of sentences get close embeddings. "plant" and "leaves" hold numbers near each other, and "invoice" holds very different ones.

  4. 4 Rono typed none of these numbers, and nor did anyone else. They were worked out from huge amounts of text, before your question ever came.RonoI didn't typea single one.

    Rono typed none of these numbers, and nor did anyone else. They were worked out from huge amounts of text, before your question ever came.

  5. 5 So inside the model, your question is only numbers, with no book or web page to look in. Where does "Check the soil first" come from? And why can the same machine, in the very same chat, name a book that was never written?Check thesoil first.No book in here.Only numbers.?

    So inside the model, your question is only numbers, with no book or web page to look in. Where does "Check the soil first" come from? And why can the same machine, in the very same chat, name a book that was never written?

  6. Quick check

    One word, two meanings.Your question has"plant". A text abouta power plant has"plant" too. Does themodel get two differentlists from its table?

    One word, two meanings.

    Show the answer

    No. One token, one row: both get the same embedding from the table.

  7. Go further

    How long an embedding is, and the real neighbours of "plant".how long the list is512 numbers per token ina model published in 2017.4,096 in Mistral 7B,a 2023 modelplantthe neighbours of "plant"Measured in the table ofGPT-2 (OpenAI, 2019): therows nearest to "plant"include "flower","vegetation" and "factory"

    How long an embedding is, and the real neighbours of "plant".

Next episode Attention: how an AI model works out what "it" means

Share this comic

More comics