A Unified and Biologically-Plausible Relational Graph Representation of Vision Transformers

Yuzhong Chen, Yu Du, Zhenxiang Xiao, Lin Zhao, Lu Zhang, David Weizhong Liu, Dajiang Zhu, Tuo Zhang, Xintao Hu, Tianming Liu, Xi Jiang

TL;DR

Researchers have developed a unified graph-based framework to represent various Vision Transformer (ViT) architectures, revealing that top-performing models share specific "sweet spots" in their graph topology. Crucially, the study finds that these high-performing artificial networks structurally resemble mammalian brains more closely than simpler models do, offering a new bridge between AI and neuroscience.

What Problem Does This Paper Address?

While Vision Transformers (ViTs) and their variants (like Swin, Mixer, and MetaFormer) have revolutionized computer vision, we lack a unified way to compare their internal structures. Each model uses different strategies to aggregate spatial information—some use self-attention, others use MLPs or even simple pooling.

Furthermore, while artificial neural networks (ANNs) are loosely inspired by biology, the structural similarity between modern ViTs and real biological neural networks (BNNs) remains largely unexplored. This paper aims to bridge these gaps by proposing a relational graph representation that can describe any ViT architecture and compare it directly to the "connectomes" of biological brains.

Methods

The authors decompose the complex operations of a ViT into two distinct sub-graphs:

  1. Aggregation Graph: This treats spatial image patches (tokens) as nodes. It describes how information is shared across different regions of an image. For example, in a standard ViT, the self-attention mechanism defines the edges of this graph.
  2. Affine Graph: This treats network channels as nodes. it reflects the communication between different features or dimensions, typically occurring within the Feedforward Networks (FFN).

To make different models comparable, the authors fixed the aggregation graph size (e.g., 14x14 nodes) and used down-sampling or up-sampling techniques for models with different resolutions. They then characterized these graphs using two standard metrics from graph theory:

  • Clustering Coefficient ($C$): Measures how "clumped" the nodes are (segregation).
  • Average Path Length ($L$): Measures how many "steps" it takes to get from one node to another (integration).
Figure 1: The aggregation and affine graph in different ViT models. (a) The patch embedding in vision transformer models. (b) The aggregation graph and (d) the affine graph in vision transformer models. (c) the structure of transformer vision models.

Datasets

The study evaluated 21 pretrained ViT models across several datasets:

  • Image Classification: CIFAR10, Animal10, and Flower17 (a small-sample dataset to test adaptability).
  • Training from Scratch: ImageNet-1k was used to observe how graph measures evolve during training.
  • Biological Connectomes: The authors compared their artificial graphs to real brain data from C. elegans (nematode), rats, cats, and macaque monkeys.

Key Insights and Ideas

  • The "Sweet Spot" for Performance: The researchers discovered a U-shaped correlation between graph measures and model accuracy. The best-performing models aren't those with the highest or lowest clustering, but rather those that fall into a specific "sweet spot" ($C \approx 0.84$, $L \approx 1.2-1.3$).
  • ViTs are "Mammalian": In a striking finding, the relational graphs of ViTs showed high similarity to the brain networks of cats and macaques. In contrast, older MLP and CNN models were structurally closer to the simpler nervous systems of worms. This suggests that the success of ViTs may stem from their more "advanced" information exchange patterns.
  • Indicators of Learning: During training, the graph measures change in tandem with accuracy. This suggests that $C$ and $L$ could serve as "health indicators" for model training, potentially identifying failing runs early.
  • Adaptability in Few-Shot Learning: For small datasets like Flower17, the relationship between graph structure and performance becomes linear rather than U-shaped, indicating that certain graph topologies are inherently better at adapting to new tasks with limited data.
Figure 2 shows the U-shaped relationship between graph measures and accuracy on large datasets, and the linear relationship on the small-sample Flower17 dataset.

Key Results

  • Quantitative Sweet Spots: Identified stable sweet spots across multiple datasets: $C \in [0.839, 0.842]$ and $L \in [1.256, 1.307]$.
  • Predictive Power: On the Flower17 dataset, the clustering coefficient showed a strong linear correlation with accuracy ($R^2 = 0.51, p < 0.001$), proving it is a robust indicator of model performance in data-constrained scenarios.
  • Biological Alignment: ViTs consistently demonstrated higher topological similarity to mammalian BNNs than traditional CNNs, as visualized in the comparative heatmaps of Figure 4.
Figure 4 compares the relational graphs of various ANNs to the BNNs of different species, highlighting the mammalian-like structure of ViTs.

Limitations and Future Work

The primary limitation acknowledged is the content-independent assumption. The current graph construction assumes that image patches are independent and that spatial relationships are fixed by positional embeddings, ignoring the actual visual content of the image.

Future work could involve:

  • Integrating dynamic, image-content-dependent information into the graph construction.
  • Using these "sweet spots" as constraints for Neural Architecture Search (NAS) to automatically design more efficient and biologically-plausible models.
  • Exploring how these graph properties relate to model robustness and adversarial vulnerability.

Summary updated

Abstract

Vision transformer (ViT) and its variants have achieved remarkable successes in various visual tasks. The key characteristic of these ViT models is to adopt different aggregation strategies of spatial patch information within the artificial neural networks (ANNs). However, there is still a key lack of unified representation of different ViT architectures for systematic understanding and assessment of model representation performance. Moreover, how those well-performing ViT ANNs are similar to real biological neural networks (BNNs) is largely unexplored. To answer these fundamental questions, we, for the first time, propose a unified and biologically-plausible relational graph representation of ViT models. Specifically, the proposed relational graph representation consists of two key sub-graphs: aggregation graph and affine graph. The former one considers ViT tokens as nodes and describes their spatial interaction, while the latter one regards network channels as nodes and reflects the information communication between channels. Using this unified relational graph representation, we found that: a) a sweet spot of the aggregation graph leads to ViTs with significantly improved predictive performance; b) the graph measures of clustering coefficient and average path length are two effective indicators of model prediction performance, especially when applying on the datasets with small samples; c) our findings are consistent across various ViT architectures and multiple datasets; d) the proposed relational graph representation of ViT has high similarity with real BNNs derived from brain science data. Overall, our work provides a novel unified and biologically-plausible paradigm for more interpretable and effective representation of ViT ANNs.
BibTeX
@article{chen2024unified,
  author = {Yuzhong Chen and Yu Du and Zhenxiang Xiao and Lin Zhao and Lu Zhang and David Weizhong Liu and Dajiang Zhu and Tuo Zhang and Xintao Hu and Tianming Liu and Xi Jiang},
  title = {{A Unified and Biologically-Plausible Relational Graph Representation of Vision Transformers}},
  journal = {IEEE Transactions on Neural Networks and Learning Systems},
  year = {2024},
  doi = {10.1109/tnnls.2023.3342810},
}
Figure