Reproducing Toy Models of Superposition: Training a Tiny Compression Network in NumPy
Discover how building a minimalist neural network from scratch in pure NumPy without borrowed numbers or automated gradient libraries reveals fundamental principles of data compression and superposition.
Neural network interpretability often feels like navigating a black box, but stripping away high-level frameworks exposes the raw mechanics of representation learning. According to the investigation published on Towards Data Science, training a miniature autoencoder using hand-derived gradients in pure NumPy spontaneously causes the hidden layer to geometric structures like a regular pentagon when forced to compress high-dimensional inputs.
Architectural Setup of the NumPy Compression Network
To replicate Anthropic's superposition phenomena without hidden abstractions, the architecture relies on a deterministic bottleneck layer designed to project inputs into a lower-dimensional subspace. The network takes continuous feature vectors and passes them through a single linear encoder followed by a non-linear activation, before attempting reconstruction via a symmetrical decoder.
Key Takeaways
- Built entirely in pure NumPy with hand-derived backpropagation gradients.
- Forces a high-dimensional feature space through a 2D bottleneck layer.
- Spontaneously develops geometric representations such as a regular pentagon during training.
Implementing Forward and Backward Passes Without Autograd
Writing custom gradient descent updates forces absolute clarity on matrix dimensions and derivative chains. Below is the core training step executing forward projections and weight updates manually across NumPy arrays.
import numpy as np
# Initialize weights with standard deviation scaling
np.random.seed(42)
W_enc = np.random.randn(2, 5) * 0.1
W_dec = np.random.randn(5, 2) * 0.1
def forward_backward(X, lr=0.01):
# Forward pass
hidden = np.dot(X, W_enc.T)
reconstructed = np.dot(hidden, W_dec.T)
# Loss computation (MSE)
loss = np.mean((reconstructed - X) ** 2)
# Backward pass (hand-derived gradients)
grad_loss = 2 * (reconstructed - X) / X.size
grad_dec = np.dot(grad_loss.T, hidden)
grad_hidden = np.dot(grad_loss, W_dec)
grad_enc = np.dot(grad_hidden.T, X)
# Weight update
global W_enc, W_dec
W_enc -= lr * grad_enc
W_dec -= lr * grad_dec
return lossEmergence of Geometric Superposition in Bottleneck Layers
When the input dimensionality exceeds the bottleneck capacity, the network cannot store every feature orthogonally. Instead, optimization pressure forces the weight vectors to arrange themselves into symmetric polygons - in this specific experiment, perfectly outlining the vertices of a pentagon to maximize information density.
| Optimization Parameter | Experimental Value | Architectural Impact |
|---|---|---|
| Input Dimensions | 5 Features | Baseline feature space |
| Bottleneck Latent Space | 2 Dimensions | Enforces compression and superposition |
| Activation Function | Linear / ReLU | Governs weight vector angular distribution |
Validating Weight Vector Coordinates and Feature Angles
Inspecting the weight matrix post-training reveals that the feature vectors converge to precise angular separations matching regular polygons. Developers studying mechanistic interpretability can use this minimalist setup to test feature interference, sparsity penalties, and polysemanticity without incurring heavy GPU overhead or framework bloat.
Conclusion
Building neural networks from first principles in NumPy strips away framework magic and lays bare the mathematical elegance of representation learning. Observing a tiny network spontaneously draw a pentagon proves that geometric superposition is an inevitable mathematical consequence of optimizing capacity constraints under informational pressure.
Related Articles
Sep 23, 2026 · 01:03 PM
YouTube Music Integrates Conversational AI Pipelines for Real-Time Query Resolution
YouTube Music introduces advanced conversational AI discovery tools and personalized podcast routing models to optimize contextual user queries. The update shifts streaming interfaces toward multimodal language interactions.
Sep 23, 2026 · 12:22 PM
Scaling Developer Ecosystems: Two Years of OpenAI Academy and Global AI Literacy
Analyzing the two-year operational milestone of OpenAI Academy and its measurable impact on regional developer communities, custom fine-tuning adoption, and localized model training.
Sep 23, 2026 · 12:09 PM
YouTube Automates Creator Workflows With Native Multimodal AI Thumbnail and Ideation Engines
YouTube is rolling out an advanced suite of multimodal creator tools designed to automate high-friction workflows like thumbnail generation and performance analytics. Announced at the annual Made on YouTube event, these agentic features shift creator operations from manual experimentation to automated system optimization.