Text to numbers

A model can only multiply and add numbers. Follow your sentence through six steps until it becomes the grid of numbers a model actually receives, and see where it first meets the model's weights.

    The real thing

    The same sentence in GPT-4o's tokenizer

    This is the actual tokenizer used by GPT-4o, running in your browser. It learned its pieces from a huge amount of text, so common words are single tokens and rare words split into pieces. Try another language too.

    Loading the real tokenizer…
    Characters–
    Tokens–
    Vocabulary–

    Differences from the steps above: it keeps capitals ("River" and "river" are different tokens), and it stores the space in front of a word inside the token, shown as ·.

    Where the rows come from

    The embedding weights are learned

    Every row of the embedding table starts as random numbers. Training uses the same task as the Tiny LLM Lab, predicting the next token, and nudges these numbers each time. Each row has 2 numbers, so each token can be drawn as a point: its two numbers are its position on this map.

    Rounds0
    Error–
    Training text

    The tokenizer learns its pieces from this text, and the embedding weights are trained on it.

    Relearns the pieces and resets the embeddings to random.

    A simplified model for understanding. Real tokenizers learn 50,000 to 200,000 pieces and work on bytes, so they can handle any language. Real embedding rows have hundreds to thousands of numbers instead of 2. Next: what the model does with this grid of numbers.