Depth is the number of successive computational layers in a neural-network architecture. In an artificial neural network, adding hidden layers lets the model build increasingly high-level abstractions and represent more complex classification boundaries. section 9.13 section 11.11
Depth matters because each layer adds another transformation:
- Shallow networks can represent simple relationships, such as a fairly simple nonlinear boundary. section 9.13
- Deeper networks can combine earlier outputs into higher-level abstractions for complex functions across many dimensions. section 9.13
- Choosing depth usually requires experimentation and iterative improvement rather than a fixed universal value. section 9.13
- Architecture setup defines the hidden-layer count alongside nodes, activation functions, inputs, outputs, and initial weights. section 9.6
Depth in a toy language model
A Transformer with two layers performs two successive processing steps in its reasoning chain. A larger model with twelve layers can perform a longer sequence of such steps. Depth is only one architectural choice: context window, embedding width, attention heads, and feed-forward size also affect the design. section 11.11
Table 11.7 The hyperparameters for the Transformer framework
|
Hyperparameter |
Rule of thumb |
Toy LLM example |
Real-world LLM |
| Vocabulary size (V) |
Based on training data |
34 sentence pieces |
50,000 (more than 250,000 sentence pieces |
| Context window (T) |
Longest prompt you need, rounded to power of 2, that still fits batch on a GPU |
32 tokens |
1,024 (more than 32,000 tokens) |
| Width (d) |
Start near 4√Vocabulary size |
4 channels |
768 (more than 20,000 channels) |
| Depth (L) |
1–2 layers per 100,000 characters of training text |
2 layers |
12 (more than 120 layers |
| Attention heads (h) |
h = Width ÷ 64 (round to even) |
1 head |
12 (more than 128 heads |
| Feed-forward size (dn) |
dn = 4 × Width is a safe default |
Layer 1: 8 neurons Layer 2: 4 neurons |
3,027 (more than 80,000 neurons) |
Compare toy and real-world Transformer depths alongside context windows, embedding widths, attention heads, and feed-forward sizes. section 11.11



