sarvesh.
Blogs

What I learned by taking apart the AI models on my MacBook

In this article

I asked Gemma for the capital of France. It gave “Paris” a 0.000068% chance of coming next. It gave a line break 97.59%.

I could see those odds because I was running the model on my MacBook Pro (M4 Pro, 48 GB). I could also open the files, change one number inside a running model, and ask the same question again.

What was Gemma going to type next?

Here’s exactly where I stopped typing.

What is the capital of France?
Answer:

A model writes in pieces called tokens. A token can be a word, part of a word, or the line break you get by pressing Enter. I was looking for the token that contains a space followed by “Paris.”

  • After Answer: Gemma 4 12B wanted to start a new line. “ Paris” came 938th.
  • After The capital of France is “ Paris” came first, at 99.20%. This time I’d used Gemma’s chat format and written the start of its reply for it.

My first test would have counted a perfectly good answer on the next line as a miss. How much difference would the line break alone have made? I changed both the format and the lead-in, so that remains open.

Gemma 4 gives a line break 97.59% after the plain answer cue and gives the Paris token 99.20% after a sentence starter in chat.

Qwen 3.8 27B showed a version I could check with the same prompt. It gave plain “Paris” about 3%. Its favorite opening was **, the Markdown for starting a word in bold. I supplied those asterisks and checked again. The chance of “Paris” coming next was over 99.99%.

Why did Gemma say lead?

I tried five questions on seven local model variants. For each question I picked a right answer and a plausible wrong one. The models never saw my choices. I scored how likely each whole name was to complete the same sentence. For Australia’s capital, I compared Canberra with Sydney. For element 74, I compared tungsten with tantalum.

The right name won all 35 comparisons. Then I let each model write an answer from scratch, choosing its favorite token at every step. They got the main fact right 32 times. All three misses were on element 74.

Model Chance of tungsten What it wrote
Gemma 3 4B · BF16 2.17% Lead
Gemma 3 4B · Q4 10.92% Lead
Qwen 3.5 2B 1.19–1.53% Ruthenium

The percentages score “tungsten” after a sentence starter. The last column gives the separately generated answer. Qwen returned only its top 20 tokens at each step, so its score is a range. All answers (CSV)

The higher-precision Gemma gave tungsten 2.17% and tantalum just 0.000635%. Tungsten won my two-name test easily. The name I’d left out, lead, got 97.53%. When Gemma could say whatever it liked, it wrote “Lead (Pb).” Element 74 is tungsten. Royal Society of Chemistry

All seven models favored the correct name in five two-name comparisons. Three gave a wrong element when they wrote their own replies.

I counted the main answer for each question. Inkling, for instance, correctly named Ganymede as the largest moon in the Solar System. It then called Ganymede the only moon larger than Mercury. Titan is larger than Mercury too. NASA’s Titan facts

What can you see in the model file?

Both copies of Gemma 3 said lead. Yet the smaller copy gave tungsten five times the chance the larger one did. I opened the files to see what compression had changed.

A model’s weights are the numbers it uses in its calculations. BF16 stores each weight in 16 bits. The copy labeled Q4 saves space by rounding groups of weights to a shorter list of allowed values. It uses different bit widths for different parts of the model.

Model Atlas showing the five local files used for weight inspection.
The five files I inspected. The question tests also included Inkling 2 Mini and Qwen 3.5 2B. Explore Model Atlas

The larger package included vision weights, so I compared only the text weights I could match. The same 3.88 billion numbers went from 7.76 GB to 2.48 GB, a 68% saving.

I compressed the same 512 rows from 16 weight matrices two ways. In every matrix, the six-bit format produced more exact zeros. Yet its typical rounding error was about a quarter of the four-bit format’s. The six-bit scale has a mark at zero. The four-bit scale can place zero between two marks. Counting zeros would have led me to pick the less accurate format.

Some relationships survived. Each token has a list of numbers, its embedding, which the model looks up when it reads that token. I picked 4,096 ordinary tokens and found which other token in that group had the most similar direction in its embedding. 4,032 kept the same nearest neighbor after compression. The Q4 file uses six bits for this part.

Could a million matching numbers identify the training GPU?

DeepSeek R1 8B has rows of weights for tokens that go unused. I tried replaying two steps that might have left a trace in those rows.

Unused rows Step I replayed Result
264 input rows Generate the starting values 1,081,344 values matched
265 output rows Compress the original rows All 265 matched byte for byte

An input row is what the model reads for a token. Bojie Li published a recipe for generating initial values in Qwen3-8B, the family DeepSeek used as its starting point. Given the same starting number, called a seed, the code produces the same sequence. On my Mac it reproduced all 264 higher-precision rows, including 52 I’d held back as a check. Changing the seed broke the match. After compression, 232 of the 264 rows matched my local file byte for byte. Bojie Li’s recipe

An output row helps score a token the model might write. Among 265 unused output rows, there were 11 distinct patterns in the original and just three in my copy. Replaying compression reproduced every local row.

DeepSeek’s 265 unused output rows have 11 distinct patterns before compression and three afterward.
See the individual measurements in Model Atlas.

The million matches identify a recipe that works. DeepSeek could have inherited the rows from its Qwen base model, or the same code could have run later. Which GPUs trained DeepSeek, and how many it used, remains unknown. DeepSeek’s model card

Which positions do Qwen’s filters favor?

Imagine Qwen reading “the sky is blue.” At “blue,” the current token is “blue” and the previous one is “is.” In 48 of this model’s 64 layers, short filters combine the current token with the three just before it.

I looked at 491,520 filters. Each has four numbers. I squared those numbers and calculated each position’s share before averaging, so each filter counted equally.

Qwen’s query filters concentrate on the current position. The key and value filters concentrate one position earlier.

The query filters help form what the model looks for. About 85% of their squared weight fell on the current position. The key and value filters help label and carry information. Both favored the previous position, at 59% and 62%. Those percentages describe the filters. How much “blue” or “is” contributes in a real sentence also depends on the values flowing through them.

What happens if you turn off one number in DeepSeek?

For each token, DeepSeek passes a list of 4,096 numbers from one layer to the next. A channel is one slot on that list. 3010 and 2276 are slot numbers. The number in a slot changes as the model reads.

In layer 6, the model multiplies each slot by a learned number. Slot 2276 had the biggest multiplier, 8.125. I expected that setting it to zero would cut the strongest response the next calculation could produce by at least 30%. The drop was only 3.98%. Slot 3010 had a smaller multiplier, but the next calculation gave it much more weight. Switching it off cut the strongest possible response by 59.90%.

What happened with actual words? I ran 20 short prompts. Across 288 positions in the user’s text, 3010 had the second-largest typical signal of all 4,096 slots. Slot 2276 came last, though it spiked at the marker that starts a user message.

Within layer 6, switching off channel 3010 changed the output much more than switching off channel 2276.

Then I turned off one slot at one position per prompt. For 3010, the size of the change inside the layer was about 69% of the original output’s size. For 2276 it was about 2%, taking the median in each case. Across all 420 checks, including the other slots I tested, the model still picked the same next token every time.

Did the next word get harder to predict?

A word can drop from a 90% chance to 51% and still come first. To see changes like that, I gave DeepSeek 16 passages it hadn’t seen during my channel tests. At each position I scored the probability it gave the token the author actually wrote. This time I switched off one slot throughout the passage.

The score is called perplexity. If every actual next token got a one-in-four chance, the score would be four. Lower means the text was easier for the model to predict. Here are the results across the same 1,560 tokens. Scores by passage (CSV)

Layer 6 setting Perplexity Change
All slots on 18.76 —
3010 off 19.55 +4.20%
2276 off 18.70 −0.30%
One of 19 other slots off 18.71–18.79 −0.26% to +0.15%
Removing 3010 increased perplexity more than removing any of the other 20 channels tested on these passages.

Removing 3010 made these passages harder to predict overall. The sample was small enough that the 95% uncertainty interval for the change in average prediction loss included zero. The two kinds of writing also behaved differently.

Seven of eight Federal Register abstracts got harder to predict, and their combined perplexity rose 7.47%. Among eight AI-written stories, four got harder and four got easier. Taken together, the stories got slightly easier, by 0.35%.

Related project · Model Atlas