What are tokens and embeddings in AI? A beginner's guide

An AI model can't read letters. It reads numbers. Here is how your text becomes tokens, how tokens become embeddings, and how embeddings differ from a model's weights.

Diagram of the sentence 'I love pizza!' being processed. Step 1 splits it into four tokens: I, love, pizza and an exclamation mark. Step 2 swaps each token for a number ID, such as 1842 for love. Step 3 swaps each ID for a column of decimal numbers, its embedding. The columns go into a box labelled LLM, which only ever sees numbers.
Fig. 1 — Text becomes tokens, tokens become ID numbers, and IDs become embeddings: the lists of numbers an LLM actually reads.

When you type “I love pizza!” into a chatbot, the model on the other side never sees the letters I, l, o, v, e. A computer model can only do maths, and you can’t do maths on letters. So before a single word reaches the model, your text is turned into numbers.

That happens in two steps. First, the text is cut into small pieces called tokens. Then each token is swapped for a list of numbers called an embedding. Those lists are what the model actually reads.

This guide explains both steps in plain English, and then clears up a question that confuses many people: if embeddings are numbers the model learned, and weights are also numbers the model learned, what is the difference? You don’t need any maths or coding background. If you are new to LLMs, our guide to what a large language model is is a good place to start.

What is a token?

A token is a small piece of text that an AI model treats as one unit. A token is often a whole word, but it can also be part of a word, a single character, a punctuation mark, or a word together with the space in front of it.

For example, “I love pizza!” might become four tokens:

  • I
  • ␣love (the word with its space in front)
  • ␣pizza
  • !

(We use ␣ to show a space, so you can see it.) Many tokenizers attach the space to the start of the next word, so ␣love and love are actually two different tokens.

As a rough rule for English, 100 tokens is about 75 words. A token is, on average, a little shorter than a word.

What is tokenization?

Tokenization is the process of splitting text into tokens. The tool that does it is called a tokenizer, and every model comes with its own.

A tokenizer has a fixed list of all the tokens it knows, called its vocabulary. Modern LLMs have vocabularies of roughly 50,000 to 250,000 tokens. Every piece of text, in any language, has to be cut into pieces from that list.

Here is the clever part. Common words get a token of their own. Rarer words are built from smaller, familiar pieces:

Four words being split into tokens. 'cat' stays as one token. 'Tokenization' becomes two tokens, Token and ization. 'unbelievable' becomes three tokens, un, believ and able. 'strawberry' becomes three tokens, str, aw and berry.
Common words stay whole; rare words are built from smaller pieces. Real splits vary from model to model.

How does a tokenizer decide which pieces to keep? Most modern ones use a method called byte-pair encoding (BPE), or something close to it. In simple terms:

  1. Start with single characters as the only tokens.
  2. Look through a huge amount of text and find the pair of tokens that appears next to each other most often, such as t + h.
  3. Glue that pair into a new token, th, and add it to the vocabulary.
  4. Repeat, many thousands of times, until the vocabulary reaches the size you want.

Very common chunks like the, ing and ␣and quickly become tokens of their own. Rare words never get their own token, but they can always be spelled out from smaller pieces. This is why a tokenizer never meets a word it “can’t” handle, even a typo or a brand-new name.

Why not just use whole words, or single letters?

Both have problems, and tokens are the middle path.

  • Whole words: the vocabulary would need millions of entries (every name, typo, plural and verb form), and any new word would be unknown.
  • Single letters: the vocabulary is tiny, but every sentence becomes very long, and the model has to work much harder to see that c, a, t together mean an animal.
  • Tokens: common words stay whole, so text stays short, and rare words are still possible from pieces.

Why tokens matter to you

Tokens are not just a technical detail. They explain several everyday things about AI tools.

AI pricing is per token. When companies sell access to an LLM, they usually charge per million tokens, counting both the text you send and the text the model writes back.

The context window is measured in tokens. An LLM can only read a limited amount of text at once, called its context window. When a model “remembers” 200,000 tokens, that is roughly 150,000 English words.

Some languages cost more tokens. Tokenizers are mostly trained on English-heavy text, so English words often get their own tokens. The same sentence in Telugu, Hindi or many other languages can need several times as many tokens, which makes it slower and more expensive to process.

Spelling and counting letters can be hard. Ask an AI how many r’s are in “strawberry”, and older models often got it wrong. The model doesn’t see ten letters. It might see three tokens, such as str, aw and berry, and has to remember how each one is spelled. It’s a bit like being asked to count letters in a word you can only hear, never see.

Numbers can be split strangely. A number like 1234567 might be cut into chunks such as 123, 456, 7. That is part of why plain arithmetic used to trip models up.

From token to ID

Once the text is split, each token is swapped for its position in the vocabulary, a whole number called the token ID. If ␣love is entry number 1842 in the vocabulary, then ␣love becomes 1842.

So “I love pizza!” turns into something like [40, 1842, 23317, 0]. (These IDs are made up; each tokenizer has its own.)

But a token ID is just a label, like a roll number in a classroom. Roll number 12 and roll number 13 sit next to each other on the list, but that tells you nothing about the two students. Token 9246 might be ␣cat and 9247 might be ␣Monday. The ID carries no meaning at all. To give the model something meaningful to work with, we need one more step.

What is an embedding?

An embedding is a list of numbers that represents a piece of text, such as a token, in a way that captures its meaning. Programmers call a list like this a vector.

For a token, it might look like this:

␣cat → [0.21, −0.53, 0.88, 0.07, −0.30, 0.14, …]

A real one is much longer: GPT-2, a small model from 2019, used 768 numbers per token, and today’s large models use several thousand.

How a token gets its embedding

Inside every LLM is an embedding table: a giant table with one row for every token in the vocabulary. Each row is that token’s embedding. Turning a token ID into an embedding is simply a lookup: go to row 9246, copy out its numbers.

A token, space cat, becomes ID 9246. An arrow points into a table with columns for ID, token and its embedding numbers. The row for 9246 cat is highlighted and holds 0.21, minus 0.53, 0.88 and more. That row is copied out as a tall column of numbers labelled the embedding of cat, with hundreds to thousands of numbers.
Getting an embedding is a table lookup: find the token's row and copy its numbers.

Where the numbers come from

Nobody types these numbers in. Like everything else in an LLM, they start out random and are improved during training. Each time the model makes a wrong prediction, training nudges the numbers a little, including the rows of the embedding table for the tokens it just read.

After billions of nudges, something remarkable happens. Tokens that are used in similar ways end up with similar numbers. ␣cat and ␣kitten get close embeddings, because they appear in similar sentences. ␣Java and ␣Python end up near each other. ␣Monday sits near ␣Friday.

A map with four coloured groups of words. Animals: cat, dog, kitten, puppy. Food: pizza, pasta, dosa, biryani. Programming: Java, Python, code, compiler. Time: Monday, Friday, today, tomorrow. Words with similar meanings sit close together inside each group.
If you could squash embeddings onto a flat map, words with similar meanings would cluster together.

So you can think of an embedding as a token’s address on a map of meaning. The map just has hundreds or thousands of directions instead of two. The individual numbers don’t have neat labels like “is an animal” or “is food”. The meaning lives in the pattern of all the numbers together.

Embeddings beyond chatbots

Embeddings are useful far outside LLMs. Special embedding models turn a whole sentence, paragraph or document into a single vector. Texts about similar things get similar vectors, even if they share no words at all: “How do I reset my password?” lands close to “I forgot my login details”.

This powers semantic search (search by meaning, not exact words), recommendations, finding duplicate questions, and RAG (retrieval-augmented generation), where an AI app finds the most relevant pieces of your documents and hands them to an LLM to answer from. The vectors are often kept in a special database called a vector database.

Weights vs embeddings: what’s the difference?

This is where many people get confused, because both are “numbers the model learned”. Here is the short answer:

  • Weights are all the learned numbers stored inside a model. They are the model itself: the file you download. They are set during training and then frozen.
  • An embedding is a list of numbers that represents one piece of text. It is what the model is working on, not the model itself.

The two meet in one place: the embedding table is part of the weights. Its rows are learned, saved in the model file and frozen, just like every other weight. When the model looks up a token’s starting embedding, it is reading a row of its own weights.

But once that embedding is copied out and starts moving through the layers, it changes with every step and every input. Those changing vectors are not stored anywhere. They are calculated fresh for your text, used, and thrown away.

Top: a large box labelled the model file equals all its weights, billions of numbers, learned in training then frozen. It contains three parts: the embedding table, the layers, and the output. Bottom: embeddings flowing through for one input. The text 'I love masala' becomes starting embeddings copied from the table, then context-aware embeddings reshaped by the layers, then the next token, dosa. Footer: weights are the machine, stored and fixed; embeddings are what flows through it.
Weights are the stored machine. Embeddings are what moves through it for each piece of text.

An everyday comparison

Think of an LLM as a factory.

  • The weights are the factory itself: the machines, their settings, and the storeroom of parts. They were built and tuned once, during training. They don’t change while the factory runs.
  • The embedding table is that storeroom: one ready-made starting part for every token. It belongs to the factory, so it’s part of the weights.
  • The embeddings are the items moving along the conveyor belt for today’s order. Each one starts as a part taken from the storeroom, and every machine it passes reshapes it. A different order means different items on the belt, but the same factory.

Side by side

Weights Embeddings
What they are All the learned numbers inside the model A list of numbers that stands for one token or piece of text
How many Millions to hundreds of billions in total One vector per token, each a few hundred to a few thousand numbers long
Their job Decide how the model processes text Carry what is being processed
When they change Only during training. Frozen when you chat Starting rows are frozen. The vectors flowing through change at every layer, for every input
Where they live Saved in the model file Starting rows are in the file; context-aware ones exist only while your text is being processed

How big is the embedding table?

The embedding table is just one part of the weights, and its size is easy to work out: vocabulary size × numbers per token.

Model Vocabulary Numbers per token Embedding table Share of all weights
GPT-2 small (2019) 50,257 tokens 768 about 39 million numbers about 31% of 124 million
Llama 3 8B (2024) 128,256 tokens 4,096 about 525 million numbers about 7% of 8 billion

In a small model, the embedding table is a big chunk of the weights. In large models, most of the weights sit in the layers, which do the heavy work of combining tokens and their context.

“Weights are what a model knows. Embeddings are what it’s thinking about right now.”

Common misconceptions

“A token is a word.” Often, but not always. A token can be part of a word, a space plus a word, a single character or a punctuation mark.

“Token IDs mean something.” They are only positions in a list. The meaning lives in the embedding, not the ID.

“Each number in an embedding has a clear meaning.” Usually not. Meaning is spread across all the numbers at once, which is why you can’t point to “the animal number”.

“Embeddings and weights are completely separate things.” The embedding table is part of the weights. The difference is between the stored table and the vectors that flow through the model for each input.

“The model learns new embeddings while I chat.” No. When you chat, all the weights, including the embedding table, are frozen. The model only calculates temporary vectors for your text.

Key takeaways

  • An AI model reads numbers, not letters, so text must be converted first.
  • Tokenization cuts text into tokens: whole words, parts of words, or symbols from a fixed vocabulary.
  • Each token has an ID, which is just a label with no meaning.
  • Each ID is turned into an embedding: a list of numbers, learned in training, where similar meanings get similar numbers.
  • Weights are all the learned numbers stored in the model. The embedding table is one part of them.
  • Embeddings are what flows through the model; weights are the model itself.

Frequently asked questions

What is a token in ChatGPT, Claude or Gemini?

A token is the small unit of text these models read and write: often a word, sometimes part of a word or a punctuation mark. Each company uses its own tokenizer, so the same sentence can be a slightly different number of tokens in each one. For English, 100 tokens is roughly 75 words.

How many tokens is 1,000 words?

Roughly 1,300 to 1,400 tokens for ordinary English text. Code, numbers, unusual names and many non-English languages use more tokens per word.

What is the difference between tokens and embeddings?

A token is a piece of text, such as ␣pizza. An embedding is the list of numbers that represents that token so the model can do maths with it. Tokenization comes first; embedding comes second.

What is the difference between weights and parameters?

For most purposes they mean the same thing: the learned numbers inside a model. “A model with 8 billion parameters” means it has about 8 billion weights. Strictly speaking, parameters also include a few other learned numbers called biases, but people usually use the words interchangeably.

Are embeddings the same as weights?

Not exactly. The embedding table is part of a model’s weights: it’s learned, stored and frozen. But the embeddings that flow through the model while it reads your text are calculated fresh for each input and never stored. Weights are the machine; embeddings are what passes through it.

What are embeddings used for outside chatbots?

Search by meaning (semantic search), recommendations, grouping similar documents, spotting duplicate questions, and RAG systems that find the right parts of your documents for an LLM to answer from.

Can I see how text gets split into tokens?

Yes. Several AI companies offer free online tokenizer tools: paste in a sentence and they colour each token and show its ID. Try a long word, a number, and a sentence in your own language, and compare how many tokens each one takes.

See it in action

Prefer watching? This video walks through the same ideas with live, hands-on demos.

Video thumbnail: What are tokens and embeddings in AI? A beginner's guideWatch on YouTube ↗

Comments

LEAVE A COMMENT
No sign-up. Comments appear after a quick review.