IDEAS home Printed from https://ideas.repec.org/a/eee/phsmap/v686y2026ics0378437126000993.html

Self-attention vector output similarities reveal how machines pay attention

Author

Listed:
  • Halevi, Tal
  • Tzach, Yarden
  • Gross, Ronit D.
  • Rosner, Shalom
  • Kanter, Ido

Abstract

The self-attention mechanism has significantly advanced the field of natural language processing, facilitating the development of advanced language-learning machines. Although its utility is widely acknowledged, the precise mechanisms of self-attention underlying its advanced learning and the quantitative characterization of this learning process remains an open research question. This study introduces a new approach for quantifying information processing within the self-attention mechanism. The analysis conducted on the BERT-12 architecture reveals that, in the final layers, the attention map focuses on sentence separator tokens, suggesting a practical approach to text segmentation based on semantic features. Based on the vector space emerging from the self-attention heads, a context similarity matrix, measuring the scalar product between two token vectors was derived, revealing distinct context similarities between different token vector pairs within each head and layer. The findings demonstrated that different attention heads within an attention block focused on different linguistic characteristics, such as identifying token repetitions in a given text or recognizing a token of common appearance in the text and its surrounding context. This specialization is also reflected in the distribution of distances between token vectors with high context similarities as the architecture progresses. The initial attention layers exhibit substantially long-range context similarities; however, as the layers progress, a more short-range context similarity develops, culminating in a preference for attention heads to create strong context similarities within the same sentence. Finally, the behavior of individual heads was analyzed by examining the uniqueness of their most common tokens in their high context similarity elements. Each head tends to focus on a unique token from the text and builds similarity pairs centered around it. This methodology for quantifying the behavior of the vector space emerging from the self-attention layers offers a novel way to understand the dynamics of the self-attention mechanism with respect to its outputs.

Suggested Citation

  • Halevi, Tal & Tzach, Yarden & Gross, Ronit D. & Rosner, Shalom & Kanter, Ido, 2026. "Self-attention vector output similarities reveal how machines pay attention," Physica A: Statistical Mechanics and its Applications, Elsevier, vol. 686(C).
  • Handle: RePEc:eee:phsmap:v:686:y:2026:i:c:s0378437126000993
    DOI: 10.1016/j.physa.2026.131363
    as

    Download full text from publisher

    File URL: http://www.sciencedirect.com/science/article/pii/S0378437126000993
    Download Restriction: Full text for ScienceDirect subscribers only. Journal offers the option of making the article available online on Science direct for a fee of $3,000

    File URL: https://libkey.io/10.1016/j.physa.2026.131363?utm_source=ideas
    LibKey link: if access is restricted and if your library uses this service, LibKey will redirect you to where you can use your library subscription to access this item
    ---><---

    As the access to this document is restricted, you may want to

    for a different version of it.

    More about this item

    Keywords

    ;
    ;
    ;

    Statistics

    Access and download statistics

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:eee:phsmap:v:686:y:2026:i:c:s0378437126000993. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    We have no bibliographic references for this item. You can help adding them by using this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: Catherine Liu (email available below). General contact details of provider: http://www.journals.elsevier.com/physica-a-statistical-mechpplications/ .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.