LLMs Introduction
What a large language model is, how the transformer architecture works at a high level, and why scale matters.
What a large language model is
A large language model (LLM) is a neural network — almost always built on the transformer architecture — trained on enormous amounts of text to do one deceptively simple thing: predict the next piece of text (a "token") given everything that came before it. Given "The capital of France is", a well-trained LLM assigns a high probability to "Paris" as the next token, because that pattern appears constantly across its training data.
What makes this interesting is that "predict the next token, at massive scale" turns out to be a remarkably general training objective. To get good at it across a large enough slice of human-written text, the model has to implicitly learn grammar, facts, reasoning patterns, code syntax, and a great deal else — not because anyone told it to, but because all of that is needed to predict text well. This is why a single model trained this way can converse, summarize, translate, write code, and answer questions, without being separately built for each of those tasks.
The transformer architecture, at a high level
Introduced in a 2017 paper ("Attention Is All You Need"), the transformer is the architecture nearly every modern LLM is built on. At a high level, it works like this:
- Tokenize the input — break the text into small pieces (tokens; see the next tutorial in this series for exactly what those are).
- Embed each token — convert each token into a vector of numbers that captures something about its meaning.
- Apply self-attention, layer after layer — each token's representation gets updated by "looking at" every other token in the input and weighing how relevant each one is to understanding it (see the "How Transformers Work" tutorial for a concrete walkthrough).
- Predict the next token — the final layer turns the last token's representation into a probability distribution over the entire vocabulary, and the model picks (or samples) the next token from that distribution.
That predicted token gets appended to the input, and the whole process repeats to generate the token after that — this is why LLMs generate text one token at a time, and why response speed is often measured in tokens per second.
Why "large" matters
Scaling these models up — more parameters (the model's internal learned weights, often in the billions), more training data (hundreds of billions to trillions of tokens of text), and more compute — has produced qualitative, not just incremental, jumps in capability. Small language models can complete simple sentences reasonably; only at large scale do models reliably handle multi-step reasoning, follow nuanced instructions, and generalize to tasks they weren't explicitly trained on. Researchers call these unpredictable jumps in capability at scale "emergent behavior," and it's a major reason the field has continued pushing toward larger models and larger training runs, alongside efforts to get more capability out of a given size.
From task-specific models to general-purpose models
Before LLMs, natural language processing largely meant building and training a separate model for each task: one model for sentiment analysis, another for translation, another for named-entity recognition, each with its own architecture, training data, and pipeline. A large, general-purpose language model changes that. The same pretrained model can be prompted to perform translation, summarization, classification, or code generation, often with no additional training at all — you just change the instructions you give it. This is the practical reason LLMs reshaped the field so quickly: the cost of adapting to a new task dropped from "train a new model" to "write a better prompt" (the subject of this site's Prompt Engineering tutorials).
Common mistakes
- Treating "the model looked up the answer" and "the model predicted a statistically likely continuation" as the same thing — an LLM has no database lookup step; a confident-sounding but wrong answer ("hallucination") is a natural consequence of a system that generates plausible text, not one that verifies facts against a source.
- Assuming bigger always means strictly better for a given task — a smaller, well-tuned model is often faster, cheaper, and just as accurate for a narrow, well-defined task; scale mainly matters for breadth and difficulty of task.
- Confusing the training objective (predict the next token) with the model's only capability — the objective is simple, but training on enough varied text at scale produces capabilities (reasoning, code generation) that don't look like "just autocomplete" in practice, even though the underlying mechanism is exactly that.