People call LLMs "black boxes" all the time. Once you train your first neural network, the phrase starts to sound strange, because nothing in the model is actually hidden. You can print every single parameter in it.

So what is "black" about the box?

A model you can fully inspect

Here is a small network that recognizes handwritten digits (the MNIST dataset). Each image is 28×28 grayscale pixels, flattened into 784 numbers:

from torch import nn model = nn.Sequential( nn.Linear(784, 100), # 100 hidden neurons nn.ReLU(), nn.Linear(100, 10) # 10 outputs, one per digit 0–9 ) 

Each neuron has one weight per input and one bias. Together, the weights and biases are the model's parameters: the numbers it learns during training.

Layer Weights Biases
Linear(784, 100) 784 × 100 = 78,400 100
Linear(100, 10) 100 × 10 = 1,000 10

That's 79,510 parameters in total. After training, this model gets most test digits right, and you can look at every one of them:

print(model[0].weight) # all 78,400 weights of the first layer print(sum(p.numel() for p in model.parameters())) # 79510 

The code is known. The math is known: multiply, add, apply ReLU, repeat. Every value is right there.

And yet this is already a (small) black box.

The box isn't hidden, it's unreadable

Print the weights of the trained model and you get this:

Parameter containing: tensor([[-0.0003, 0.0192, ..., 0.0037, 0.0021], [-0.0198, -0.0150, ..., -0.0060, -0.0299], ..., [-0.0217, -0.0136, ..., -0.0012, -0.0017], [ 0.0142, 0.0089, ..., -0.0181, 0.0020]], requires_grad=True) 

None of these numbers has a name. There is no weight called detects_loop_at_top or is_vertical_stroke. Training set all of them automatically by nudging them, batch after batch, in whatever direction reduced the error.

How the numbers get there: backpropagation

That nudging has a name: backpropagation. It's worth understanding, because it explains why the result is unreadable.

Training starts with random weights. Then, for every batch of images, it repeats four steps:

  1. Forward pass: run the images through the network and get predictions.
  2. Loss: measure how wrong the predictions are with a single number.
  3. Backward pass (backpropagation): for every weight, calculate how the loss would change if that weight were a tiny bit bigger. This is the weight's gradient. The calculation starts at the output and works backwards, layer by layer, using the chain rule from calculus. That's where the name comes from: the error is propagated back through the network.
  4. Update: move every weight a small step in the direction that lowers the loss.

In PyTorch, the whole loop body is four lines:

optimizer.zero_grad() # clear the gradients from the previous batch loss = loss_fn(model(X), y) # steps 1 and 2 loss.backward() # step 3: a gradient for all 79,510 parameters optimizer.step() # step 4: nudge every parameter 

A positive gradient for one weight says: "increase this weight a tiny bit and the loss goes up." So training decreases it a little. A negative gradient means the opposite, so training increases it. Repeat that for all 79,510 parameters, for every batch, for thousands of batches.

Here's the key point for the black-box question. Backpropagation only ever asks one thing of each weight: does changing you make the loss smaller? It never asks what the weight means, and it never tries to make it readable. Each weight ends up wherever it was most useful for lowering the error, starting from a random value.

You can watch this happen. I recorded 5 of the 78,400 first-layer weights while training the model for 2 epochs (3,750 batches):

5 weights changing during training, with the loss below

  • They all start as small random numbers, between −0.03 and +0.04. PyTorch initializes weights randomly, so at step 0 the network knows nothing.
  • Then every batch nudges them a little. Some drift far (neuron 4's weight ends at −0.30), some barely move (neuron 2's stays near 0).
  • One flips sign. Neuron 6's weight for pixel (13,10) starts positive and ends at −0.22. That pixel sits at the edge of the blue stroke you can see in neuron 6 in the image further down. Nobody decided that neuron 6 should dislike ink there. That stroke formed batch by batch, because each small step lowered the loss.
  • The loss drops fast and then flattens, but the weights keep moving. After about 500 steps the loss only creeps down (from about 0.3 to 0.12), yet the weights keep drifting. Many different combinations of weights work about equally well, and which one training ends up with depends on the random starting values and the order of the batches.

So the "logic" of the network isn't designed. It's the leftover result of thousands of small adjustments to every single parameter. Nobody chose it, and it was never written in a form meant for humans to read.

Compare the result with code a developer writes:

// Normal code: the rules are readable fun isZero(img: Image) = img.hasLoop() && !img.hasVerticalStroke() 
# Neural network: the "rules" are 79,510 unnamed numbers [-0.0003, 0.0192, ..., 0.0037, 0.0021, ...] 

In normal software, a human writes the logic and the logic explains itself. In a neural network, training discovers the logic and stores it as numbers nobody wrote or labeled.

That's what "black box" means: not that we can't see inside, but that what we see doesn't explain why the model does what it does.

Questions you can't answer by reading the weights:

  • Why did the model say this image is a 7 and not a 1?
  • What features did it actually learn?
  • Which unusual input will make it fail?

You can peek inside a small model

For a model this small, you can get partial answers. Each hidden neuron has 784 weights, one per pixel, so you can reshape them back into a 28×28 image and see what that neuron "looks for":

import matplotlib.pyplot as plt w = model[0].weight[0].detach().reshape(28, 28) # neuron 0's weights v = w.abs().max() plt.imshow(w, cmap="RdBu_r", vmin=-v, vmax=v) # red = positive, blue = negative plt.colorbar() plt.show() 

Here are the first 12 of the 100 neurons, after training the model for 5 epochs (97.7% correct on test digits):

The weights of 12 hidden neurons, each drawn as a 28×28 image

Positive weights (red) mean "I want ink here", negative weights (blue) mean "I don't want ink here". White means the neuron doesn't care about that pixel.

A few neurons show something you could put into words. Neuron 6 is mostly one short blue stroke in the middle-left: ink in that spot pushes the neuron toward zero, so it stays active only when that spot is empty. Neurons 2 and 4 have a clear diagonal or curved shape. But most of them, like neurons 8 and 10, are a speckled mix of red and blue that doesn't match any shape a human would name. And even the clear ones only make sense together with the other 99 neurons and the output layer that combines them.

That's the black box in one picture: everything is visible, and almost none of it is readable.

Now scale it up

An LLM is built from the same basic parts: layers of weights and biases, trained by reducing a loss. In fact, generating the next token is the same kind of problem as recognizing a digit. It's multi-class classification, just with far more classes:

MNIST model LLM
Question Which digit is this? Which token comes next?
Classes 10 ~50,000–200,000 (the vocabulary)
Parameters ~80 thousand billions or more

If 79,510 parameters are already hard to read, billions are hopeless to read by inspection. When an LLM gives a wrong answer, makes something up or behaves strangely, there's no line of code to point at. You can't set a breakpoint on "the model's reasoning".

That's why LLMs are the black box everyone talks about.

"Just ask the model to explain itself"

A common workaround is to make the model write down its reasoning, either with chain-of-thought prompting or by adding a reasoning field to a structured output:

{ "reasoning": "Income is below 3× the monthly payment and there are 2 recent missed payments.", "decision": "reject" } 

(Put reasoning before decision. The model generates tokens in order, so it reasons first and decides second, instead of justifying a decision it already made.)

This is useful. Combined with an LLM observability tool such as Datadog LLM Observability, Langfuse or LangSmith, you get an audit trail of every prompt, response, tool call and stated reason.

But there's a catch: the explanation is also generated text. It can sound convincing and still not match what actually drove the output. Researchers call this the faithfulness problem. A logged rationale tells you what the model said its reasoning was, not what happened inside the network.

So reasoning fields and tracing make the box easier to audit. They don't make it transparent.

Opening the box: interpretability

There's a research field working on the real problem: interpretability. Instead of asking the model why, it looks at the internal activations directly, trying to find which neurons or groups of neurons represent which concepts and how information flows between them.

There has been real progress. Researchers have found internal features in large models that respond to specific concepts, and changed model behavior by turning those features up or down. But nobody can yet fully explain how a large model arrives at a given answer.

Summary

  • A neural network is not hidden: the code, the math and every parameter are visible.
  • It's a black box because its logic was learned, not written, and it's stored as unnamed numbers that don't explain themselves.
  • Backpropagation sets those numbers by nudging each weight in whatever direction lowers the error. It optimizes for being right, never for being readable.
  • Small models can be partly understood. Models with billions of parameters mostly can't, by inspection.
  • Asking an LLM to explain itself, and logging that, helps with auditing, but the explanation is not guaranteed to be the true cause.
  • Interpretability research is trying to actually open the box.

The box isn't locked. We just can't read the language it's written in yet.