</sg>

Forward Propagation, visualized.

When your code calls an LLM, what actually happens between the request and the response? A product manager's mental model — enough vocabulary to hold your own with an ML engineer, no calculus required.

Built by tinkering with Claude Code — half to learn what really happens inside an LLM call, half to see how well AI can build the kind of visual, interactive document Bret Victor called an explorable explanation.

The decision assembly line RAW DATA input 01 · INPUT simple patterns 02 · HIDDEN combinations 03 · HIDDEN abstract concepts 04 · HIDDEN ANSWER prediction 05 · OUTPUT
Fig. 1Data enters as raw material and exits as a prediction. Every stage in between transforms it a little further.

If you ship AI products, you will spend your career inside one acronym: the API call. A few lines of code go out, a blob of text comes back, and somewhere in the middle a neural network did something. That something is forward propagation — the act of moving data through a neural network in one direction, input to output, until a prediction falls out the end.

This is a walkthrough of what actually happens in there. By the end you'll have the mental models, vocabulary, and order-of-magnitude numbers to talk with ML engineers about latency, cost, and capability without nodding through words you don't own.

§ 00When your program calls an LLM

Before we zoom into the network, it helps to see where it sits inside the bigger picture. Here's what happens between the moment your program sends an LLM a request — some prompt like "write me a function that…" or "summarize this email" — and the moment a response streams back.

Inside an LLM call API · MODEL SERVER YOUR APP builds prompt POST tokenize text → IDs embed IDs → vectors PREFILL 1 forward pass over the prompt ↓ fills KV cache DECODE 1 pass per token × N tokens ↺ reads KV cache STREAM token by token response streams back · typewriter UX = decode loop made visible forward propagation lives in prefill + decode · every output token = one full trip through 80 layers
Fig. 1aThe pipeline. Tokenize and embed prep the input; prefill and decode do the actual thinking; stream pipes the result back one token at a time.

Two things are worth zooming in on: the prefill vs decode split inside the server, and what the model is doing when it starts feeding itself.

Prefill vs decode · two phases, two different rates

The forward pass isn't one step — it's two phases.

A 500-token answer = 1 prefill + 500 decode passes.

Prefill vs decode PREFILL · 1 PASS all prompt tokens in parallel You are a helpful coding assistant 6 TOKENS · ALL AT ONCE 80 layers KV fills "Sure" first output token DECODE · N PASSES one new token at a time "Sure" 1 NEW TOKEN 80 layers · same weights KV reads "," ↺ loop N times next token · sample · append · repeat
Fig. 1bSame 80 layers both sides. Prefill processes every prompt token in parallel and fills the KV cache. Decode reuses the cache, processing one new token at a time — N times.

From decode token #2 onward, the model is literally feeding itself — each pass's input is your prompt plus everything it has generated so far. That's the autoregressive in "autoregressive language model." The streaming typewriter effect in ChatGPT or Claude is nothing mystical — it's the decode loop made visible, each character a completed forward pass arriving over the wire the moment it's produced.

Why naming prefill and decode matters

They are two separate latency budgets. Every real inference optimization attacks one phase or the other.

  • Time-to-first-token (TTFT) = prefill cost. Long prompts tax this.
  • Tokens-per-second (TPS) = decode cost. Long answers tax this.

Split the budget and the optimization space slots into place:

  • Prompt caching — skips prefill on repeated contexts.
  • Speculative decoding — accelerates decode by having a small model draft tokens that a big model verifies.
  • Batching — amortizes both across concurrent requests.
  • Quantization — shrinks the cost of every pass.

Hear "our latency is high" and the first question is no longer which knob? — it's which phase?

With that map in hand, let's zoom in. One API call runs many forward passes. One forward pass runs through 80 layers. One layer runs thousands of neurons. One neuron runs one small math operation. Each zoom down is the next thing to understand.

Zooming in, four times each panel is inside the previous panel's highlighted region × N per response × 80 layers × 1000s of neurons your program's LLM API call contains: ONE FORWARD PASS (one of many) LLM API CALL ONE LAYER ONE FORWARD PASS ONE NEURON ONE LAYER weighted add, then fire or not ONE NEURON one API call = many passes × many layers × many neurons × one tiny math operation
Fig. 1cEach panel is what's inside the previous panel's highlighted region. Read the zoom chain as a sentence: an API call contains forward passes; a forward pass contains layers; a layer contains neurons.
If drawn at (something like) true scale… same four levels, placed side by side — watch the shrinkage LLM API CALL 1 per call × FWD PASS 500 per call × 80 per pass LAYER × NEURON 8,192 per layer = 327,680,000 neuron firings per API call true relative size is ~10,000× more extreme than this — a real neuron next to an API call is invisible
Fig. 1dScale comparison. The shapes shrink dramatically here; the actual ratios are even worse. Multiply across the row and one API call resolves to roughly 327 million neuron firings — each of which is just a few adds and multiplies.

§ 01The assembly line

Think of a neural network as a multi-stage assembly line in a factory. Each stage — a "layer" — processes raw materials step by step, until a final product rolls off the line. Forward propagation is simply moving data down that line, in one direction, from input to output.

Every neural network — whether it's detecting spam, recognizing faces, or generating an essay — follows the same four-stage anatomy. The stages vary in size and sophistication, but the structure is universal.

STAGE 01

Input layer · Raw materials

The starting point. An email's text. An image's pixels. A customer profile's columns. Whatever you're asking the model to reason about, in its rawest numerical form. For an LLM, this is the embedded tokens we just met.

Flour, eggs, sugar arriving at the bakery — unprocessed, unmixed, full of potential.

STAGE 02

Hidden layers · Assembly stations

The intermediate steps where data is transformed. Early layers catch simple patterns — edges, keywords. Later layers compose those into richer ones: an ear, then a face, then cat. "Hidden" just means you don't see their outputs directly — they're intermediate work.

Mix the batter. Shape the cake. Frost and decorate. Each station adds one meaningful transformation.

STAGE 03

Neurons · The workers

Each neuron is a tiny voter inside a layer. It takes its inputs, multiplies each by a weight ("how much should I care about this signal?"), adds a small bias, runs the result through an activation function, and decides: fire, or stay quiet. We'll zoom in next — they're the protagonists.

A quality-check station where workers inspect parts and vote on whether something is worth passing along.

STAGE 04

Output layer · The verdict

The last layer produces the prediction. Spam or not spam. An estimated price. An identified object. The next word to say. Whatever question the model was built to answer — usually with a confidence score attached.

The finished cake, boxed, ribboned, ready for delivery.

§ 02Inside one neuron

The input layer is really just data sitting there — no workers, no calculations, just numbers waiting. Everything interesting starts at the first hidden layer, where the first wave of neurons springs into action. Understand one neuron and you understand the whole machine.

One neuron, up close x₁ x₂ x₃ INPUTS FROM PREVIOUS LAYER w₁ = 0.2 w₂ = 0.9 w₃ = 0.5 Σ + b f( · ) WEIGHTED SUM plus a bias "b" ACTIVATION fire, or stay quiet y OUTPUT TO NEXT LAYER Line thickness = weight strength · Thicker means "I care more about this input"
Fig. 2The atomic unit. Every network is millions of these wired together.
Intuition

A neuron is an opinionated voter.

It listens to signals from the previous layer, but not equally — it has its own taste. Each signal has a dial (a weight) that says how much to care about it. The neuron adds up all the weighted signals, adjusts by a baseline lean (the bias), and decides: "is this strong enough to shout about?" If yes, it passes a loud signal forward. If not, it stays quiet.

Multiply that by hundreds of voters per layer, and dozens of layers, and you get a model.

Technical

A neuron computes y = f(Σwᵢxᵢ + b).

Each input xᵢ is multiplied by a learned weight wᵢ. The products are summed, a bias b is added, and the result passes through a non-linear activation function f — typically ReLU: max(0, z).

Without the non-linearity, stacking layers would collapse to a single linear transformation. The activation is what gives the network its expressive power.

Two things to internalize.

Weights are what "learning" produces. When a model is trained, the weights are the knobs being tuned. Billions of tiny dials get nudged, epoch by epoch, until the network gets good at its task. Everything a model "knows" is encoded in those numbers. When someone says "the weights of GPT-4 aren't public," they mean: you can't download the dials.

The activation is what makes depth worth having. Without that non-linear kink at each neuron, stacking a hundred layers would be mathematically equivalent to one giant linear equation — you could only learn straight lines. The activation introduces the small non-linearity that, compounded across many layers, lets the network model arbitrarily complex patterns. It's the reason deep learning is deep.

What do the layers actually do?

Once you stack 80 of these layers and train them on the internet, specific layers end up specializing in specific things. Roughly — but less tidily than vision models, where early layers clearly detect edges and late layers clearly detect objects. In language models, interpretability researchers find bands, not hard boundaries.

What do the layers actually do? roughly · what interpretability research finds in language models INPUT OUTPUT L 1 — L 10 surface forms · tokens · position what words are, where they sit L 10 — L 25 morphology · POS · induction heads plurals, tense, "if X then Y" patterns L 25 — L 45 entities · dependencies · co-reference who did what to whom L 45 — L 65 semantics · facts · sentiment meaning, world knowledge, feeling L 65 — L 80 task format · next-token pick what exactly to say next rough bands, not hard boundaries · same function often appears across many layers
Layer depthA sketch of how specialization tends to distribute in large language models. Real layers are messier than this — but the shape is directionally true.

Three caveats keep the picture honest:

The field that maps this out is mechanistic interpretability; Anthropic's Transformer Circuits is the canonical starting point.

The usable intuition for product work: depth enables composition. You don't need to know exactly which layer holds the "sentiment" circuit to reason about what models can and can't do — but when an engineer says "we're fine-tuning the top few layers," you now know they're touching task-format and output machinery, not rewiring how the model reads syntax.

§ 03How big are we actually talking?

An assembly line sounds manageable. The reality is that modern networks have so many workers and stations that the numbers stop feeling like numbers and start feeling like astronomy. Here's the calibration your intuition needs.

PARAMETERS PER MODEL · LOG SCALE MNIST classifier 2 hidden layers ~100K params ResNet-50 image classifier · 2015 25M params BERT-large language model · 2018 340M params GPT-3 OpenAI · 2020 175B params Llama 3 70B Meta · 2024 · open weights 70B params GPT-4 estimated · 2023 ~1.7T params
Fig. 3Each step up is roughly an order of magnitude. The bars are log-scaled.

Parameters is what ML folks call weights + biases: the total count of tunable dials in the model. It's the most-quoted stat about a model, and it's the right one for order-of-magnitude intuition.

Anatomy of a modern LLM

Let's look at one in detail. Llama 3 70B, because its architecture is public and it's representative of the current state of the art.

Layers
Stacked transformer blocks, each containing attention and feedforward neurons.
80
Hidden dimension
The size of the vector representing each token as it flows through the model.
8,192
Attention heads
Parallel mechanisms per layer that let the model "look at" different parts of the input at once.
64
Total parameters
Every weight and bias in the whole network. The dials learning rearranged.
70 billion
Context window
The longest input the model can process in one pass, in tokens.
128,000

Where all those gigabytes come from

Model size on disk is just parameters × bytes per parameter. Each parameter is a number, and that number needs to be stored at some precision.

FP32 (full precision)
4 bytes each. Used during training. Llama 3 70B at this size:
280 GB
FP16 / BF16
2 bytes. Standard for inference. This is the "native" published size.
140 GB
INT8 quantized
1 byte. Small quality hit, fits on a single data-center GPU.
70 GB
INT4 quantized
0.5 bytes. Noticeable quality loss, but runs on a consumer laptop.
35 GB

Quantization is the art of representing each parameter with fewer bits. A weight that was 0.7234156 in training might become just 0.72 — or even 0.7 — at inference. The model gets dumber, often only slightly, and memory drops 2×, 4×, sometimes 8×. This is why you see people running "7B" or "13B" models on a laptop: the base model is small and quantized.

PM takeaway

Three views of the same model — each the right answer to a different question:

  • "70B" — parameter count.
  • "140 GB" — FP16 size on disk.
  • "Runs on a 3090" — quantized to fit in a consumer GPU's 24 GB VRAM.

Knowing which one is being quoted matters for every capacity, latency, and cost conversation.

Are the layers "fixed"? Architecture vs weights

Natural follow-up once you see numbers like these: are the layers fixed, or do they shift around between users, prompts, tokens? The answer needs two distinctions.

Who designs the architecture? Humans — the ML research team at the lab. The architecture file is usually a few hundred lines of code. Meta's Llama 3 is a good public reference — the entire architecture is ~300 lines of PyTorch: meta-llama/llama3/llama/model.py. If you open it, three lines make the "stacked layers" picture concrete:

What makes a model "smart" isn't the architecture; it's what gets poured into it during training. We'll get to that direction of the assembly line in §06.

§ 04The latent space

Here is the single most important concept you don't yet have a picture for. Bring this one to whiteboards and watch engineers nod — it's the abstract "workspace" the model reasons inside.

dimension A dim B Animals cat dog rabbit horse cow Vehicles car truck boat train plane Emotions joy fear anger hope grief MEANINGS HAVE DIRECTION king queen man woman + royalty king − man + woman ≈ queen similar concepts cluster · parallel directions encode similar relationships
Fig. 4An 8,192-dimensional space, drawn in two. Close points mean similar things; parallel directions mean similar relationships — the inset shows the classic "king − man + woman ≈ queen" pattern.

The output of every hidden layer is a list of numbers — a vector. In Llama 3 70B, that list is 8,192 numbers long. You can't picture an 8,192-dimensional space, but you can picture the idea: each input the model has ever seen ends up as a point in that space. Similar things — "cat" and "dog," "joy" and "hope" — land near each other. Dissimilar things land far apart. This is the latent space (sometimes called embedding space or representation space).

The famous result that first made this click: in a well-trained language model, you can do arithmetic on meanings. Take the vector for "king," subtract "man," add "woman" — and you land very close to "queen." The model has organized its internal space so that abstract relationships (gender, royalty, tense, plurality) correspond to consistent directions.

Where it fits on the assembly line

Latent space isn't a separate stage — it is what the hidden layers are producing. Each layer's output is a point in a (usually high-dimensional) latent space. As data moves through the network, its location in latent space shifts: early layers organize by surface features (letter patterns, edges), deep layers by abstract meaning (sentiment, intent, topic).

Same space family, different depths:

Why this matters for products

Semantic search, recommendations, "find similar documents," clustering of support tickets, RAG retrieval — all of it works by putting things into a latent space and measuring distance. When your team debates "dense vs. sparse retrieval" or "which embedding model to use," they're arguing about whose latent space is the best map of meaning for your use case.

§ 05End-to-end: a spam classifier

The simplest possible worked example — a tiny network deciding if one email is spam. Same anatomy as a trillion-parameter LLM, just smaller.

FREE money! click here → RAW EMAIL "free" "click" "winner" "now" detects keywords LAYER 1 "free" + "click" = suspicious "winner" + "now" = suspicious combines phrases LAYER 2 SPAM conf. 90% VERDICT 01 · INPUT 02 · FEATURES 03 · PATTERNS 04 · OUTPUT
Fig. 5Four stages, one pass, one answer.

Reading left to right: a raw email enters on the left. The first hidden layer picks out suspicious words in isolation — free, click, winner, now. The next layer notices these keywords aren't just present individually; they're clustering together in ways that matter. The output layer weighs it all and commits: spam, 90% confidence.

The whole journey is forward propagation. One direction, one pass, one answer. The "learning" already happened during training — thousands of example emails, weights slowly settling into positions that make this particular pipeline accurate. Now, at inference time, the model is just running what it knows.

Scale the picture up. Replace the four stages with 80 transformer blocks. Replace the tiny vocabulary of suspicious words with a token embedding table. Replace the binary "spam / not spam" verdict with a probability over 128,000 possible next tokens. Run the whole thing once per token you want to generate. That's an LLM.

§ 06The other direction · backpropagation

Forward propagation is the model running. Backpropagation is how the model learned to run — the reverse direction through the same network, used only during training, never at inference time. Every weight you now find frozen inside Llama 3 or Claude got there because of this loop.

Same network, two directions forward to predict · backward to learn layer 1 layer 2 layer 3 layer 78 layer 79 layer 80 INPUT PREDICTION FORWARD activations flow input → output Δ WEIGHTS LOSS BACKWARD gradient flows output → input inference uses forward only · training uses both forward → compute loss → backward → update weights → repeat
Fig. 6Same stack, two directions. The arrow on the left is what every API call does; the arrow on the right is what happened during training to make the API call work.

The training loop

For each training example — a chunk of text from the internet, a book, source code, a curated conversation:

Over training, the weights drift from random noise into a configuration where the forward pass produces useful answers. That drift is where "learning" happens. By the end, everything the model "knows" — grammar, facts, reasoning patterns, style — is encoded in those billions of numbers.

Why "back"-propagation?

Because the gradient flows backward through the layers, exactly mirroring the forward pass. The error at the output tells you what the last layer should have done differently. That signal tells the second-to-last layer what it should have done. And so on, back to the first hidden layer. Each layer's contribution is computed using the chain rule of calculus — but the intuition is simpler than the math: same network, signal flowing the other way.

Pre-training, fine-tuning, inference — same machinery, different scales

PM decoder · "we trained a model on your data"

When a vendor says this, they usually mean one of three things. The cost and capability differences are orders of magnitude.

  • Pre-trained from scratch — almost nobody does this; it's a frontier-lab activity.
  • Fine-tuned — weights actually get nudged on your data. Real, not trivial.
  • Prompted with retrieval (RAG) — no weight changes; they just feed your data in via the prompt at inference time.

Split these three apart the way you split prefill and decode. Once you name them, the conversation changes.

§ 07Why this matters at the PM level

Trade-off

More layers = richer patterns, harder debugging. Depth buys capability but costs you interpretability and training stability. Every architectural decision is a product decision — capacity vs. cost, flexibility vs. controllability.

Latency

Each layer adds compute time. A forward pass through 80 layers is 80 sequential matrix multiplications per token. For streaming use cases this surfaces as time-to-first-token and tokens-per-second — the two metrics your users will actually feel.

Interpretability

Early layers are legible; later ones are abstract. You can often tell what a first layer detects. By layer forty, features are compositions of compositions. Explainability tooling exists for a reason — mechanistic interpretability is a whole field (Anthropic does a lot of it).

Cost

Parameter count drives everything. Memory, inference cost, training compute, deployment options. Scaling from a 7B to a 70B model is a 10× jump in every dimension — and not always a 10× jump in quality. This is the math behind "why not just use GPT-4 for everything."

Context

The latent space is where your product lives or dies. RAG, semantic search, personalization — all latent-space engineering. The model's representation of your domain is the substrate your features are built on.

TL;DR

Forward propagation is a step-by-step recipe for turning raw data into a decision. Inside an LLM call it runs once per output token.

  1. Input enters as numbers. For an LLM, that's tokens from a tokenizer, then vectors from an embedding table.
  2. Hidden layers transform. Each neuron is a weighted-sum-plus-activation deciding whether to pass a signal forward. Stacked deep, they compose simple patterns into abstract meaning.
  3. Latent space is the workspace. At every layer the data occupies a point in a high-dimensional space — progressively reorganized to highlight what matters for the task.
  4. The output layer commits. A class, a score, a probability distribution over the next token.

The "learning" happened during training, when billions of weights were tuned against examples. At inference time the model is just applying what it already knows — running the assembly line it's been taught to run. Understanding this gets you 80% of the way in any ML conversation; the rest is scale, architecture, and taste.