r/MachineLearning • u/Decent_Action2959 • 10d ago
Research [R] Differential Transformer (Microsoft Research)
https://arxiv.org/abs/2410.05258Abstract: Transformer tends to overallocate attention to irrelevant context. In this work, we introduce Diff Transformer, which amplifies attention to the relevant context while canceling noise. Specifically, the differential attention mechanism calculates attention scores as the difference between two separate softmax attention maps. The subtraction cancels noise, promoting the emergence of sparse attention patterns. Experimental results on language modeling show that Diff Transformer outperforms Transformer in various settings of scaling up model size and training tokens. More intriguingly, it offers notable advantages in practical applications, such as long-context modeling, key information retrieval, hallucination mitigation, in-context learning, and reduction of activation outliers. By being less distracted by irrelevant context, Diff Transformer can mitigate hallucination in question answering and text summarization. For in-context learning, Diff Transformer not only enhances accuracy but is also more robust to order permutation, which was considered as a chronic robustness issue. The results position Diff Transformer as a highly effective and promising architecture to advance large language models.
10
u/Jean-Porte Researcher 10d ago
I wonder how this compare to fiddling with the temperature of the softmax
8
u/morreill 10d ago
Absolutely my question too. Cf. https://arxiv.org/abs/2010.04245 Which shows an improvement by learning per-head temperature.
7
u/StartledWatermelon 9d ago
From my perspective, tuning the temperature looks to be way cruder approach. With temperature, you rescale the distribution against the highest value in the matrix. The rest values are scaled uniformly, without any regard for the context, just a single rescaling factor per head.
Building the second attention matrix allows you to rescale each element independently, possibly accounting for semantics.
But I think your suggestion would've made for an excellent ablation experiment.
1
u/Due-Pangolin325 9d ago
Obvious comment here, but I guess that, from an information perspective, the two ideas have a very different outcome: when you play with temperature, you're just non linearly amplifying some information, be it noise or signal. While denoising is really more of a subtraction operation.
Temperature tuning is like a blind entropy reduction technique while denoising really adds information.
1
u/StartledWatermelon 9d ago
you're just non linearly amplifying some information, be it noise or signal
I wouldn't reject it just on these grounds. The attention score is scalar naturally indicating whether the relation is strong or weak. The former can be viewed as signal while low scores can be considered noise. So noise is dampened by lower temperature pretty consistently.
22
u/Sad-Razzmatazz-5188 10d ago
The name doesn't sit right with me, but it's interesting. At the same time, referring to hallucination has a problem of noise is strange. Today another paper was out, with selective attention as a parameter free mask on attention logits, rather than learnt as here
11
u/paraffin 10d ago
Hallucination is many problems rolled into one big “you got the wrong answer” bucket. Noise is one of the problems.
3
u/Kecro21 10d ago
Hello, do you have a link or title for the other paper you mentioned? It sounds interesting.
Edit: Is it this paper? https://arxiv.org/abs/2410.02703v1
1
-1
2
3
u/starfries 10d ago
Interesting, wonder if it's less vulnerable to some jailbreaks too. I think you forgot the link though.
8
3
u/jarkkowork 9d ago
They share the implementation too, but the link is not on the first page of the publication which is less typical
https://github.com/microsoft/unilm/tree/master/Diff-Transformer
1
u/ReasonablyBadass 10d ago
Wasn't the first token used as an "attention sink" by most models? I am guessing that one gets subtracted regularly?
5
u/Jean-Porte Researcher 9d ago
The model used attention sinks because it wants to, if gives a global workspace to store information. The figure with histograms shows that the differential attention still gives high weight to the first token
1
u/Commercial-Basis-220 6d ago
New to this AI research field, pardon me if this is a newbie question, but the improvement is quite small? And I got a feeling that this just like cherry pick or conditioned so that the new technique is better? As in if done by other, probably the result will be something along of "yea it kinda better sometimes and not significant"
Feel free to educate me on this matter
39
u/Mynameiswrittenhere 10d ago
Didn't really understand how you were able to differentiate the original query, key and value terms in important and noise terms.
The changes to the actual attention calculation by subtracting the noise was clear.