AIToday
Large Language ModelsQiita 機械学習Published: Nov 23, 2026, 16:00 JST

Attention's √d scaling explained via coin tosses on Qiita

Send on LINE
Attention's √d scaling explained via coin tosses on Qiita

3 Key Points

  1. What happened

    A Qiita author published an explainer showing that unscaled Attention (Attention(Q, K, V) = Softmax(QK^T)V) makes dot products vary wildly as dimensions grow — like d = 512 producing scores from 1000 to 3000 — and that Softmax then saturates to 100% and 0%, killing gradients.

  2. Why it matters

    When Softmax outputs stick at 100% and 0%, the gradient becomes nearly zero, so the model loses the signal on how to adjust weights and training stalls (vanishing gradient).

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, every morning.

Context & Analysis

The explainer builds from the original Attention formula without scaling, Attention(Q, K, V) = Softmax(QK^T)V, and walks through two failure steps. First, as the dimension d grows, the dot product QK^T sums more terms, so its spread grows dramatically — compare d = 3, where scores stay within 10 to 20 points, with d = 512, where scores can range from 1000 to 3000. Second, Softmax receives these widely varying scores and pushes the largest to nearly 100% while the rest fall to nearly 0%, which flattens the gradient to almost zero and stops learning.

The natural question then is why divide by √d rather than by d. It argues that because positive and negative terms partially cancel, the actual spread grows with √d, not d; dividing by d would shrink too much. The coin-toss game makes this concrete: after 100 tosses, the expected distance from the start is about √100 = 10 steps, which is exactly the standard deviation. So dividing by √d restores the scores to a well-behaved size before Softmax, preventing vanishing gradients and keeping training going.

FAQ
What happens if you don't scale by √d in Attention?
As the dimension d grows, the dot products QK^T vary more widely — d = 512 can produce scores from 1000 to 3000. Softmax then saturates to 100% and 0%, the gradient becomes nearly zero, and training stalls.
Why divide by √d instead of d?
Because the spread of a sum of d independent terms grows with √d, not d. The coin-toss example shows 100 tosses drift about √100 = 10 steps from the start, so dividing by √d is dividing by the standard deviation, not an average.
What is the coin-toss analogy?
Heads is +1 step, tails is −1 step; after 100 tosses (d = 100), the final distance from the start is about √100 = 10 steps, not zero and not 100.
Qiita 機械学習Read Original Article
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleApple's Siri layoffs hit old infrastructure, not new AI