The objective of this study was to explore a training-free method to reduce tokens and consequently computational costs in vision transformers in a way that is spatially coherent. Vision transformers (ViTs) use self-attention to achieve state-of-t...
The objective of this study was to explore a training-free method to reduce tokens and consequently computational costs in vision transformers in a way that is spatially coherent. Vision transformers (ViTs) use self-attention to achieve state-of-the-art results in image and video intelligence tasks, including classification, action recognition, text-to-video retrieval (and vice versa), etc. The input to a ViT is always converted into a sequence of ‘tokens’ processed within the layers of a transformer. The self-attention inside a transformer is of quadratic complexity with respect to token count. The higher the number of tokens, the better the results of the transformer, but the higher the computational cost. Methods to reduce token count by pruning or merging have been introduced. These methods perform token merging or pruning based on attention matrix data and are performed anywhere in the sequence. This thesis investigates a spatially-constrained token reduction strategy, inspired the concept that spatially close together tokens carry similar information, especially if they are background or low-motion tokens, aiming to study if if reducing tokens while being mindful of their original location in the image or frame can contribute to improving efficiency without sacrificing accuracy. This work proposes a spatially- constrained mechanism that is injected in between transformer layers once, and replaces the transformer’s view with an adaptive view where tokens are different sizes based on the data they contain. This coarse+fine view aims to represent important areas at the original resolution, but convert less important regions into singular tokens at 2x2 coverage. The selected importance metric is L2 Norm of token embeddings, and the original position of each token is tracked throughout the network. The proposed method achieves only a 0.09% accuracy drop at 128 GFLOPs on Kinetics-400, and 0.24% accuracy drop at 115 GFLOPs on Something-Something V2.
Key words
Video Transformers, Token Merging, Token Reduction, Efficient Inference, Spatial Token Merging, VideoMAE