Chapter CWhat is a large language model?Page 2 of 8

What is a large language model?

How pretraining builds patterns

Pretraining turns repeated prediction errors across vast collections of examples into reusable patterns stored in model weights.

~14 minLearning mechanism

Before you start

Why this matters

Imagine learning to autocomplete sentences with millions of practice rounds. In each round, you see some text, predict what follows, compare your guess with the actual continuation, and adjust slightly. Early guesses are poor. After enough varied examples, you become sensitive to grammar, tone, facts often expressed in text, and relationships between distant words.

That is the core intuition behind pretraining. The real process uses token sequences, numerical parameters, optimization algorithms, and immense computation, but its learning signal is surprisingly simple: make better predictions on the training examples.

1Learn the idea

Read

From documents to training examples

Training begins with collections of text and often code. Depending on the model, sources may include licensed material, public material, data created by human trainers, or synthetic examples. Responsible developers document source categories, filtering, rights, privacy practices, and known gaps as clearly as possible.

The data is cleaned and transformed. Systems may remove duplicates, filter low-quality or harmful material, exclude sensitive information, and balance domains. No filter is perfect. Data choices shape what the model learns, which languages it handles well, and which biases or omissions may remain.

Text is tokenized and divided into sequences. A sequence supplies many prediction examples. In:

Rain fell all night, so the river rose.

the model can practice predicting fell after Rain, all after Rain fell, and so on. At scale, batches contain many sequences processed in parallel.

Read

Parameters begin without useful language

An LLM contains many adjustable numbers called parameters or weights. They determine how token representations are transformed through layers of a neural network. Before training, these values do not encode useful language patterns.

For each training position, the model outputs scores for possible next tokens. A loss function measures how much probability it assigned to the actual next token. Predicting the actual token with high probability gives a lower loss; assigning it almost no probability gives a higher loss.

An optimization method uses gradients to estimate how each weight contributed to the error. The weights then move by small amounts intended to reduce future error:

  1. Run tokens through the model.
  2. Compare predictions with actual next tokens.
  3. calculate the loss.
  4. Compute gradients through the network.
  5. Update weights slightly.
  6. Repeat over many batches.

No engineer writes a separate rule for every noun, programming pattern, or historical association. The network develops internal representations because they help reduce prediction error across examples.

Teach

Pattern learning is distributed

A common but misleading picture is that each fact occupies one labeled slot. In modern neural networks, useful behavior is generally distributed across many parameters and activations. One parameter may contribute to many patterns, and one pattern may depend on many parameters.

This distribution allows generalization. After seeing many forms of dates, names, questions, and comparisons, a model can respond to a combination that never appeared exactly in training. It does not need an identical stored sentence to continue plausibly.

Models can sometimes reproduce memorized passages, especially material that was duplicated or distinctive. That is a real privacy and evaluation concern. But occasional memorization does not mean every response is retrieved from a hidden archive, nor can the model normally identify the specific training record behind an answer. Its weights are not a searchable bibliography.

Read

Scale changes what can be represented

Three broad resources influence pretraining:

  • Data: the quantity, diversity, quality, and coverage of examples.
  • Compute: the hardware and operations available for processing examples and updates.
  • Model capacity: the number and arrangement of parameters that can represent patterns.

More is not automatically better. Repeated junk data can reinforce junk. A huge model can be inefficient for a narrow task. Poorly balanced sources can leave major gaps. Researchers use scaling studies to choose combinations of data, capacity, and computation rather than maximizing one number alone.

Larger, well-trained models often make more accurate predictions across a wider range of contexts. Some capabilities become much more reliable with scale. Still, scale does not turn statistical prediction into guaranteed truth, remove bias, or provide live knowledge of events after training.

Read

Pretraining is not the whole product

A pretrained model is often good at continuing text but not yet good at acting as a helpful assistant. Developers commonly add post-training. Techniques vary, but may include supervised examples of useful responses, preference-based optimization, safety training, tool-use examples, and domain adaptation.

These stages change which behaviors are likely. For instance, examples can teach a model to answer a direct question instead of merely continuing the question, to follow a requested format, or to refuse certain dangerous requests. Product systems may then add system instructions, retrieval, filters, and tools.

Keep the stages distinct:

  • Pretraining builds broad language and world patterns into weights.
  • Post-training shapes behavior toward desired interactions.
  • Prompting supplies temporary instructions and examples at request time.
  • Retrieval and tools provide external information or actions during use.

Confusing these stages leads to bad diagnoses. If a model lacks current prices, a clearer prompt may not supply the missing data. If it ignores a format inconsistently, examples or a stronger model may help. If it must cite a private policy, retrieval is usually more appropriate than hoping pretraining included it.

Read

What training does not imply

Training on language does not by itself grant direct access to the world. The model has no automatic view of today’s weather, your database, or a private document unless the application provides that information through context or a tool.

Training also does not mean the model learns like a person in every respect. The objective, scale, sensory experience, and feedback differ. The useful technical claim is narrower: optimization changes weights so the model predicts token sequences more successfully, and those learned representations support many downstream behaviors.

Checking tutor…

Continue learning · glossary & guides