The name “matrix multiplication” sets you up to think of \(3 \times 4 = 12\). A better way to read \(Ax\) is: the matrix \(A\) takes the vector \(x\) and moves it somewhere else. The matrix is a function, and the vector is its input.
Seen this way, a lot of what happens inside an LLM gets simpler.
What can a matrix do?
Take a shape made of 2D points and multiply every point by the same matrix. Here is an F, because an F shows you when something has been mirrored. The dashed outline is the original.

The first thing to notice is scale. The matrix with 2 on the diagonal doubles everything, so it behaves exactly like multiplying by 2. Ordinary multiplication is just the simplest thing a matrix can do.
Negative numbers on the diagonal are more interesting:
- One negative value mirrors the shape. Look at the F in the Flip plot: it reads backwards, and no rotation can do that.
- Two negative values give a half turn. This is the only real rotation a 2D diagonal matrix can make, apart from doing nothing.
For any other angle you need numbers off the diagonal. The 45° rotation has them, and so does the shear, which is a mix of the two directions.
This is also why the order matters. With numbers, \(3 \times 4 = 4 \times 3\). With matrices, rotating and then shearing is not the same as shearing and then rotating, so \(AB\) and \(BA\) are usually different. Multiplying two matrices really means do one move, then the other.
Rectangular matrices change the dimension
All the matrices above are square, so 2 numbers go in and 2 come out. The shape of the matrix tells you the sizes:
\[ \underbrace{A}_{n \times m} \; \underbrace{x}_{m \times 1} = \underbrace{y}_{n \times 1} \]
So \(m\) numbers go in and \(n\) numbers come out. More rows than columns (a tall matrix) goes up in dimension. More columns than rows (a wide matrix) goes down.
Here is a tall one, taking 2D to 3D:
\[ \begin{bmatrix} 1 & 0 \\ 0 & 1 \\ 2 & 3 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} x \\ y \\ 2x + 3y \end{bmatrix} \]
The point \((1, 1)\) becomes \((1, 1, 5)\). Do this to a whole grid of points and you get this:

Each point now has 3 numbers, but the third one is computed from the other two, so nothing new has been added. The points can’t leave the flat sheet \(z = 2x + 3y\). A tall matrix gives the data more numbers, but on its own it doesn’t give it more freedom.
Going down has the opposite problem. A wide matrix can throw information away for good. If the matrix just drops \(z\), then \((1, 1, 5)\) and \((1, 1, 0)\) both land on \((1, 1)\), and nothing can tell you afterwards which one you started with.
So is this what an LLM does?
It’s easy to say that an LLM takes data and maps it from lower to higher dimensions. That’s only half right. It goes up, but it also goes down, several times.
Here is a very small model trained on one job: next-word prediction. You give it a word, and it scores every word it knows on how likely that word is to come next. An LLM does the same job each time it writes a word.
The model only knows 6 words, taken from one sentence: the cat sat on the mat. It has the same steps as a Transformer but much smaller sizes, and it leaves out attention, so it only ever sees one word. Here it is after training, given “cat”:

Input: 6 numbers. One slot per word the model knows. “cat” is written as a 1 in its slot and 0 everywhere else, which is called a one-hot vector.
Embedding: 6 down to 3. You might expect this step to go up, but a one-hot vector is already longer than what comes out. Multiplying by the embedding matrix picks out one column, so this is a wide matrix going down.
embed = nn.Embedding(6, 3)
one_hot = torch.zeros(6)
one_hot[1] = 1 # "cat"
out = embed.weight.T @ one_hot # shape: [3]
torch.equal(out, embed(torch.tensor(1))) # Truenn.Embedding is that multiplication with a shortcut, since it can look the column up directly.
Feed-forward: 3 up to 12, then back to 3. Here is the tall matrix. A Transformer has one of these in every layer:
\[ \text{FFN}(x) = \max(0, xW_1 + b_1)W_2 + b_2 \]
Output: 3 up to 6. The last matrix gives one score per word the model knows. A softmax turns those into probabilities. For “cat”, “sat” gets a probability of 1.00. For “the”, the model splits it, 0.50 on “cat” and 0.50 on “mat”, because the sentence has both.
A real model has the same steps with bigger sizes. The input size is simply how many tokens the model knows. These are the sizes from the original Transformer in Attention Is All You Need:
| Step | Small model | Original Transformer |
|---|---|---|
| One-hot input (tokens it knows) | 6 | 37,000 |
| Embedding | 3 | 512 |
| Inside the feed-forward | 12 | 2,048 |
| Back to model size | 3 | 512 |
| Output scores | 6 | 37,000 |
Attention moves dimensions too. From the previous post, \(Q\), \(K\) and \(V\) come out of matrix multiplications. In the paper, each of the 8 heads takes 512 down to 64.
Where does the “more information” come from?
Going up sounds like it should add information, but a tall matrix adds no freedom. Here is that same result at the sizes the Transformer uses. Rank counts how many independent directions the data really has.
up = nn.Linear(512, 2048, bias=False)
x = torch.randn(5000, 512)
h = up(x)
h.shape # [5000, 2048]
torch.linalg.matrix_rank(h) # 512
torch.linalg.matrix_rank(torch.relu(h)) # 2048After the tall matrix, each vector has 2,048 numbers but only 512 directions. It’s the flat sheet again, with more dimensions. After the ReLU, all 2,048 directions are in use. That’s the \(\max(0, \cdot)\) in the formula above. It bends the flat sheet, and each of the 2,048 numbers can now switch on or off on its own.
A smaller picture helps here. Take the 2D sheet from earlier. A matrix can tilt it, but it stays flat. Roll it into a cylinder and it now uses all 3 directions, even though it’s still the same sheet. No matrix can do that, because rolling needs a non-linear function.

ReLU doesn’t make cylinders. It bends with sharp creases rather than smooth curves, but the idea is the same: bending lets the data use the extra room.
Without that ReLU, the whole feed-forward block would collapse. A 512 × 2048 matrix times a 2048 × 512 matrix is just a single 512 × 512 matrix, so the detour through 2,048 would give you nothing new.
Information also comes from the matrix itself. A word ID on its own says almost nothing. The 512 numbers that come out of the embedding were already stored in the matrix, and training put them there.
What training is doing
At the Transformer’s sizes, the embedding matrix alone holds 37,000 × 512 = 18,944,000 numbers. Each of the feed-forward matrices has 512 × 2,048 = 1,048,576 more, in every layer, for both encoder and decoder.
The architecture only fixes the shapes, meaning how many numbers go in and come out at each step. Training picks the numbers inside. So training an LLM is a search for the transformations that take “the words so far” to “good scores for the next word”. The 6-word model does the same search, with far fewer numbers.
Source
- Vaswani, Shazeer, Parmar, Uszkoreit, Jones, Gomez, Kaiser, Polosukhin. Attention Is All You Need. NeurIPS 2017, arXiv:1706.03762. The sizes come from this paper: \(d_{model} = 512\), \(d_{ff} = 2048\), 8 heads with \(d_k = 64\), and a 37,000 token vocabulary for its English to German task.