Text to tokens
LLMs do not read words the way humans do. They read tokens: small pieces of text that can be whole words, prefixes, suffixes, or punctuation. Tokenization turns raw text into a sequence of integers the model can process.
Modern tokenizers use subword algorithms like Byte Pair Encoding (BPE). Common words get their own token; rare words are split into smaller units. This keeps the vocabulary manageable while allowing the model to represent any word.
Key idea: tokenization is the interface between human text and machine math. The choice of tokens affects how the model learns and what it can represent.
Embeddings and vectors
After tokenization, each token is converted into a long list of numbers called an embedding. The embedding captures meaning in a geometric sense: tokens with similar usage end up with similar vectors.
These vectors are not random. They are learned during training so that the model can use them to predict the next token. The embedding space becomes a map of language: synonyms cluster, opposites separate, and relationships between words appear as directions in space.
Next-token prediction
At the center of an LLM is a simple-sounding task: given a sequence of tokens, predict the most likely next one. During training, the model sees text like "The cat sat on the ___" and learns to assign high probability to "mat."
Because the task is simple, the training data can be enormous: web pages, books, code, articles. Scale is what makes LLMs powerful. The same objective — predict the next token — produces models that can summarize, translate, answer questions, and even write code, because all of these can be framed as text completion.
It is not a database
LLMs do not store facts like a database. They store weights that encode patterns in language. Sometimes the pattern matches reality, and the output is true. Sometimes the pattern is plausible but false. This is called a hallucination.
LLMs are also not search engines. A search engine retrieves existing documents. An LLM generates new text based on patterns. If you need exact, up-to-date facts, combine an LLM with a search tool or a database.
Important: an LLM's goal is to produce plausible text, not to verify truth. Always check claims that matter.
Tokenize a sentence
Type a sentence below. The demo uses a simple tokenizer for illustration. Real LLMs use subword tokenizers that can split words like "unhappiness" into "un", "happiness", or smaller pieces.
Next-token probabilities
An LLM turns a vocabulary of words into vectors, then scores each possible next word. This Python example uses embeddings and softmax to pick the next token.
Check yourself
Why might an LLM confidently give a wrong answer to a factual question?
Your answer:
Sample answer: LLMs generate text that is statistically plausible. They are not databases or truth-checkers. If the training data contains a common misconception, or if the prompt is misleading, the model may produce a confident but false answer.
Quick quiz
1. What is the main training objective of an LLM?
2. What is an embedding?
3. Why is an LLM not a reliable database?
Keep learning
You now know what an LLM is at a high level. Next, learn how it turns a prompt into an answer.
Part of the advanced remake of the “Are LLMs Smarter Than a 5th Grader?” series.