© 2026 Unknown Observer

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.

Sep 23, 2026 · 12:42 PM·7 min read

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.

pythonCode Snippet
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 loss

Emergence 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 ParameterExperimental ValueArchitectural Impact
Input Dimensions5 FeaturesBaseline feature space
Bottleneck Latent Space2 DimensionsEnforces compression and superposition
Activation FunctionLinear / ReLUGoverns 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