Abstract
Relational reasoning—the capacity to understand how elements relate to one another—is a defining feature of human intelligence, yet its computational basis remains unclear. Here, we combined human neuroimaging (7T fMRI) and artificial neural network modeling to examine relational reasoning in biological and artificial systems. Using the Latin Square Task, we found that humans and transformers were able to generalise the task reliably, while standard architectures used in cognitive neuroscience could not. Analysing the transformer components revealed distinct computational roles: positional encoding captured the spatial structure of the task and aligned with representations in visual cortex, whereas attention encoded relational structure and mapped onto frontoparietal and default-mode networks. Attention weights tracked the relational complexity of the task, providing a computational analogue of working-memory demands. These results demonstrate convergent computational strategies for reasoning in brains and transformers, highlighting attention-based architectures as powerful models for investigating the neural basis of higher cognition.
Introduction
Relational reasoning—the ability to understand how different elements, such as pieces on a board or words in a sentence, interact—is a cornerstone of human intelligence. While neuroimaging has identified the frontoparietal network as a primary site for these processes, the underlying computational mechanisms remain elusive. Standard artificial neural networks (ANNs) used in neuroscience, such as Multi-Layer Perceptrons (MLPs) and Recurrent Neural Networks (RNNs), often struggle to generalize reasoning tasks to novel scenarios. This study investigates whether the Transformer architecture provides a more accurate computational model for human reasoning and how its specific components—Attention and Positional Encoding—align with biological neural activity.
Methods
The researchers employed a multi-pronged approach combining neuroimaging and computational modeling. High-resolution 7T fMRI data were collected from 40 participants performing the Latin Square Task (LST), a non-verbal reasoning task similar to Sudoku. In the LST, participants identify a missing shape in a 4x4 grid based on the rule that each shape appears only once per row and column.
Concurrently, three types of ANNs—an encoder-only Transformer, an LSTM, and an MLP—were trained to solve the LST. The models were evaluated on 8,000 training puzzles and 1,000 test puzzles, categorized by "relational complexity" (1-vector, 2-vector, or 3-vector problems). A separate validation set of 108 "out-of-distribution" puzzles was used during fMRI scanning to strictly test generalization. Representational Similarity Analysis (RSA) was then used to compare the internal activations of the AI models with the brain activity patterns of the human participants.
Key Results and Insights
Transformers as Robust Generalizers
A significant performance gap emerged between the architectures. On the difficult out-of-distribution validation set, the Transformer achieved 97.65% accuracy, vastly outperforming the LSTM (55.49%) and MLP (33.02%). Furthermore, both human and Transformer performance declined as relational complexity increased, indicating a shared sensitivity to task difficulty that was absent in the other models.
Mapping Computational Circuits to Brain Regions
By isolating the roles of Positional Encoding (PE) and the Attention mechanism, the study revealed a functional division that mirrors the human brain's organization:
- Positional Encoding (PE): This component captures the spatial geometry of the task. RSA confirmed that PE activations align significantly with the primary visual cortex (V1), suggesting that the model's way of representing spatial layout mimics early sensory processing in humans.
- Attention: This mechanism handles the logical relationships between grid elements. Attention activations mapped onto the frontoparietal (FPN) and default-mode networks (DMN), regions associated with fluid intelligence and working memory.
Attention as a Proxy for Working Memory
The study found that as puzzle complexity increased, the Transformer's attention weights became more distributed or "dense." This provides a direct computational analogue to the increased working memory load humans experience during difficult reasoning tasks. Much like the human brain, the Transformer processes information hierarchically: early layers align with sensory visual regions, while deeper layers align with abstract cognitive control regions.
Discussion
These findings suggest that Transformer architectures process complex relationships in a way that remarkably mirrors the human brain. While the Transformer's physical implementation (global self-attention and backpropagation) differs from biological neurons, the resulting representations show significant alignment.
Future research should explore whether these findings hold for other domains, such as verbal or social reasoning. Additionally, the authors suggest using these insights to develop more biophysically plausible models and testing them against even more complex benchmarks like the Abstract Reasoning Corpus (ARC) to further bridge the gap between artificial and biological intelligence.
Summary updated