Learning Correlation Structures for Vision Transformers

Manjin Kim, Paul Hongsuck Seo, Cordelia Schmid, Minsu ChoCVPR 2024

Abstract: We introduce a new attention mechanism, dubbed structural self-attention (StructSA), that leverages rich correlation patterns naturally emerging in key-query interactions of attention. StructSA generates attention maps by recognizing space-time structures of key-query correlations via convolution and uses them to dynamically aggregate local contexts of value features. This effectively leverages rich structural patterns in images and videos such as scene layouts, object motion, and inter-object relations. Using StructSA as a main building block, we develop the structural vision transformer (StructViT) and evaluate its effectiveness on both image and video classification tasks, achieving state-of-the-art results on ImageNet-1K, Kinetics-400, Something-Something V1 & V2, Diving-48, and FineGym.

Introduction

While Vision Transformers (ViTs) have revolutionized computer vision, they often struggle with the "permutation invariance" of standard self-attention. In a vanilla transformer, the relationship between a query and a key is reduced to a single scalar dot product, which ignores the spatial or temporal arrangement of the surrounding keys.

In reality, the "map" of correlations between a query and its neighbors contains rich information. For example, in a video, these correlations reveal motion trajectories; in an image, they reveal object boundaries and scene layouts. Standard transformers often ignore these geometric structures, relying instead on positional encodings to provide a sense of space. The authors argue that by failing to recognize these "correlation structures," models miss out on a crucial cue for visual reasoning and generalization.

Structural Self-Attention (StructSA)

The authors propose Structural Self-Attention (StructSA), which replaces standard scalar-based attention with a structure-aware process consisting of two main components:

  1. Structural Query-Key Attention (SQKA): Instead of treating each query-key correlation as an isolated value, SQKA applies convolutional kernels over the local correlation maps. These kernels act as "pattern detectors," recognizing specific geometric arrangements (like edges or motion directions) in the interaction between pixels or frames.
  2. Contextual Value Aggregation: Once a pattern is detected, the model uses it to dynamically aggregate a local neighborhood (context) of value features, rather than weighting a single "value" vector.
The StructSA pipeline: SQKA extracts structural patterns from query-key correlation maps to guide context aggregation.

A key innovation is the introduction of a "structure dimension" ($D$). While previous "Convolutional Self-Attention" (ConvSA) methods can be seen as a restricted version of this approach ($D=1$), StructSA allows the model to learn multiple, diverse pattern extractors simultaneously. This enables the model to capture a variety of complex structures—for instance, one head might focus on horizontal motion while another captures vertical textures.

Key Insights and Expressivity

The core insight of this work is treating the query-key interaction not as a mathematical intermediate, but as a feature map that deserves its own convolutional processing. The paper demonstrates that increasing the structure dimension ($D$) leads to consistent performance improvements, proving that a single convolutional projection is insufficient to capture the full complexity of visual relationships.

Comparison of learned patterns between ConvSA (D=1) and StructSA (D=8). StructSA captures a richer variety of structural patterns.

StructSA is particularly powerful for video. By recognizing spatio-temporal structures, it can distinguish between subtle actions (like "pushing something left to right" vs. "right to left") much more effectively than models that treat time as just another dimension. To maintain efficiency, the authors employ strided key/value projections, matching the computational cost (FLOPs) of baseline models while delivering higher accuracy.

Experimental Results

The authors evaluated StructViT on a wide array of benchmarks, including ImageNet-1K for images and Kinetics-400, Something-Something V1 & V2, and Diving-48 for videos. StructViT consistently outperformed both pure transformers and existing hybrid models:

  • ImageNet-1K: StructViT-B reached 86.5% top-1 accuracy (with token labeling), surpassing similar-sized models like MViTv2 and UniFormer.
  • Something-Something V2: On this motion-centric dataset, StructViT-B achieved 71.5% top-1 accuracy, a significant margin over the baseline UniFormer-B.
  • Efficiency: On Kinetics-400, StructViT-B achieved 83.4% top-1 accuracy using only 55% of the computation required by MTV-B.
  • Generalization: The model also improved object detection performance on COCO by 1.0% box mAP when used as a backbone.

Conclusion

StructSA introduces a principled way to incorporate geometric and temporal structure into the transformer architecture. While the mechanism is more complex than vanilla attention, its ability to capture rich correlation patterns leads to significant gains in both image and video understanding. Future work may explore applying these structural insights to other domains like Natural Language Processing or generative modeling.

Summary updated

BibTeX
@inproceedings{kim2024learning,
  author = {Manjin Kim and Paul Hongsuck Seo and Cordelia Schmid and Minsu Cho},
  title = {{Learning Correlation Structures for Vision Transformers}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  url = {https://openreview.net/forum?id=mjBc5i3B3L},
}
Figure