How attention sinks keep language models stable

(hanlab.mit.edu)

188 points | by pr337h4m a day ago ago

31 comments

  • Calavar a day ago

    > Researchers had observed similar patterns in BERT, where "a surprisingly large amount of attention focuses on the delimiter token [SEP] and periods," which they argued was used by the model as a sort of no-op. The same summer at Meta, researchers studying vision transformers found similar behavior, observing that models would repurpose uninformative background patches as computational scratchpads.

    This seems to go beyond just transformers. For example, I recall reading a paper a while ago that showed a similar effect in an image to image model with a GAN/U-Net architecture [1].

    [1] https://arxiv.org/abs/1712.02950

    • derbOac 7 minutes ago

      > This seems to go beyond just transformers

      And beyond that. Sometimes I feel like AI research is reinventing wheels that exist elsewhere. Maybe just the wheels, but still.

    • SpaceManNabs 14 hours ago

      I miss GANs. I understand that they are much harder to train than transformers for the same performance even with high data regime and high parameter regime, but there was such good optimization research and tricks that came out of them.

      The work on the capacity of discriminators was super cool.

      • godelski 10 hours ago

          > much harder to train than transformers
        
        There's plenty of GANs that use transformers. PWC seems to be redirecting to GitHub currently but IIRC about half of top scores on FFHQ256 were GANs with transformers in them. I know that the number 2 was, I saw it at CVPR. It was a lot smaller and had higher throughput than the diffusion models it was outperforming.

        Though the main reason diffusion took over was for the ability to encode more diversity. I still think there's a place for GANs and we overcorrected by putting too much focus on diffusion, but there are a lot of fundamental advantages to diffusion. Though they aren't strictly better, there's no global optima for solution spaces this large. I think the ML community (maybe CS in general) has a tendency to take an all or nothing approach. I don't think this is a really good strategy...

  • canjobear 20 hours ago

    Seems like this was a better solution to the same problem https://www.evanmiller.org/attention-is-off-by-one.html

    • danieldk 14 hours ago

      The attention sink as used in gpt-oss is similar to your link. But rather than adding one to the denominator, they add a trainable 'logit' (a different logit for each head).

    • scotty79 an hour ago

      It would be super funny if it was sufficient.

      This all reminds me of the bias term of a perceptron.

      And with transformers we started with not having any and the network repurposed one of the inputs for that which annoyed people because now dropping this particular input makes the whole thing be unreasonably affected but also annoyed some other people because weight on that input was unreasonably high because it sort of balanced all others.

      So initially people (from hanlab) tried to affix this input so it doesn't get dropped. Then they (from openai this time) decided to just skip the input by providing learnable bias inside of the network (doing the thing that classical perceptron does) and now this guy proposes further optimization just by setting bias to 1 everywhere, which might work perfectly fine since we don't really care about absolute values because ultimately we just pick largest one and don't care what it was. So in training all other weights just get scaled by the bias so it can be 1. It's little like doing physics calculations with speed of light set to 1.

      If you have simple feed forward network of perceptrons where ultimately in the end you just pick the largest output and don't care about absolute values then maybe you'd also be fine with just setting all perceptron bias terms to 1 and excluding them from the learning.

      Is bias learnable in biological neurons? Doesn't activation potential threshold (or whatever it's called) rely on some chemistry and isn't the same for all neurons?

    • markisus 19 hours ago

      Did this end up working? It sounds plausible but it needs some empirical validation.

  • innerlee 19 hours ago

    The singular defects (or high-norm tokens) [1] may be related to attention sinks. It is interesting that the direction of all high-norm tokens share the same direction. Maybe the theory behind is not very complex and the issue can be fixed cleverly during training.

    [1] https://openreview.net/pdf?id=4yBnUokU2v

  • esafak 21 hours ago

    > Barbero et al. have shown that attention sinks serve as "pressure valves" preventing what researchers call "over-mixing"—a pathological state where deep models processing long sequences blur important distinctions between tokens. The presence of a sink draws attention away from other tokens, limiting the spread of information (and noise) and resulting in more stable embeddings.

    This sounds like it is working for the wrong reasons. Surely the right behavior is for the right neurons to receive attention rather than the first handful. Jamming everything there is the complementary sin of blurring. I would investigate attention equalization paired with a sparsity prior or something similar to prevent blurring.

    • yorwba 20 hours ago

      The point is that there's not always a right token to attend to. If the information you're looking for is not there, no clever attention scheme will find it. The best you can hope for when that happens is that the value returned in the "not found" case is distinguishable from the "found" case. Having an attention sink serve as a fixed "not found" value is one way to do this.

      • esafak 20 hours ago

        Good point. Does that make them mitigate hallucinations?

        • yorwba 20 hours ago

          In a sense? As the article notes, models trained using standard attention develop attention sinks naturally and removing them makes the model deteriorate completely, so the hallucinations you're thinking of were most likely output by a model that had already mitigated them in this way.

  • Scene_Cast2 19 hours ago

    I found a fairly large improvement in my toy transformer model where I added a "global" token akin to the CLS token in ViT.

    Another approach I've seen is the "Diff transformer" from MS Research (https://github.com/microsoft/unilm/tree/master/Diff-Transfor...).

  • Havoc a day ago

    > The first few tokens often carried minimal semantic information—sometimes just a start-of-sequence marker or common words like "the" or "a."

    I wonder if it makes sense to use the first word as a title of sorts rather than going straight in grammatically correct sentence when prompting

    • xg15 19 hours ago

      Some people start their prompts with "Hello" or "Please" or something similar, out of some habitual sense of politeness, I think. It would be hilarious if those prompts really work better because the model can use those words as attention sinks.

      • CamperBob2 17 hours ago

        One point that Karpathy has made in some of his videos is that using additional tokens in the prompt can facilitate computation. If you ask a transformer to do some basic math, it will be more likely to get the right answer (or at least a better approximation) with a more verbose prompt. To me, this backs up the use of more conversational language ("Please," etc.) when prompting.

        However, that seems to be contradicted by what was shown recently with the successful International Math Olympiad effort. Their prompts, such as https://github.com/aw31/openai-imo-2025-proofs/blob/main/pro... , were very terse. It's hard to tell where the prompt stops and the CoT response starts, in fact.

        So there is probably some interplay between the need for attention sinks and the use of step-by-step reasoning. It might not be too surprising if the latter works because it's an indirect way to optimize the former.

        • xg15 16 hours ago

          I wonder if the model could also just make its own sink tokens if the prompt doesn't have any. E.g. if the model first emits some "fluff" like "The answer to this question is:" before starting with the actual answer, it could use those tokens as attention sinks. Same with "thinking tokens" that don't directly contribute to the answer or invisible formatting tokens, etc.

          • blackbear_ 3 hours ago

            Good thought, that indeed works: https://arxiv.org/abs/2310.02226

          • CamperBob2 15 hours ago

            True, along with "You're absolutely right! What an insightful observation. You're going places, bro," yadda yadda yadda.

            It would be amusing if all that gratuitous sycophancy actually helped with inference accuracy. It would also be worth treating that as a bug to be fixed, of course.

        • yorwba 15 hours ago

          > It's hard to tell where the prompt stops and the CoT response starts, in fact.

          That's because you're looking at the final output that includes neither the prompt nor the intermediate chain of thought.

          • CamperBob2 15 hours ago

            Good point -- I can see that, but it all ends up in the same context, anyway. Point being, the model seems to prefer to conserve tokens.

            That said, now I'm wondering if all those dashes it spews out are more than just window dressing.

    • optimalsolver 20 hours ago

      "Magnets. How do they work?"

      • gjm11 19 hours ago

        The heuristic doesn't work quite so well when applied to the actual original version of that line.

  • flimflamm 5 hours ago

    Hah they kind of found "NULL" pointer in LLMs.

  • smaddox 10 hours ago

    > though we did not delve into the observation

    Oh, the irony.

  • sanj 18 hours ago

    Is there a way to hint in the prompting what information should be retained in the attention sinks?

  • am17an a day ago

    This is nice and useful because the new GPT-OSS model uses this technique. Kudos to the original authors!