InLine

InLine.

, & .
Bring AI in line with your research.

Manuscript.docx
DocumentLiteratureImages
Revision author: InLine

Stable Attention through Score Scaling

Abstract

Attention mechanisms aggregate information using query–key similarities. We investigate how score scaling affects the concentration of attention weights as the key dimension increases.

1. Introduction

Attention mechanisms allow sequence models to combine information from different input positions. Early work in neural machine translation introduced learned alignment to select relevant source representations during decoding (Bahdanau et al., 2014). Subsequent attention-based models explored alternative scoring functions and alignment strategies, illustrating how the choice of similarity computation shapes the information available to a decoder (Luong et al., 2015).

The Transformer placed attention at the center of a highly parallel sequence architecture (Vaswani et al., 2017). In its dot-product formulation, queries and keys determine similarity scores, while values provide the representations that are combined. This separation makes the mechanism efficient to implement, but it also raises a numerical question: how should the magnitude of a score change when the dimensionality of its inputs increases?

A larger key dimension can increase the magnitude of unnormalized dot products. The is therefore central to explaining how scores become attention weights. Building on the formulation of Vaswani et al. (2017), we compare scaled and unscaled variants under matched conditions. Our aim is to characterize changes in weight concentration, rather than to infer downstream performance from attention patterns alone.

2. Method

The matrices Q, K, and V represent queries, keys, and valuesdenote the query, key, and value matrices. Our algorithm computes pairwise dot products and normalizes the final outputscales the scores before softmax.

The computation implemented in our algorithm is expressed as:

Attention(Q,K,V)=softmax(QKTdk)V(1)

Here, dk is the key dimension. The scale is applied before normalization, and the resulting weights to aggregate the value representations.

We evaluate key dimensions of 16, 64, and 128 while keeping the remaining settings fixed. Attention-weight entropy is recorded for both variants, with higher entropy indicating a less concentrated distribution.

3. Results

The two variants behave differently as the key dimension increases . The unscaled variant produces more concentrated weights, whereas the scaled variant maintains a more distributed pattern.

dkUnscaled entropyScaled entropy
160.860.95
640.310.94
Source: data/attention_scores.csv

At dk = 64, scaled attention yields an entropy of 0.94, compared with 0.31 for the unscaled variant. These results support the use of score scaling in the evaluated conditions.

This comparison demonstrates improved downstream task performanceindicates less concentrated attention weights in the evaluated conditions.

4. Conclusion

Score scaling moderates the effect of increasing key dimensionality on attention concentration. Future work will examine whether this behavior persists across longer sequences and different input distributions.

References

Bahdanau, D., Cho, K., & Bengio, Y. (2014). Neural machine translation by jointly learning to align and translate. arXiv preprint. arXiv:1409.0473.

Luong, M.-T., Pham, H., & Manning, C. D. (2015). Effective approaches to attention-based neural machine translation. arXiv preprint. arXiv:1508.04025.

Vaswani, A., et al. (2017). Attention is all you need. arXiv preprint. arXiv:1706.03762.

Use InLine to start your research,
papers, books and projects.

DOCX

Let AI handle Word tables, equations, and cross-references, making proofreading less tedious.

LaTeX

Compile LaTeX in real time with Tectonic, and connect AI directly to your local LaTeX projects.

Agents

Connect the agents and SKILLs you already use, and work in InLine together with your own agent.

Plugins

Bring the literature tools you already use into the project, and let search and the agents read them.

Library

Bring literature, excerpts, and reading notes into the same project, ready whenever you return to your ideas.

Translate

Select a word or passage and read the translation beside the original. Keep your place and your train of thought.

Data Safety

Keep manuscripts, sources and API keys on your computer, organized in your own folders and always under your control.

Plans and pricing

Start with a free trial, then subscribe in the app when you need it.

See pricing

Leave a little room for your next piece of work.