# Mission 4.2: Where are the 8 billion parameters?

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/einsatz-4-2

Belongs to [Chapter 4: The transformer in outline](https://llm.yoga/en/04-transformer.md).

Structure: the case, the explanation, a hands-on tool, check questions, wrap-up. The answers to all questions are collected at the end.

## The case

**Ralf**, CTO at a customer:

> “Qwen3-8B is too big for our devices. I’d start with the attention and shrink it. The paper was called ‘Attention Is All You Need’, so that’s where most of it sits, right?”

If you advise customers on their own models, you hear rebuilding plans like this a lot; a number for where the parameters sit saves long discussions. Qwen3-8B is an open language model. Its **parameters** are the numbers that were set during training; according to the model card there are 8.2 billion, recalculated 8,190,735,360. Attention is the part where each word looks at the words before it (mission 4.1).

**Question 1 (prediction):** What share of Qwen3-8B’s parameters sits in the attention?

- A) About 70 percent, it’s the heart of the model.
- B) About half, the rest is spread over everything else.
- C) Just under a fifth.

## What’s behind it

Back to the meeting from mission 4.1: in the attention, the words pass notes around. After that, each word thinks things over on its own. This thinking is the bigger part of the work, and it needs most of the parameters.

The term for it is **feed-forward layer**, a classic neural network in every layer of the model. It widens a token’s vector, its list of 4,096 numbers, to 12,288 and narrows it again. Qwen3 uses three large matrices for this (SwiGLU). The counting follows a simple rule: a matrix that maps a numbers to b numbers has a × b weights.

That gives about 151 million parameters per layer in the feed-forward layer and about 42 million in the attention. The attention is smaller because its four matrices are narrower than the three in the feed-forward layer, and in Qwen3 four query heads also share one key and one value. On top come the **embedding table**, which translates each token number into a vector, and the output matrix at the end, 622 million each.

Across 36 layers that adds up to: feed-forward 66.4 percent, attention 18.4, embedding and output together 15.2. Since a paper by Geva et al. (2020), a common idea is that much of the learned knowledge sits in the feed-forward layers, while attention moves information between tokens.

For Ralf this means: attention makes the transformer special, but not big. If you want a smaller model, in practice you take a smaller model from the same family, or you store the weights with fewer bits: qwen3:8b is 5.2 GB in Ollama instead of 16.4 GB in BF16 (chapter 9).

### In more detail: the calculation for Qwen3-8B

Values from the config.json: vocabulary 151,936, width 4,096, 36 layers, 32 query and 8 KV heads with 128 numbers each, feed-forward width 12,288, embedding not shared.

Embedding: 151,936 × 4,096 = 622,329,856. Attention per layer: query 4,096 × 4,096 = 16,777,216, key and value each 4,096 × 1,024 = 4,194,304, output projection 16,777,216, QK-Norm 256, together 41,943,296.

Feed-forward per layer: 3 × 4,096 × 12,288 = 150,994,944. Normalizations per layer 8,192. One layer: 192,946,432, times 36: 6,946,071,552.

Total: 622,329,856 + 6,946,071,552 + 4,096 (final normalization) + 622,329,856 (output) = 8,190,735,360. Without embedding and output 6,946,075,648, exactly the 6.95 billion on the model card.

Memory: 8.19 billion × 2 bytes (BF16) = 16.4 GB. qwen3:8b in Q4_K_M is 5.2 GB, so about 5 bits per parameter on average.

## Try it

**Feed-forward share of Qwen3-8B**

**Task:** Work out for Ralf what percentage of all Qwen3-8B parameters sits in the feed-forward layers. One decimal place.

**From the config.json of Qwen3-8B**

Width (hidden_size): 4,096. Feed-forward width (intermediate_size): 12,288. Three matrices per feed-forward layer. 36 layers.

All parameters together: 8,190,735,360.

Feed-forward share in percent

## Check

**Question 2 (check question):** Ralf asks how much memory Qwen3-8B needs in its original BF16 format, meaning 2 bytes per parameter, for the weights alone.

- A) About 8.2 GB, one byte per parameter.
- B) About 16.4 GB.
- C) About 5.2 GB, that’s the file size in Ollama.

**Question 3 (check question):** Ralf sticks to his plan: “Then we’ll just halve the attention.” How much smaller would that make the model?

- A) By a little over 9 percent; the rest stays as it is.
- B) By about half, because attention is the heart of the model.
- C) By about 18 percent, that’s how much sits in the attention.

**Question 4 (check question):** The model is supposed to run on devices with 8 GB of memory. What do you suggest to Ralf?

- A) Drop the embedding table, it only translates token numbers into lists of numbers anyway.
- B) Shrink the attention and then retrain the model yourselves.
- C) A smaller model from the family, or store the weights with fewer bits.

## Done

**What you can do now**

- You count the parameters of a component with the rule “a numbers to b numbers means a × b weights”.
- You know that in Qwen3-8B two thirds of the parameters sit in the feed-forward layers and just under a fifth in the attention.
- When a customer wants to “slim down” a model, you ask about the target device and its memory, and use parameters times bytes to show whether a smaller model or fewer bits per weight will do.

### Two cards for review

**Card 1:** Which component of Qwen3-8B holds most of the 8.19 billion parameters?

- A) the attention
- B) the feed-forward layers
- C) the embedding table and output matrix

**Card 2:** True or false? “If you want to make a language model much smaller, the attention is the best place to start.”

- [Next mission: Why doesn’t the model know our niche item number?](https://llm.yoga/en/einsatz-4-3.md)
- [Try it on your Mac](https://llm.yoga/en/mac-4-2.md)

## Read more in the chapter

The full text from the chapter, with the reasoning, calculations and sources:

- [Where the 8 billion parameters come from](https://llm.yoga/en/04-transformer-2.md)
- [The feed-forward layer](https://llm.yoga/en/04-transformer-2.md)
- [Stacking layers](https://llm.yoga/en/04-transformer-2.md)
- [Embeddings: from token ID to vector](https://llm.yoga/en/04-transformer-1.md)

## Answers: only reveal them after the learner has answered or explicitly asks

**Question 1:** The correct answer is C.
- A: About two thirds really do sit in one component, but not in the attention; they’re in the feed-forward layers: 66.4 percent. Attention comes to 18.4 percent.
- B: Less. Each of the 36 layers has about 42 million parameters in the attention but 151 million in the feed-forward layer. Overall that’s 18.4 versus 66.4 percent.
- C, correct: 18.4 percent, about 1.5 billion. Two thirds sit in the feed-forward layers, the rest in the embedding table and the output matrix. So Ralf is starting with the smaller part.

**Feed-forward share in percent** Answer: 36 × 3 × 4,096 × 12,288 = 5,435,817,984; divided by 8,190,735,360 that’s 66.4 percent. Attention: 18.4 percent.

**Question 2:** The correct answer is B.
- A: BF16 means 16 bits, so 2 bytes per number. 8.19 billion × 2 bytes is 16.4 GB. One byte per parameter would be an 8-bit format.
- B, correct: 8.19 billion × 2 bytes = 16.4 GB, too much for a Mac with 16 GB. With fewer bits per weight (chapter 9) that shrinks: qwen3:8b is 5.2 GB in Ollama.
- C: The 5.2 GB apply to the Ollama version in the Q4_K_M format with about 5 bits per parameter. In the original BF16 format it’s 16.4 GB.

**Question 3:** The correct answer is A.
- A, correct: Attention holds 18.4 percent of the parameters, and half of that is 9.2 percent. For a device the model doesn’t fit on at all, that’s far too little.
- B: Heart doesn’t mean biggest part. Attention holds 18.4 percent of the parameters; halved, that’s a little over 9 percent less.
- C: It would be 18.4 percent if the attention were removed entirely. Halved, the model shrinks by 9.2 percent.

**Question 4:** The correct answer is C.
- A: Without it, the model can’t process the token numbers at all. Besides, it holds only 7.6 percent of the parameters.
- B: That saves little, because attention is only just under a fifth, and training is expensive. In practice you take a ready-made smaller model.
- C, correct: That’s how it’s done in practice: at about 5 bits per weight, qwen3:8b is 5.2 GB instead of 16.4 GB in BF16. A test shows whether the answers are still good enough.

**Card 1:** Correct: B, the feed-forward layers The feed-forward layers: 66.4 percent. The attention the transformer is named for comes to 18.4 percent, the embedding table and output matrix together to 15.2.

**Card 2:** **False.** In Qwen3-8B the attention holds only 18.4 percent of the parameters; halving it shrinks the model by a little over 9 percent. In practice you take a smaller model from the same family, or store the weights with fewer bits: qwen3:8b is 5.2 GB in Ollama instead of 16.4 GB in BF16.
