DWG № NN-001Field Guide · Sheet 1 of 1Rev. 2026-07

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

Everything in AI is built from one tiny machine that makes one tiny decision. 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 final "squash" step (the activation) turns the total into how strongly you say yes.

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

That's the whole formula. A model like ChatGPT is just billions of these tiny yes/no-ish decisions wired together.

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 squash: "if the total is negative, just say zero." Used inside almost every modern model.
SigmoidTurns any number into a 0–100% confidence. Great for final answers like "spam or not spam?"
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 — Tap any word to see where it looks. Tap it: the model splits its attention between "robot" and "ball" — thicker arc = looking harder. Then switch to Head B: same sentence, totally different pattern — this head only cares about neighboring words (grammar). Real models run dozens of such heads at once, each proofreading for something different. That parallel crowd of glances is the engine inside GPT, Claude, and Gemini.
Multi-headMany attention "glances" run at once — one head tracks grammar, another tracks who "it" refers to, another tracks position. Like proofreading a sentence several times, looking for something different each pass.
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:

Tap 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 tap: you'll get "mat" every time. Slide to 2.0 and tap a few times: suddenly the cat sits on the keyboard, or the moon. This is the exact dial you'll set in every AI API call you ever make.
ProbabilitiesThe model's honest odds for every possible next word. All of AI text generation is just sampling from these.
Temperature / top-pThe two sampling dials in every AI API. You'll tune these constantly as an AI engineer.
PretrainingHow the base model got smart: it played "guess the next word" on trillions of words of internet text. That's it. That one game, at scale, taught it grammar, facts, and reasoning.
Why answers stream word-by-wordBecause that's literally how they're made — the loop runs once per token.
Chapter 08 / giving a model a specialty

Fine-Tuning

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. Best possible results, but you need the whole giant model loaded for training — think a room full of expensive GPUs. Big-company territory.

LoRA

Freeze the textbook, add sticky notes. The huge model stays untouched; you train tiny add-on notes beside it (under 1% of the dials). Nearly as good, hugely cheaper, and the "notes" file is small enough to email. The industry default.

QLoRA

Sticky notes on a paperback. First shrink the frozen model into a compressed low-precision version, then add the notes. Quality barely drops — and now it fits on one gaming GPU or a free-ish Colab. How hobbyists fine-tune at home.
MethodDials retrainedHardware needed (8B model)When to use
Full fine-tune100%a GPU clusterYou're a lab with big data & budget
LoRA<1%one good GPUThe default for most real projects
QLoRA<1%one gaming GPU / ColabLearning & hobby projects — start here
Just prompting / RAG0%none — use an APIAlways try this first

How a chatbot is actually made — 3 stages

FIG 8.1 — Stage 1: read the whole internet, learn to autocomplete (raw talent). Stage 2: study thousands of example conversations, learn to be a helpful assistant (manners). Stage 3: humans rank its answers best-to-worst and it learns their taste (polish). That pipeline is how you get from "autocomplete" to ChatGPT.
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 ③.

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 — This also reduces hallucination — the model's habit of confidently making things up when it doesn't know. Give it the real pages and it has far less need to invent. As an AI engineer you'll build this pipeline more often than you'll ever fine-tune.
Chapter 09 / where to go from here

Your Path

P1

Build intuition (2–3 wks)

Watch, then rebuild everything on this page yourself in simple Python. It's genuinely doable.

→ 3Blue1Brown "Neural Networks" (YouTube, visual & gentle) · Karpathy "Zero to Hero" (build it from scratch)
P2

Understand transformers (2–3 wks)

Follow along as someone builds a mini-ChatGPT live, and read a picture-based walkthrough of the architecture.

→ Karpathy "Let's build GPT" · Jay Alammar "The Illustrated Transformer" (blog, all pictures)
P3

Fine-tune something real (2–3 wks)

Use QLoRA to teach a small open model your own dataset — in a free browser notebook. Compare before vs after.

→ HuggingFace free course (huggingface.co/learn) · Unsloth notebooks (easiest starting point)
P4

The AI engineer job (ongoing)

Prompting, letting models read your documents (RAG), calling tools, building agents. This is where your React/Node skills make you dangerous — you can ship the whole product, not just the model part.

→ Anthropic & OpenAI API docs · start with one small end-to-end project
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 autocomplete from the whole internet. Builds raw talent.
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.