Foundations · Lesson 3 of 3
How large language models work
Chat assistants feel like conversation partners, but underneath they do one surprisingly simple thing, over and over: predict the next piece of text. Here is what happens between your prompt and the reply.
Step 1: text becomes tokens
A large language model (LLM) doesn't read letters or whole words. It reads tokens: common chunks of text that can be a whole word, part of a word or punctuation. As a rule of thumb for English, one token is about four characters, or about three-quarters of a word, so 100 tokens is roughly 75 words [1]. The exact split depends on the model [1].
Tokens matter in practice. Models have a limit on how many tokens they can consider at once, often called the context window, and many services price usage by the token.
Step 2: predict the next token
At its core, an LLM is trained to predict the next token in a sequence [2]. Given "The cat sat on the", it assigns a probability to every token it knows: "mat" might be likely, "floor" plausible, "volcano" very unlikely. It picks one, adds it to the text, and predicts again. A long, fluent answer is this loop repeated hundreds or thousands of times.
The model learns these probabilities in pre-training, by doing next-token prediction across a very large body of text and adjusting its weights with the same kind of training loop described in the previous lesson. Along the way it picks up grammar, facts, styles and reasoning patterns, because all of them help predict what comes next.
Step 3: the transformer and attention
Almost every modern LLM is built on the transformer, an architecture introduced by Google researchers in the 2017 paper "Attention Is All You Need" [3]. Its key idea is attention: while processing each token, the model weighs how relevant every other token in the context is. In "The trophy didn't fit in the suitcase because it was too big", attention is how the model can connect "it" to "trophy".
The original transformer dropped the step-by-step recurrence that earlier language models used and relied on attention instead, which made training far easier to run in parallel [3]. That efficiency is a big part of why models could grow so large.
What "large" means, and what the model can't know
The "large" in large language model refers to scale: the number of adjustable weights, or parameters, and the amount of text used in training. GPT-3, the model the 2022 paper started from, had 175 billion parameters [4]. More parameters let a model capture more patterns, but as the next section shows, size is not the whole story.
Two limits follow directly from how an LLM is built. First, it only knows what was in its training text, so it has no knowledge of events after its training data was collected unless a tool or a person supplies that information in the prompt. Second, nothing in next-token prediction checks facts against the world. The model learns which words tend to follow which, and true statements are usually the most likely continuation, but not always.
Step 4: from text predictor to assistant
A model that only predicts text will happily continue your question with more questions. To turn it into a helpful assistant, developers fine-tune it further. A well-known 2022 paper from OpenAI described one approach: people wrote example answers, then ranked the model's outputs from best to worst, and those rankings were used to train the model further [4]. This is often called reinforcement learning from human feedback (RLHF). In the paper's human evaluations, outputs from a 1.3-billion-parameter model trained this way were preferred to outputs from the 175-billion-parameter GPT-3 [4], a model more than 100 times larger. Training method mattered as much as size.
The same paper is candid that the resulting models still made simple mistakes [4].
Why LLMs make things up
An LLM generates the most plausible continuation, and plausible is not the same as true. NIST describes this as confabulation: generating and confidently presenting erroneous or false content. It explains that this is a natural result of how generative models work, because they approximate the statistical patterns of their training data, for example by predicting the next token [2]. Errors are more likely with open-ended, long-form answers and in specialist domains [2].
Practical rules follow from that:
- Ask for sources, then open them. A citation an AI gives you can itself be confabulated.
- Give the model the facts it needs (paste the document, the config, the data) instead of relying on its memory.
- Have a person who knows the subject check anything that matters before it ships. At Lumiversed, that step is not optional.
Try it
Open the free OpenAI Tokenizer and paste in a sentence, then a long unusual word, then a line of code. Notice how common words are single tokens while rare words split into pieces. Next, ask a chat assistant to "continue this sentence three different ways: The cat sat on the". You are watching next-token prediction choose among plausible options.
Key takeaways
- LLMs read and write tokens; in English one token is roughly three-quarters of a word.
- The core skill is next-token prediction, learned in pre-training on large amounts of text.
- The transformer's attention lets each token weigh every other token in the context.
- Human-feedback fine-tuning turns a text predictor into a helpful assistant.
- Plausible isn't true: LLMs confabulate, so verify anything that matters.
Sources
- OpenAI Help Center, “What are tokens and how to count them?”
- NIST AI 600-1, “Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile” (July 2024), §2.2 Confabulation
- Vaswani et al., “Attention Is All You Need,” arXiv:1706.03762 (2017), NIPS 2017
- Ouyang et al., “Training language models to follow instructions with human feedback,” arXiv:2203.02155 (2022)
How this lesson was made: drafted with AI (Claude, by Anthropic, working as Lumiversed's website engineer), with every factual claim checked against the sources above on 2026-11-26. Reviewed by V (founder), Lumiversed's human engineer, on 2026-11-26. Spotted an error? Tell us.