Topoformer: brain-like topographic organization in Transformer language models through spatial querying and reweighting

Taha Binhuraib, Greta Tuckute, Nicholas M. Blauch · 2025

Read Topoformer: brain-like topographic organization in Transformer language models through spatial querying and reweighting by Taha Binhuraib, Greta Tuckute, Nicholas M. Blauch (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2510-18745.txt.

Introduction

Taha Binhuraib, with Greta Tuckute and Nicholas Blauch, gives transformer language models a brain-like spatial layout. In real brains, neurons are arranged topographically: cells with similar jobs sit near each other. Standard transformers instead store representations in unordered vector spaces that are hard to visualize or interpret.

Their Topoformer redesigns self-attention so that queries and keys live on two-dimensional grids, with local pools of queries tied to each key, and rewires the attention layer to connect only locally. A small sentiment model first proved the idea workable, with organization emerging in different parts of the layer. Scaled up to a BERT-style model trained on masked language modeling, the topographic version matched the ordinary model on language benchmarks while producing interpretable maps across eight linguistic test suites. The authors also compared the organization with human brain responses to natural sentences.

Catalog record

CREATORTaha Binhuraib, Greta Tuckute, Nicholas M. Blauch
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE67 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2510-18745

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Topoformer: brain-like topographic organization in Transformer language models through spatial querying and reweighting Taha Binhuraib, Greta Tuckute, Nicholas M. Blauch Abstract Spatial functional organization is a hallmark of biological brains: neurons are arranged topographically according to their response properties, at multiple scales. In contrast, representations within most machine learning models lack spatial biases, instead manifesting as disorganized vector spaces that are difficult to visualize and interpret. Here, we propose a novel form of self-attention that turns Transformers into “Topoformers” with topographic organization. We introduce spatial querying — where keys and queries are arranged on 2D grids, and local pools of queries are associated with a given key — and spatial reweighting , where we convert the standard fully connected layer of self-attention into a locally connected layer. We first demonstrate the feasibility of our approach by training a 1-layer Topoformer on a sentiment classification task. Training with spatial querying encourages topographic organization in the queries and keys, and spatial reweighting separately encourages topographic organization in the values and self-attention outputs. We then apply the Topoformer motifs at scale, training a BERT architecture with a masked language modeling objective. We find that the topographic variant performs on par with a non-topographic control model on NLP benchmarks, yet produces interpretable topographic organization as evaluated via eight linguistic test suites. Finally, analyzing an fMRI dataset of human brain responses to a large set of naturalistic sentences, we demonstrate alignment between low-dimensional topographic variability in the Topoformer model and human brain language network. Scaling up Topoformers further holds promise for greater interpretability in NLP research, and for more accurate models of the organization of linguistic information in the human brain. 1 Introduction Biological brains are spatially organized, containing category-selective areas ( Kanwisher 2010 ) , broad feature maps that tile individual cortical areas ( Konkle & Oliva 2012 ; Bao et al. 2020 ) and the cortex more broadly ( Huth et al. 2012 ; Huth et al. 2016 ; Margulies et al. 2016 ) , as well as large-scale distributed networks ( Yeo et al. 2011 ; Braga et al. 2020 ) . This spatial organization is one way in which the human brain, a vastly complex “black box”, is more naïvely interpretable than modern deep neural networks (DNNs), whose units have functional properties organized without simple spatial priors. Recent work in computational neuroscience has bridged this gap in DNNs trained for vision, demonstrating that local smoothness or wiring cost minimization objectives can be incorporated into DNNs to encourage the development of smooth functional organization of responses, which can then be easily visualized in 2D ( Lee et al. 2020a ; Blauch et al. 2022 ; Keller & Welling 2021 ; Doshi & Konkle 2021 ; Margalit et al. 2023 ; Lu et al. 2023 ) , building upon classic approaches ( Kohonen 1982 ; Jacobs & Jordan 1992 ) . In addition to simulating topographic properties within regions, topographic vision models have also explained the hierarchical organization of topographic information from earlier to later visual areas ( Margalit et al. 2023 ; Lu et al. 2023 ) . One topographic vision model has even demonstrated the emergence of spatial clusters corresponding to ventral, lateral, and dorsal streams of the visual system ( Finzi et al. 2021 ; Finzi et al. 2023 ) . Collectively, topographic vision models are helping to unify a computational understanding of the functional organization of the visual system. However, topographical priors have not yet been built into models of linguistic processing, despite tremendous progress in the development of natural language processing (NLP) models and their application in cognitive science and neuroscience ( Wilcox et al. 2020 ; Gauthier et al. 2020 ; Schrimpf et al. 2021 ; Caucheteux & King 2022 ; Goldstein et al. 2022a ; Tuckute et al. 2024 ) . In NLP, Transformer language models (LMs) have undoubtedly established themselves as the leading architecture for language tasks ( Vaswani et al. 2017 ; Radford et al. 2018 ; Brown et al. 2020 ; OpenAI 2023 ) , displaying human-like language understanding and generation. In cognitive science and neuroscience, these LMs have emerged as the most quantitatively accurate models of human language processing. They generate probabilities of upcoming words that explain reading behavior of humans ( Wilcox et al. 2020 ; Merkx & Frank 2021 ; Shain et al. 2022 ; Oh & Schuler 2023 ) , and their internal activations can explain the neural signals of humans reading or listening to naturalistic sentences or stories at the granularity of fMRI voxels and intracranial recordings ( Schrimpf et al. 2021 ; Goldstein et al. 2022b ; Caucheteux & King 2022 ; Antonello et al. 2024 ; Tuckute et al. 2024 ) . Despite the success of these LMs, they remain difficult to interpret, and incomplete as models of brain function. In the current work, our aim is to bridge these gaps by inducing a topographic organization of features within the Transformer architecture. We employ local-connectivity based approaches inspired by recent topographic vision models ( Keller & Welling 2021 ; Blauch et al. 2022 ) to the language domain, asking whether we can obtain topographic organization of linguistic representations within a Transformer architecture via spatial constraints. To do so, we introduce two computational motifs — spatial querying and spatial reweighting — to the self-attention layer, which encourage the development of topographic organization in separate components of the self-attention layer. We call Transformer models employing these constraints Topoformers . We show that we can scale these topographic motifs to a large BERT Topoformer model trained with a masked language modeling objective, and that topographic organization develops within each hierarchical layer of the network, without significantly compromising task performance. We interpret this topography using a novel suite of 8 semantic and syntactic tests. Last, we demonstrate that the topographic representations of the Topoformer can be aligned with the topographic representations of the human functionally-defined language network in multiple subjects. In summary, our work demonstrates for the first time that Transformer models can be trained to exhibit topographic organization similar to the human brain, and paves the way for further interpretability work leveraging spatial priors. Figure 1: Spatial querying and reweighting operations in the “Topoformer”. The first row shows standard querying operations in the attention module of a single-head Transformer, and the second row shows the spatial counterparts used in the Topoformer. Standard querying associates a single query dimension of token i with a single key dimension of token j . In contrast, spatial querying associates a local pool of query dimensions with a given key dimension, through the intermediate local pooling matrix M. Standard (dense) reweighting applies a fully connected linear layer W^{O} to the outputs of a single attention head (typically to combine the outputs of multiple attention heads). In our formulation, we use a locally connected layer W^{O}_{\text{local}} in its place (spatial reweighting). While the figure illustrates querying for a pair of tokens and reweighting for a single token, when processing a full sequence, there is a 2D grid of the form shown here for each token. Each heatmap shows the loadings of the second PC of responses (top: control model, bottom: Topoformer-SQR model with spatial querying

Read the complete text