FOUNDATIONS
What Is an LLM (Large Language Model)?
A large language model (LLM) is a neural network trained to predict the next token in a run of text, given everything before it. That one training objective, run at enormous scale, is what produces behavior that reads like writing, reasoning, and conversation.
What the video explains
The six-step loop
An LLM is a next-word predictor, trained on a lot of text to guess what comes next. It guesses one word at a time, and the paragraph you read back is that guess, repeated. Step zero happens only once per model version: the model reads a huge amount of text and learns to predict the next word of it, over and over, until the prediction is reliable. That step runs in three stages: pre-training, where it just learns to continue text and absorbs grammar, facts, and style along the way; fine-tuning, where it's shown good question-and-answer pairs so it learns the shape of a helpful assistant instead of a text completer; and reinforcement learning from human feedback, where people rank its answers and it gets nudged toward the ones they prefer.
Tokens, embeddings, and attention
Once a model is trained, generating the next word goes through five steps, tracked here on one running sentence: "The dog chased the cat because it stole his food." First, the sentence is sliced into tokens. A token is not the same thing as a word: "chased" splits into "chas" and "ed," and each token, including the space in front of it, is swapped for a plain number, an id. That id is the only thing that reaches the model.
Second, those ids are embedded: each one becomes a vector, a list of numbers chosen so that tokens with a similar meaning land close together. "Dog" and "wolf" cluster together, and so do "chased" and "stole," while "food" sits off on its own. Third, attention: every token looks at every earlier token and weighs how much it matters. For the word "it," the model gives "cat" a 62 percent weight, "dog" 15 percent, and "chased" barely 8 percent, so "it" moves next to "cat" on the meaning map, the one that actually stole the food.
Layers, prediction, and the loop
Fourth, that attention step plus a small network runs many times in stacked layers. Early layers mostly work out grammar and word shape, middle layers add facts like who did what to whom, and late layers handle tone and intent. Fifth, prediction: the model scores every word it could say next. For this sentence, "food" scores 85 percent, "toy" 8 percent, "bone" 4 percent. A temperature dial controls the pick: low temperature sticks to the top score, high temperature is willing to gamble on a lower one.
Then the loop closes: the picked word gets appended to the sentence, and the whole five-step process runs again from step one on the slightly longer text. Predict, append, repeat. That loop is the entire machine, and it's why a model streams its answer out one piece at a time instead of handing you the whole thing at once. On its own, a plain LLM like this can't reach live information, take actions and check the results, spend extra effort on a hard problem, or answer from a document it was never trained on. Every other topic in this series is one thing bolted onto this same plain model, built to cover one of those gaps.
The mechanical core: next-token prediction
Text is broken into tokens, roughly word-pieces rather than whole words. The model reads a sequence of tokens and outputs a probability distribution over the next one. Generation samples from that distribution, one token at a time, feeding each new token back in to predict the one after it.
Training hides the next token in a huge text corpus and makes the model guess it, nudging its weights, billions of numbers, every time it guesses wrong. Nothing labeled 'understanding' gets programmed in. The ability to answer questions or follow instructions falls out of that guessing game once the scale and the training data are large enough.
The architecture: transformers and attention
Nearly every current LLM is a transformer, and its core mechanism is self-attention. For each token, the model works out how much every other token in the input should shape its representation. That is how it ties a pronoun to a noun five sentences back, or a question to context anywhere in the input, no matter the distance.
Attention is also why context length is expensive. Naive self-attention cost grows with the square of the input length. Long-context models take real architectural and engineering work to get around that. You cannot buy the capability by raising a number in a config file.
Pretraining vs. instruction tuning
A base model trained only on next-token prediction over internet-scale text is good at continuing text. It is not good at following instructions or turning down a harmful request. Instruction tuning and reinforcement learning from human feedback (RLHF) are later training stages that turn that base model into something that acts like an assistant. Pretraining supplies the raw capability. The later stages supply the behavior.
FAQ
- Does an LLM 'understand' language?
- That is a real open debate. What is not debated: the training objective is next-token prediction, and whatever internal representations let it do that well are what people point to when they say 'understanding.'
- Why do LLMs hallucinate?
- The model produces the statistically likely next token. It does not look anything up. When it never reliably learned the true answer, it still produces fluent, confident, wrong text, because fluency and correctness are separate things to a next-token predictor.
Sources
Related
- What Is a Neural Network?
- What Is Tokenization?
- What Are Embeddings?
- What Is Attention in a Transformer?
- What Are Transformer Layers?
- How Does Next-Token Prediction Work?
- How Does the Generation Loop Work?
- What Is an AI Hallucination? Why AI Makes Things Up
- What Is a Prompt? How AI Reads Your Instructions
- What Is a Context Window? Why AI Seems to Forget
- What Is RLHF? How Chatbots Learn What People Prefer
Last updated 2026-10-05