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.
翻译:空间功能组织是生物大脑的一个标志性特征:神经元根据其响应特性以多尺度地形方式排列。相比之下,大多数机器学习模型中的表征缺乏空间偏置,表现为难以可视化和解释的无序向量空间。本文提出一种新颖的自注意力形式,可将Transformer转变为具有地形组织的“Topoformer”。我们引入了空间查询——其中键和查询排列在二维网格上,且局部查询池与给定键相关联——以及空间重加权,将标准自注意力的全连接层转换为局部连接层。我们首先通过在情感分类任务上训练单层Topoformer验证了方法的可行性。采用空间查询的训练促使查询和键形成地形组织,而空间重加权则分别促使值和自注意力输出形成地形组织。随后我们将Topoformer模块扩展至大规模模型,训练了基于掩码语言建模目标的BERT架构。研究发现,在地形变体在自然语言处理基准测试中与非地形对照模型性能相当的同时,通过八项语言学测试套件评估,其产生了可解释的地形组织。最后,通过分析人类大脑对大量自然语句响应的功能磁共振成像数据集,我们证明了Topoformer模型中低维地形变异与人类大脑语言网络之间存在对齐关系。进一步扩大Topoformer规模有望提升自然语言处理研究的可解释性,并为人类大脑语言信息的组织机制提供更精确的模型。