Post

What do LLMs see? I wrote a lil' tool that extracts the attention matrices out of open models and creates this typing visual, with each token's opacity changing according to its average attention score as the prompt progresses. Dimmer words are considered less important to the model.

44 reposts264 likes

that’s very cool! Have you tried/considered using a colour scale, eg temperature colours (red, yellow, blue, white) so that subtle variations are easier to pick out?

Just put the latest version here: gist.github.com/samwho/6e351... It's messy and vibey and I've only tested it with 2 models so it's possible that different attention schemes confuse it. Looking at specific attention heads near the start of the model (top of grid) is most interesting ime.

Beautiful visualization! First token is an attention sink as expected, the visualization may be clearer with that first token score excluded from the shading calc.

Amazing work. I would love to see this sort of visualization applied in other contexts, like tool use or code generation. Might be interesting to see which tokens are most salient

I looked at this briefly (and less elegantly) during my dissertation work integrating LLMs in smart homes, and it was interesting to see how it'd relate keys in JSON structures to user commands like "set the lights up for a party"

I found a really fun attention head in the first layer of Qwen3 4B. It seems to alternate between attending really strongly to determiners, then to the most recent tokens in the sentence (sorry about Slack bouncing at the bottom of the screen).

This was done with a relatively small model, LFM2.5 1.2B. In the process of downloading the biggest model my lil laptop can run to see how it looks.

Also, worth noting: this is not super representative of what the LLM actually thinks of each token. It's a global average from every attention layer and every head, which "blurs" the detailed information. It also doesn't consider the projections that happen after attention. It's just a bit of fun.

I wrote it because my boss nerd sniped me by saying "recent tokens in context are always much more important than old ones." I wanted to know if that was actually true. So far I think it _might_ be, but more testing required.

> recent tokens in context are always much more important than old ones The key insight to overcome this fallacy is to stop thinking in tokens and accept that LLM "think" in embeddings, which contain multiple tokens plus their attention "score".

from my own very flawed perception, the very first thing (system prompt / first message) seems to carry a lot of 'weight', and the most recent prompt does as well, but the 'middle stuff' seems to carry 'less weight'. it would be very interesting to see this visualized or the 'mechanics'.

Interesting that the most consistently attended to tokens are newlines/periods. I think I've heard some folks argue that semantic information is getting stored for those tokens in the KV cache, not sure if that's true but there has to be some reason for that consistent focus.

Here's a version that lets me look at individual layers and heads (a layer just being the mean of all of its heads). Notice some heads really care about specific tokens that others don't.

My guess is no. The effect of the sink on the first token isn't so much about the first token itself but about moderating attention interactions in other token positions.

No, I haven't done any playing with SAEs yet. This is literally just pulling out attention scores after a forward pass through a model with a prompt and visualising them.