AI Fundamentals: Neural Networks
The general public has become increasingly aware of the potentially world-changing capabilities and dangers of AI. An onslaught of solved mathematical problems1 and cyberattacks2 has helped legitimize the idea of superhuman AI in the eyes of the public, as well as policymakers. Every day, we see op-eds and blog posts on whether AI will or won’t replace humans in a particular sector of the economy, or even the economy as a whole. What has irritated me about most of this writing is the fact that it inadequately explains some of the key ideas that the authors are taking into consideration when making important forecasts. For example, AI 2027 only briefly mentions reinforcement learning in spite of the fact that it’s core to understanding why the rogue AIs it predicts might emerge.3 What I want to do with the following essays is take a smart reader interested in understanding what will happen with AI, and explain the key concepts underlying how it works in sufficient detail that they can reason about its future growth from first principles, rather than looking at something like the graph below and taking its implications on faith alone.4
This series of essays will cover the following topics:
- Neural networks
- Large language model basics
- Advanced large language models
- Implications for alignment and generalization of intelligence
- Predictions
Neural networks
Large language models are fundamentally based on neural networks. Neural networks are loosely inspired by how real brains work, where a collection of neurons are interconnected in a way that allows them to process information.5 The simplest useful neural network is the multilayer perceptron (MLP).6
Scroll sideways to see the whole diagram →
We can get a better understanding of how the MLP works by seeing how it can be applied to a classic machine vision problem, the classification of digits from images. Our goal will be inputting an image and receiving an output that shows the number most likely to be in the image. A black-and-white image can be thought of as a list of numbers ranging from zero to one, with each number representing the brightness of a pixel in the image.
Brightness
0 (black)1 (white)
Each square is one pixel; its number is its brightness.
Click a pixel to make it brighter. After white it goes back to black.
↓ Read row by row into a list of 25 numbers:
- 0.0
- 0.1
- 0.9
- 0.1
- 0.0
- 0.1
- 0.4
- 1.0
- 0.4
- 0.1
- 0.9
- 1.0
- 1.0
- 1.0
- 0.9
- 0.1
- 0.4
- 1.0
- 0.4
- 0.1
- 0.0
- 0.1
- 0.9
- 0.1
- 0.0
In our example, the images come from the MNIST dataset, a collection of 70,000 black-and-white images of handwritten digits.7 Each image is 28 x 28 pixels in size, meaning they have 784 pixels, and therefore 784 real-valued inputs we can feed into our MLP. The MLP’s first layer, the input layer, should therefore have 784 neurons. Each unique image we feed into our MLP will activate the neurons in the input layer differently.
The neurons in the input layer feed into the hidden layers in the network. Let’s give our multilayer perceptron 2 hidden layers with 16 neurons each.8 There can be an arbitrary number of hidden layers in the network, and each layer can have an arbitrary number of neurons. Each neuron in the hidden layer will also have some kind of value, one that is calculated from the values of every single neuron in the previous layer. For the first hidden layer in our network, that means the 16 neurons in it calculate their values from the 784 values of the input layer. The calculation that each neuron performs is as follows:
Scroll sideways to see the whole diagram →
Value of the highlighted neuron (neuron 1 in hidden layer 1):
a1(1) = σ( w1a1 + w2a2 + w3a3 + … + w784a784 + b )
= σ( Σ wiai + b ), summed over all 784 inputs
a = input values, w = weights, b = bias, σ = activation function
Try it: one neuron with three inputs
z = w₁a₁ + w₂a₂ + w₃a₃ + b = 0.92
output = ReLU(z) = 0.92
Each neuron has its own weight for every input, and multiplies each input by its weight. These multiplied values are then summed together. A bias is then added to this sum. We then pass this through an activation function. This function can be something like ReLU, which gives a zero when the input is anything less than zero, but is equal to the input for all input values above zero. The reason we need an activation function is that otherwise all the layers could just be described by a single linear function, which is undesirable when you want to approximate the complicated functions describing real-world data.9 Every neuron in the hidden layers will have its own set of weights and biases. The final hidden layer will feed into an output layer.
Our output layer has 10 neurons, each of which corresponds to one of the 10 digits. The neurons in this layer complete the same mathematical operation as the neurons in the hidden layers, taking a weighted sum, adding a bias, then inputting the resulting value into an activation function. However, since we’d like our output to be a probability distribution of which digits are most likely to be the one in the image, we use softmax as the activation function.10 This turns the raw values we get into a valid probability distribution, with properties such as all of the values summing to 1 and no negative values. This is important, since it doesn’t make sense for a given digit to be -2% or 120% likely.
We can now imagine the MLP as one big function that takes in 784 inputs and spits out 10 outputs, with its weights and biases acting as the constants in the function. Seeing this, two key questions come to mind. Firstly, why does the MLP’s particular structure lend itself to recognizing digits, as well as other complex objects? Secondly, how do we find weights and biases that lead to the MLP effectively recognizing digits and other complex objects?
The first question can be answered through a half-true story. A network with well-tuned parameters could theoretically break down the image into something like horizontal, vertical and diagonal edges in its first hidden layer. For instance, a neuron that detects horizontal edges at the very top of the image might set the weights corresponding to those pixels to very high values, while pixels at the bottom of the image have weights with values close to zero. The second hidden layer might detect larger features, like circles or long lines, which would be composed of combinations of edges. The output layer would then see which combination of activations occurs in the second hidden layer and determine which digit it’s likely to be, since digits are composed of unique features. For example, a 6 is composed of a circle at the bottom and a diagonal line at the top, while a 7 is composed of a diagonal line in the center and a horizontal line on top. This is an explanation that is intuitive to humans.
(a) The intuitive story: how we might imagine the network recognises a 9
Input image

Hidden layer 1:
small strokes






Hidden layer 2:
loops and lines


Output
(b) What hidden layer 1 actually learns: the weights of its 16 neurons after training
















Each square shows one neuron’s 784 incoming weights, laid out as a 28 × 28 image. White = positive weight (a bright pixel here raises the neuron’s value), black = negative, grey ≈ 0.
Network: 784–16–16–10 MLP trained on 50,000 MNIST images; 95.5% accuracy on 10,000 held-out images.
The reality is somewhat more complex. When we train actual neural networks, the activations in the hidden layers are not what a human would expect at all.11 There is no neat, comprehensible structure to the features that are actually detected, only the activations and weights that result in the highest probability of guessing the digit correctly. But it’s still useful to think of neural networks as recognizing structure and features in data, just not necessarily features that are intuitive to humans.
This naturally leads us to ask what process actually sets the messy weights and biases in the network. We have 784 input neurons, 2 hidden layers with 16 neurons each and 10 output neurons. We can count the number of parameters to set like this:
Input to hidden layer connections (weights): 784 x 16 = 12,544
Hidden layer to hidden layer connections (weights): 16 x 16 = 256
Hidden layer to output layer connections (weights): 16 x 10 = 160
Biases: 16 + 16 + 10 = 42
Total parameter count: 12,544 + 256 + 160 + 42 = 13,002
It’s apparent that there are too many parameters to fine-tune manually. Therefore we need an algorithm which allows us to adjust these parameters until the network gets good at detecting digits. The first step towards that is an actual measure of how good the network is at detection. The measure used is called cross-entropy loss.12 We take an image, feed it into the neural network and find the likelihood it assigns to the correct answer, then calculate its negative logarithm. If we had an image of a “7” and the network assigned it a probability of 1.0 of being a 7, the loss would be 0. If the probability was 0.76, the loss would be 0.27. And if the probability was 0.05, the loss would be 3.0. The more confidently correct the network is, the lower the loss. The more confidently incorrect the network is, the higher the loss.
Now that we have a measure of how good the network is at predicting digits, we need to figure out a process that adjusts its parameters in a way that minimizes the loss. This is called gradient descent.13 Imagine a function with the 13,002 parameters as inputs and the network’s cross-entropy loss as the output. It’s computationally infeasible to graph the entire function, but it is possible to find its slope at a given point. Gradient descent takes steps in the direction where the slope of this function is negative, recomputes the slope after the step and then keeps taking steps downwards. In practice, you do stochastic gradient descent, where you estimate the slope from small batches of training data instead of the entire dataset.14 The steps are noisier, but it’s much cheaper to compute.
Doing any form of gradient descent the naive way, where you wiggle each parameter’s value individually and see how it affects the loss, is very computationally expensive. Instead, you do backpropagation, where you see how much each neuron in the previous layer contributed to the loss at the current neuron and then propagate that all the way back to the first layer. This allows you to compute the gradient about as cheaply as a forward pass of the neural network, making it computationally feasible to train larger neural networks.15
What we’ve learned in this section has non-trivial implications for current AI models and their development. For instance, the fact that training loss is a verifiable metric has implications for whether models can be post-trained to be good at machine learning research. Another is the idea that neural networks should be trying to recognize features and structures in their input data to generate accurate outputs. Finally, there’s the fact that models do not necessarily “understand” the data they process. They might be internalizing some kind of pattern that helps minimize loss during training, but these patterns are not necessarily related to any kind of humanly understood notions relating to digits or writing. This could even involve exploiting flaws in the training data, such as a particular quirk in how the dataset creators drew “7”s that the rest of humanity doesn’t really have when writing “7”.16
The next essay will describe the neural network architecture that modern large language models actually use, the transformer architecture,17 which combines MLPs, networks called “attention blocks” and normalization steps. It will also explain how LLMs encode the language data they process, which is somewhat different from how the simple MLP in this essay encodes vision data.
I also have to mention that this essay is heavily based on 3Blue1Brown’s Deep Learning series.18 If you want an even deeper and more intuitive explanation of the concepts presented here, please check it out. I mostly wrote it because a ~1,600-word essay might be easier to get through than ~60 minutes of videos for a certain friend of mine. I also want to give that friend a big nod of appreciation for giving me the motivation to start writing this series of essays.
Notes
- Kakaes, “Why the Legendary Erdős Problems Are Falling to AI”; Feng et al., “Semi-Autonomous Mathematics Discovery with Gemini.” ↩
- Anthropic, “Disrupting the First Reported AI-Orchestrated Cyber Espionage Campaign.” ↩
- Kokotajlo et al., AI 2027. ↩
- METR, “Task-Completion Time Horizons of Frontier AI Models,” which is also the source of Fig. 1; the method is described in Kwa et al., “Measuring AI Ability to Complete Long Software Tasks.” ↩
- Rosenblatt, “The Perceptron,” 386–408, which introduced the perceptron as a model of how the brain might store information and recognise patterns. ↩
- Goodfellow, Bengio and Courville, Deep Learning, ch. 6, “Deep Feedforward Networks,” which introduces multilayer perceptrons as the basic deep learning model. ↩
- LeCun, Cortes and Burges, “The MNIST Database of Handwritten Digits.” The 70,000 images are split into a 60,000-image training set and a 10,000-image test set, and were derived from handwriting samples collected by NIST. ↩
- This 784–16–16–10 network is the same example used in 3Blue1Brown, “But what is a neural network?,” chapter 1 of its deep learning series. ↩
- Goodfellow, Bengio and Courville, Deep Learning, ch. 6, on rectified linear units and on why stacking layers without a nonlinear activation function still produces a linear function. ↩
- Goodfellow, Bengio and Courville, Deep Learning, ch. 6, on softmax output units. ↩
- 3Blue1Brown, “Gradient descent, how neural networks learn,” chapter 2 of its deep learning series, which looks at the weights such a network actually learns. ↩
- Goodfellow, Bengio and Courville, Deep Learning, ch. 6, on cross-entropy cost functions. ↩
- Goodfellow, Bengio and Courville, Deep Learning, ch. 4, “Numerical Computation,” on gradient-based optimisation. ↩
- Robbins and Monro, “A Stochastic Approximation Method”; Goodfellow, Bengio and Courville, Deep Learning, ch. 8, “Optimization for Training Deep Models,” on stochastic gradient descent. ↩
- Rumelhart, Hinton and Williams, “Learning Representations by Back-Propagating Errors”; Goodfellow, Bengio and Courville, Deep Learning, ch. 6, on back-propagation and its computational cost. ↩
- For a survey of networks that learn unintended shortcuts in their training data, see Geirhos et al., “Shortcut Learning in Deep Neural Networks.” ↩
- Vaswani et al., “Attention Is All You Need.” ↩
- 3Blue1Brown, “Neural Networks.” ↩
Bibliography
- 3Blue1Brown (Grant Sanderson). “Neural Networks.” Deep learning video series. https://www.3blue1brown.com/topics/neural-networks.
- Anthropic. “Disrupting the First Reported AI-Orchestrated Cyber Espionage Campaign.” November 13, 2025. https://www.anthropic.com/news/disrupting-AI-espionage.
- Feng, Tony, Trieu Trinh, Garrett Bingham, et al. “Semi-Autonomous Mathematics Discovery with Gemini: A Case Study on the Erdős Problems.” arXiv:2601.22401, 2026. https://arxiv.org/abs/2601.22401.
- Geirhos, Robert, Jörn-Henrik Jacobsen, Claudio Michaelis, Richard Zemel, Wieland Brendel, Matthias Bethge, and Felix A. Wichmann. “Shortcut Learning in Deep Neural Networks.” Nature Machine Intelligence 2 (2020): 665–673. https://arxiv.org/abs/2004.07780.
- Goodfellow, Ian, Yoshua Bengio, and Aaron Courville. Deep Learning. Cambridge, MA: MIT Press, 2016. https://www.deeplearningbook.org/.
- Kakaes, Konstantin. “Why the Legendary Erdős Problems Are Falling to AI.” Quanta Magazine, August 3, 2026. https://www.quantamagazine.org/why-the-legendary-erdos-problems-are-falling-to-ai-20260803/.
- Kokotajlo, Daniel, Scott Alexander, Thomas Larsen, Eli Lifland, and Romeo Dean. AI 2027. AI Futures Project, April 3, 2025. https://ai-2027.com/.
- Kwa, Thomas, Ben West, Joel Becker, et al. “Measuring AI Ability to Complete Long Software Tasks.” NeurIPS 2025. arXiv:2503.14499. https://arxiv.org/abs/2503.14499.
- LeCun, Yann, Corinna Cortes, and Christopher J. C. Burges. “The MNIST Database of Handwritten Digits.” https://yann.lecun.com/exdb/mnist/.
- METR. “Task-Completion Time Horizons of Frontier AI Models.” Last updated September 8, 2026. https://metr.org/time-horizons/.
- Robbins, Herbert, and Sutton Monro. “A Stochastic Approximation Method.” Annals of Mathematical Statistics 22, no. 3 (1951): 400–407. https://doi.org/10.1214/aoms/1177729586.
- Rosenblatt, Frank. “The Perceptron: A Probabilistic Model for Information Storage and Organization in the Brain.” Psychological Review 65, no. 6 (1958): 386–408. https://doi.org/10.1037/h0042519.
- Rumelhart, David E., Geoffrey E. Hinton, and Ronald J. Williams. “Learning Representations by Back-Propagating Errors.” Nature 323 (1986): 533–536. https://doi.org/10.1038/323533a0.
- Vaswani, Ashish, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. “Attention Is All You Need.” Advances in Neural Information Processing Systems 30 (2017). https://arxiv.org/abs/1706.03762.