10 comments

  • MCP1231 hour ago
    This is great, thank you. I have to teach this stuff on Friday so perfect timing. It's hard to explain the attention mechanism in a way that becomes intuitive because the weighting scheme does not help much with the intuition. Having a visualization like this helps a lot. Don't move that page please since I'll link to it!
  • fuddle4 hours ago
    This is great, I've read multiple books and watched videos about the attention mechanism. Now that I understand it, this is the clearest example I've seen on how attention works.
  • fermlon3000029 minutes ago
    INSANE
  • wopak4 hours ago
    neat, combining info from two phrases is hard to see without such a tool.<p>are you worried later-layer attention gets drowned out by earlier layers just because there are more of them contributing to the sum?
    • ifz4 hours ago
      Hmm, I might try to add some controls to limit which layers get summed up. It might be able to reveal more patterns.<p>Right now only simple correlations are visible.
  • itsnasme4 hours ago
    I like the visualisation. Pretty cool
  • sva_5 hours ago
    I highly question this simplistic idea of high vector magnitude = high influence.
    • smallmancontrov5 hours ago
      You get what you pay for. If you want to think harder and get more, <a href="https:&#x2F;&#x2F;transformer-circuits.pub&#x2F;2025&#x2F;attention-qk&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;transformer-circuits.pub&#x2F;2025&#x2F;attention-qk&#x2F;index.htm...</a>
    • ifz5 hours ago
      I don&#x27;t disagree with that. I did add an entire caveat paragraph there.<p>To me, it&#x27;s more of a neat visualization, not something that can be used to interpret LLM behavior. Even with a lot of simplification, it can show some interesting patterns.
    • apnabhidu474 hours ago
      Same I dont get it just, could you clarify it
  • ex-aws-dude3 hours ago
    I don&#x27;t know much about LLMs but does that mean you have N^2 computation with the context size since every token needs to track how it relates to every other token?
    • TomatoCo2 hours ago
      Yes, except no with the KV cache. Because tokens aren&#x27;t modified by future tokens you can cache the meaning of previous tokens. This makes the total effort linear over the entire context (or constant per forward pass).
      • libraryofbabel1 hour ago
        &gt; This makes the total effort linear over the entire context (or constant per forward pass).<p>This is incorrect. The compute required per forward pass to generate <i>each additional token</i> during decode will scales as O(N), even with a KV cache (without a KV cache, it would scale as O(N^2)). Over generating N tokens, it&#x27;s O(N^2) with the cache (and O(N^3) without).<p>It&#x27;s O(N) for a forward pass because that new token still has to &quot;attend to&quot; to each previous token. That requires N dot products: between the cached key vectors and the new query vector for the new position. You also have N reads from memory (K and V) which is probably gonna be your actual bottleneck. (Decode is memory-bound.)<p>This is why you should avoid long contexts, if you can, even with a warm cache. You will get charged more, in &quot;cache read&quot; tokens.
      • ex-aws-dude2 hours ago
        I see and is there only 1 layer of relations?<p>Or does it accumulate the relations like A relates to B, so also add in B&#x27;s relations
    • acedTrex3 hours ago
      For full self attention yes
  • stared4 hours ago
    I am curious what&#x27;s the actual formula.<p>I mean, there so many headers and layers, it is tricky to make a choice that will resonate with our intuition . Is it some weighted average? Or maybe ablation test?
    • ifz4 hours ago
      It&#x27;s really simple, basically just the magnitude of the value vector, weighted by QK dot product, summed across all attention heads and layers.<p>When I started, I expected I&#x27;d have to experiment a lot to find something comprehensible. But this simple computation can already show some patterns.
      • stared3 hours ago
        Nice! Sometimes the simplest approaches work the best.
    • visarga3 hours ago
      If you want quick access look at google images for &quot;transformer attention formula&quot; there are some interesting depictions
  • colophontio5 hours ago
    [dead]
  • Yyylov1 hour ago
    [dead]