DWG № NN-001Field Guide · Sheet 1 of 1Reviewed 22 Sep 2026

The Anatomy of a
Neural Network

From one tiny decision-maker to the full machinery behind ChatGPT and Claude — explained with pizza orders, dart games, and sticky notes. Every diagram is live: poke it. No math degree needed.

Drawn forFullstack devs → AI Engineers
ScalePlain English
PrerequisitesCode literacy only
Chapter 01 / the tiny decision-maker

The Neuron

Many neural networks are built from a small mathematical unit called a neuron. Think of deciding "should I order pizza tonight?" You weigh a few facts: how hungry you are, how much money you have. Some facts matter more to you than others — that "how much it matters" number is called a weight. You also have a baseline craving no matter what — that's the bias. Add it all up, and a nonlinear activation shapes what is passed to the next layer.

decision = squash( hunger × importance₁ + budget × importance₂ + baseline )

That weighted-sum pattern is one building block. Large language models combine billions of learned parameters across attention and feed-forward layers rather than behaving as a pile of literal yes-or-no decisions.

FIG 1.1 — Play with the dials. Thicker line = that input matters more. Amber = pushes toward "yes", violet = pushes toward "no". The curve on the right is the squash step — see where your total lands on it.
Why the squash step matters: without it, stacking a million decisions would collapse into one boring straight-line rule, like a calculator that can only multiply. The little bend in the curve is what lets networks learn curvy, complicated things — faces, grammar, sarcasm.
WeightsImportance dials. "Learning" literally means finding good settings for billions of these dials.
BiasA head start. Like already being 70% sure of pizza before checking your wallet.
ReLUThe simplest version says, "if the total is negative, use zero." Modern architectures may instead use GELU, SiLU, or related functions.
SigmoidMaps any number between 0 and 1. That output can act like a score, but it is not automatically a calibrated probability.
Chapter 02 / decision-makers in teams

Layers & the Forward Pass

One neuron makes one tiny judgment. Put a row of them side by side and you get a layer — a panel of judges all looking at the same facts, each caring about different things. Stack several panels and you get a company hierarchy: junior analysts spot simple patterns, managers combine those into bigger ideas, and a director makes the final call.

Real example — a network looking at a photo: the first layer notices edges and blobs of color. The next layer combines edges into shapes like ears and whiskers. A deeper layer combines those into "this looks like a cat." Nobody programmed "ear" or "whisker" — the layers figured out those stepping stones on their own.

One full trip of information from input to answer is called the forward pass. Press play:

idle — 3 facts in → 2 teams of 5 → final answer
neuronsignal passing throughfinal answer
FIG 2.1 — Facts flow left to right, each layer building on the last layer's opinions. This exact ripple happens every time you send a message to ChatGPT or Claude — just with billions of neurons instead of 15.
Input layerThe raw facts: pixels of a photo, words of a sentence (as numbers).
Hidden layersThe middle teams. More layers = "deeper" network = can learn more abstract ideas.
Output layerShaped like the answer: one number for "house price", or one per option for "cat / dog / bird".
ParametersAll the dials (weights + biases) counted together. A "7B model" has 7 billion dials.
Chapter 03 / how the dials get set

Training: Loss & Gradient Descent

A brand-new network has all its dials set randomly, so its answers are garbage. Training is like learning darts blindfolded, with a friend shouting how far you missed by:

1) Throw (make a prediction). 2) Friend shouts your miss distance — that score is the loss. 3) Figure out which part of your throw caused the miss — arm too high? too much force? That blame-tracing is backpropagation. 4) Adjust each part slightly and throw again. Repeat millions of times until you're hitting bullseyes.

The adjust-and-retry part has a fancy name — gradient descent — but it's just walking downhill in fog: you can't see the bottom of the valley, but you can feel which way slopes down, so you take a step that way. How big a step? That's the learning rate. Try it:

step 0 · loss —
FIG 3.1 — The ball is the model, height = how wrong it is. With small steps it gets comfy in the first dip (a "local minimum") and never finds the truly best spot. Crank the step size up and it can jump out — but too big and it bounces around like a caffeinated kangaroo. Finding the sweet spot is half of real ML work.
LossThe "how wrong was I" score. Lower = better. Training only ever tries to shrink this number.
BackpropagationBlame-tracing: works backwards through every layer asking "how much did YOU contribute to the miss?"
OptimizerThe adjustment strategy. The popular one, Adam, is like a smart hiker with momentum — it remembers which direction has been working.
Epoch & batchBatch = how many practice throws before adjusting. Epoch = one full run through all your practice examples.
One more word you'll hear — overfitting: when the model memorizes the practice examples instead of learning the pattern. Like a student who memorized last year's exam answers and fails the moment a question is reworded.
Chapter 04 / turning words into numbers

Tokens & Embeddings

Networks only eat numbers — so how do they read? Two steps.

Step 1 — chop: text is snapped into tokens, LEGO-brick pieces of words. Common words are one brick ("the", "cat"); rare words get built from smaller bricks ("unbelievable" → un + believ + able). Each brick has an ID number in a big fixed dictionary. This is why AI services charge "per token" — it's per LEGO brick.

Step 2 — locate: each token ID looks up its embedding — a long list of numbers that works like GPS coordinates on a map of meaning. On this map, "king" sits near "queen", "pizza" near "burger", and "happy" far from "furious". The model learned this map itself, just from reading. Finally, since a bag of coordinates has no order, each token gets a seat number (positional encoding) so the model knows "dog bites man" ≠ "man bites dog".

FIG 4.1 — One word → three LEGO bricks → three coordinate lists (only 6 of ~4,096 numbers shown) → plus a seat number each. These flow into the model.
Token~¾ of a word on average. "Hello world!" is 3 tokens.
EmbeddingThe coordinates-of-meaning list. Nearby = similar meaning.
Positional encodingThe seat numbers. Without them, a sentence is just a word salad.
Context windowHow many tokens fit on the model's desk at once. Exceed it and the oldest ones fall off.
Chapter 05 / the billion-dollar idea

Self-Attention

Read this sentence: "The robot picked up the ball because it was heavy." What does "it" mean — the robot or the ball? Your brain answered instantly by glancing back at earlier words and weighing which fits. Attention is exactly that glance-back, done with math. For every word, the model asks: "which other words in this sentence help me understand this one?" — and borrows meaning from them, in proportion to how relevant they are.

Under the hood it works like a room full of people wearing name tags. Each word shouts a question ("I'm a pronoun — who's a heavy object around here?"), reads everyone's name tag to see who's relevant, then listens to what the relevant ones actually say. In the papers these three are called Query, Key, and Value — but it's just shout, scan tags, listen.

FIG 5.1 — Select any word to inspect an illustrative attention pattern. Select it to see weight distributed across earlier context; thicker arcs mean larger weights. The second pattern emphasizes neighboring tokens. These hand-tuned examples build intuition, but learned attention heads do not have guaranteed human-readable jobs.
Multi-headSeveral learned attention projections run in parallel, allowing the model to represent different relationships. Researchers sometimes observe patterns, but a head is not guaranteed to own one concept.
Causal maskIn chat models, words may only look backwards. No peeking at the future — that's the word being predicted!
Why it wonEvery word can check every other word instantly and in parallel — perfect for GPUs. Older designs read one word at a time, like sipping a book through a straw.
KV cacheA speed trick: remember earlier words' name tags so they aren't re-read for every new word generated.
Chapter 06 / the repeating factory station

The Transformer Block

Attention alone isn't enough — it gets wrapped with three helpers into a block, one factory station on an assembly line. The best mental model: attention is the group discussion (words share info with each other), and the feed-forward part is individual homework (each word goes off and thinks alone about what it just heard). Do discussion → homework, and you've got one block. Stack that station 30–80 times and you've got a frontier model.

Tap each part of the schematic to see its job in plain words:

Select a componentData flows bottom → top. The dashed lines that skip around the sides are the clever trick that makes very deep networks possible.
FIG 6.1 — One block. Small models stack ~12 of these; the biggest stack ~100. That's genuinely the whole architecture.
Residual connectionBefore editing anything, keep a photocopy of the original and staple it to the edited version. Nothing important ever gets lost, no matter how many stations the data passes through.
LayerNormA volume normalizer. Keeps the numbers in a comfortable range so no station gets deafened or has to strain to hear.
Feed-forward (MLP)The individual-homework step. Surprisingly, this is where most of the model's dials — and most of its stored "knowledge" — live.
AttentionThe group-discussion step from Chapter 05 — the only place words talk to each other.
Chapter 07 / putting it all together

The Full Model & How It Writes

Here's the secret that surprises everyone: ChatGPT, Claude, Llama — under the hood, each is a very fancy autocomplete running in a loop. The recipe: words → coordinates (Ch. 04) → through the stack of blocks (Ch. 06) → out comes a probability for every word in the dictionary as the next word. Pick one, glue it onto the sentence, run the whole thing again. Every AI answer you've ever read was written one token at a time this way.

How it picks is controlled by temperature — an adventurousness dial. Low: always take the safest word (reliable, a bit boring). High: give unlikely words a real chance (creative, occasionally unhinged). Try it:

FIG 7.1 — Slide temperature to 0.1 and the most likely option dominates. At 2.0, less likely options receive more probability. Many model APIs expose temperature, although supported sampling controls vary by model and provider.
ProbabilitiesA distribution over possible next tokens. These scores guide generation, but they are not confidence estimates for the truth of an answer.
Temperature / top-pCommon sampling controls that reshape or limit the next-token distribution. Availability and behavior vary across APIs.
PretrainingLearning statistical patterns from large datasets, commonly through next-token prediction. Training mixtures and objectives vary between model families.
Why answers stream word-by-wordBecause that's literally how they're made — the loop runs once per token.
Chapter 08 / changing behavior and supplying knowledge

Model Adaptation & Grounding

Fine-tuning changes model behavior

A freshly pretrained model is like a brilliant medical graduate — enormous general knowledge, zero bedside manner, no specialty. Fine-tuning is the residency: continue its training on a smaller, focused set of examples so it learns a specific job — answer like a support agent, write in your brand's voice, output your exact report format. Three ways to do it, differing in how much of the brain you retrain:

Full fine-tune

Retrain every single dial. This offers maximum flexibility but requires considerably more memory, compute, data, and operational care. It is not automatically better than a focused adapter.

LoRA

Freeze the textbook, add sticky notes. The base weights stay frozen while small low-rank matrices are trained. This can sharply reduce trainable parameters and memory, depending on the model and configuration.

QLoRA

Sticky notes on a paperback. The frozen base model is quantized while low-rank adapters are trained. This reduces memory requirements, with quality and hardware needs depending on model size and training choices.
MethodDials retrainedHardware needed (8B model)When to use
Full fine-tune100%high-memory or multiple GPUsWhen broad weight updates justify the cost
LoRAa small subsetoften one capable GPUEfficient task or behavior adaptation
QLoRAa small subsetless memory than standard LoRAAdapter training under tighter memory limits
Prompting / RAG0%none when using an APIEvaluate before training

A simplified model-development pipeline

FIG 8.1 — A useful high-level model is pretraining, supervised instruction tuning, and preference optimization. Real systems can use additional objectives, synthetic data, safety training, evaluation, and product-level controls.
Golden rule for real projects — escalate in this order: ① just ask better (prompt engineering) → ② hand the model your documents to read (RAG) → ③ fine-tune. Fine-tuning teaches style and skills; handing over documents supplies facts. Most production problems are solved at ① or ② and never need ③.
Where the analogies stop: this guide intentionally compresses architecture and training details to build intuition. Model families differ in activations, normalization, positional methods, attention variants, data mixtures, training objectives, and alignment techniques.

What "RAG" means — in one picture

Models only know what they read during training, and they can't see your files. RAG (retrieval-augmented generation) is the workaround, and it's beautifully unglamorous: when a question comes in, search your own documents, and paste the relevant pages into the prompt along with the question. The model answers using what's in front of it — like an open-book exam instead of a memory test.

RAG or agent? Retrieval gives a model relevant knowledge; an agent chooses and performs actions. Read the practical comparison: AI Agents vs RAG.
FIG 8.2 — RAG can reduce unsupported answers when retrieval returns relevant, trustworthy context. It does not guarantee correctness; production systems still need source citations, evaluation, access controls, and fallback behavior.
Chapter 09 / where to go from here

Your Path

P1

Build intuition (2–3 wks)

Watch, then rebuild the core ideas on this page in simple Python.

P2

Understand transformers (2–3 wks)

Follow a small GPT implementation and compare the code with a visual walkthrough of the architecture.

P3

Adapt something real (2–3 wks)

Start with prompting and retrieval, then use LoRA or QLoRA when evaluation shows that training is warranted.

P4

Ship and evaluate (ongoing)

Build a small end-to-end product with structured outputs, tools, evaluations, observability, latency and cost budgets, privacy controls, and defenses against prompt injection.

Chapter 10 / pocket glossary

Jargon Decoder

Every term from this guide (plus a few you'll meet on day one of any tutorial), in one table. Screenshot this.

When you hear…Think…
Weight / parameterOne importance dial. "7B model" = 7 billion dials.
BiasA head start added before deciding.
ActivationThe squash step that turns a total into a firing strength.
LayerA team of decision-makers looking at the same input.
Forward pass / inferenceRunning data through the model to get an answer. "Inference" = using the model (vs. training it).
LossThe "how wrong was I" score. Training only ever shrinks this.
Gradient descentWalking downhill in fog toward "less wrong".
Learning rateStep size. Too small = crawling, too big = kangaroo.
BackpropagationBlame-tracing: which dial caused the miss?
OverfittingMemorizing the practice exam instead of learning the subject.
TokenA LEGO brick of text, ~¾ of a word. AI is priced per brick.
EmbeddingGPS coordinates on a map of meaning.
AttentionEach word glancing at the others to work out what matters.
TransformerThe architecture: group discussion + individual homework, stacked many times.
Context windowHow much text fits on the model's desk at once.
TemperatureAdventurousness dial when picking the next word.
PretrainingLearning broad statistical patterns from a large data mixture, often through next-token prediction.
Fine-tuningThe residency: extra training for a specific job.
LoRA / QLoRASticky notes on a frozen (or compressed) textbook — cheap fine-tuning.
RAGOpen-book exam: search your documents, paste the pages into the prompt.
HallucinationConfidently making things up. Reduced by RAG, never fully cured.
GPU / VRAMThe specialized chip that does the math / its onboard memory — the scarce resource everything is measured against.
AgentA model in a loop that can use tools (search, code, your APIs) to finish multi-step tasks.
Sources / primary reading

References & Further Reading

The diagrams and analogies are original explanations informed by these foundational papers. They are starting points, not a claim that every current model uses the same implementation.

  1. Vaswani et al., Attention Is All You Need (2017).
  2. Hu et al., LoRA: Low-Rank Adaptation of Large Language Models (2021).
  3. Dettmers et al., QLoRA: Efficient Finetuning of Quantized LLMs (2023).
  4. Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (2020).