Concepts / Sampling and the Probabilistic Nature of Models

Sampling and the Probabilistic Nature of Models

The transformer is the dominant architecture for language-based foundation models, and it is chosen before training begins. Dominant means the common default, not the only design.

  • Programming

Why Architecture Is Decided First

Imagine two teams that each want to build a language model. The first team starts by asking which data to gather and how to run the training job. The second team starts earlier, by asking what shape the model itself should take. Training gets most of the attention in news coverage, but a major decision happens before training begins: choosing the architecture and the size of the model. That decision controls how much compute training will require and what the finished model can do.

This article focuses on the architecture side of that decision. Before you can judge a model, you need a working picture of two things: the transformer, which is the design that now dominates language-based foundation models, and the scale numbers used to describe how big a model is. As you read, keep one question in mind. When a model is large and capable, which part of that result comes from its architecture, and which part comes from how much it was scaled?

What do you think happens?

Two language models have exactly the same number of parameters. Must they need the same amount of training compute?

  • Yes, because the parameter count fixes the cost of training

  • No, because the amount of training data also affects compute

Reveal answer
Answer:

No. Two models with the same parameter count can need very different amounts of compute, depending on how much data they see during training.

A parameter count tells you about the model's size. It does not tell you how expensive the model was to build. Training compute depends on the model size and the data size together, so the parameter count is only part of the picture.

Dominant Does Not Mean Only

Definition

The transformer is the dominant architecture for language-based foundation models, and it is chosen before training begins. Dominant means the common default for this family of models, not the only design anyone has tried.

The distinction matters. A dominant design wins because it solves a set of problems well enough that most builders reach for it first. That popularity does not mean every problem is solved, and it does not mean the design is free of tradeoffs. A builder who treats a dominant default as the only option may miss the places where it falls short.

The course material says the transformer was designed to address certain problems and that it has limitations, and it explores both. The excerpt this article draws on does not list those problems or limitations by name, so this article does not claim a specific list. What the material does make clear is that the transformer is a deliberate design response to earlier challenges. Understanding it means understanding what it handles well and where it falls short.

Three Numbers That Describe Scale

A model's scale is not captured by one number. It is described with three quantities: the number of parameters, the number of training tokens, and the number of FLOPs needed for training. Each one answers a different question about the model. Parameters tell you about the model's size. Training tokens tell you how much data the model is trained on. FLOPs tell you how much computation training requires.

Parameterslearned values in the modelTraining tokensamount of text passedthrough trainingFLOPscomputation needed fortraininglinked but separatelinked but separate
What each scale measure counts, and how the three differ. Each measure answers a different question, and they are linked but separate.

The three numbers are linked but separate. A model can have many parameters and still be trained on a small amount of data. Two models with the same parameter count can need very different amounts of compute depending on how much data they see. This is why reading only the parameter count tells you about the model's size but not about how expensive it was to build.

How Size and Data Drive Training Compute

Training compute is shaped by two things: the size of the model and the size of the data. A bigger model has more learned values to adjust during training. A bigger dataset means more text passes through the training process. Both push the total amount of compute upward. Compute is therefore not a fixed property of the model alone. It grows with the model and also with the data the model is trained on.

Worked example

Comparing Two Training Plans

Team A trains a large model on a small amount of text. Team B trains a smaller model on a much larger amount of text. Which change pushes total training compute up, and what does that tell you about comparing them?

  1. 1
    Identify the two inputs to compute

    Training compute depends on the size of the model and the size of the data, so both plans have to be evaluated on both dimensions.

  2. 2
    Look at the model side

    Team A has more learned values to adjust, which raises compute. Team B has fewer, which lowers this part of compute.

  3. 3
    Look at the data side

    Team B passes far more text through training, which raises compute. Team A passes less, which lowers this part of compute.

  4. 4
    Compare the totals

    The two effects pull in different directions, so the parameter count alone cannot tell you which plan is more expensive. You need both numbers, along with the training token count.

Result

Compute depends on model size and data size together. A large model is not automatically more expensive than a smaller model trained on far more data.

Scaling Laws and Compute Budgets

This is where the scaling law comes in. Given a fixed compute budget, a scaling law helps determine the best combination of number of parameters and number of training tokens. The question it answers is practical. If you can spend only so much compute, should you build a larger model trained on fewer tokens, or a smaller model trained on more tokens? Scaling laws give builders a principled way to make that split instead of guessing.

Model sizenumber of parametersTraining computeFLOPs needed for trainingScaling lawchooses the splitRecommended balanceparameters and tokensData sizenumber of training tokensCompute budgetfixed amount availableraisesraisesinput toreturns
Model size and data size both feed the compute requirement. A scaling law takes a compute budget and returns a recommended balance of parameters and tokens.

The source excerpt does not give a numeric formula for the recommended balance. The diagram shows only the relationships: size and data both feed the compute requirement, and the scaling law takes a compute budget and returns a recommended split. Do not assume a specific formula beyond that relationship unless your source provides one.

Tracing Batch Shapes Through Query, Key, and Value

Models do not process one word at a time in isolation. Input tokens are handled in batches, and the shape of the data tells you how those batches are organized. The course material gives the shape of the input as a three-dimensional arrangement written $N \times T \times 4096$. Here $N$ is the batch size, meaning how many sequences are processed together, and $T$ is the sequence length, meaning how long each sequence is. The 4096 is the width of each token's vector.

The query, key, and value vectors that the transformer computes from that input have the same shape. So the batch keeps its three dimensions as it moves through the Q, K, and V step. The diagram below traces this path. The source excerpt does not detail the steps that come after these vectors are formed, so the diagram stops there.

Input batchN × T × 4096Query vectorsN × T × 4096Key vectorsN × T × 4096Value vectorsN × T × 4096computed ascomputed ascomputed as
The input batch has shape N × T × 4096. The query, key, and value vectors computed from it share that same shape, so batch size, sequence length, and vector width keep their meaning at each step.
Worked example

Reading the Shape of a Batch

A batch contains 8 sequences, and each sequence has 512 tokens. Using the input shape N × T × 4096, what is the shape of the batch, and what does each number mean?

  1. 1
    Assign the batch size

    The first dimension N counts how many sequences are processed together. Here N = 8.

  2. 2
    Assign the sequence length

    The second dimension T is the length of each sequence. Here T = 512.

  3. 3
    Read the vector width

    The third dimension, 4096, is the width of each token's vector. It does not change with the number of sequences or their length.

  4. 4
    Carry the shape to Q, K, and V

    Query, key, and value vectors have the same shape as the input, so each of them is also 8 × 512 × 4096.

Result

The batch shape is 8 × 512 × 4096. The sequence dimension T = 512 is what would be called the length of each sequence, which is the sense in which the context length refers to T.

Mistakes When Reading Model Scale

  • Common mistake

    Treating a dominant architecture as the only architecture

    What it looks like

    Assuming that because transformers dominate language-based foundation models, no other design is worth considering.

    Why it fails

    Dominant means the common default, not the only design. A default wins because it handles a set of problems well, not because it solves every problem.

    Do this instead

    Describe the transformer as the common default, and remember that it has limitations the course material explores.

  • Common mistake

    Judging a model's cost by its parameter count alone

    What it looks like

    Concluding that two models with the same number of parameters must have cost the same to train.

    Why it fails

    The three scale numbers are linked but separate. Compute also depends on how much data the model sees, so equal parameter counts can still mean very different training compute.

    Do this instead

    Check the parameters, the training tokens, and the FLOPs together before comparing cost.

  • Common mistake

    Confusing batch size with sequence length

    What it looks like

    Reading the shape N × T × 4096 and treating N as the length of each sentence.

    Why it fails

    N is the number of sequences in the batch, while T is the length of each sequence. Mixing them up leads to wrong reasoning about memory and compute.

    Do this instead

    Read N as how many sequences are processed together and T as how long each sequence is.

  • Common mistake

    Assuming architecture alone determines model behavior

    What it looks like

    Believing a transformer will perform well on a specialized task simply because it has the right design.

    Why it fails

    The source notes that behavior also depends on the training data and on how the model is adjusted afterward.

    Do this instead

    Consider the training data and any later adjustment alongside the architecture when judging a model.

Practice Tracing a Batch and a Budget

EASY

A batch of input has shape N × T × 4096 with N = 4 and T = 1024. Write the shape of the query, key, and value vectors computed from this batch. Then explain, in one sentence each, what N and T each count.

Hints
  • Query, key, and value vectors share the shape of the input batch.
  • N counts sequences processed together, and T counts tokens in each sequence.
MEDIUM

A team has a fixed compute budget and must choose between a larger model trained on fewer tokens and a smaller model trained on more tokens. Using only the ideas in this article, name the tool that helps make this split, and describe what it takes as input and what it returns.

Hints
  • Look for the concept that takes a compute budget and returns a recommended balance.
  • The output is a balance of parameters and training tokens, not a single number of FLOPs.

Key Takeaways

  • The transformer is the dominant architecture for language-based foundation models, meaning the common default rather than the only design, and it is chosen before training begins.
  • A model's scale is described by three linked but separate numbers: parameters, training tokens, and FLOPs needed for training.
  • Training compute grows with both model size and data size, and a scaling law uses a compute budget to recommend a balance between parameters and tokens.
  • The input batch has shape N × T × 4096, and the query, key, and value vectors share that shape, so batch size, sequence length, and vector width each keep a distinct meaning.

Related concepts

More concepts starting with S