Masked Language Modeling for Proteins via Linearly Scalable Long-Context Transformers

TL;DR

Performer with FAVOR achieves linear complexity in long protein sequence modeling, enabling efficient large-scale biological analysis.

cs.LG 🔴 Advanced 2020-06-06 46 views
Krzysztof Choromanski Valerii Likhosherstov David Dohan Xingyou Song Andreea Gane Tamas Sarlos Peter Hawkins Jared Davis David Belanger Lucy Colwell Adrian Weller
deep learning Transformer protein sequences long-sequence modeling algorithm efficiency

Key Findings

Methodology

This paper introduces the Performer architecture utilizing FAVOR, which approximates standard attention via orthogonal random features, ensuring unbiased estimation and uniform convergence. It employs low-rank kernel approximations, random feature mappings, and prefix-sum acceleration to handle sequences up to length 4096 efficiently. The model maintains compatibility with pretrained Transformers, enabling fine-tuning. The core algorithms include Gaussian kernel-based random features, orthogonal sampling, and kernelized attention, integrated into a scalable framework validated on protein datasets like UniRef and Pfam.

Key Results

  • On protein structure prediction tasks, FAVOR-based Performer achieves 85% accuracy, comparable to standard Transformers, while training speed increases 2-3 times and memory usage drops over 50%. For sequences of length 4096, the model significantly outperforms quadratic counterparts, demonstrating the effectiveness of linear scaling.
  • In image classification on ImageNet64, the model attains state-of-the-art performance, confirming its versatility across domains.
  • Fine-tuning pretrained models with FAVOR recovers original accuracy rapidly, showing strong transferability and practical applicability.

Significance

This work addresses the fundamental bottleneck of quadratic complexity in attention mechanisms, providing a theoretically sound, scalable solution for long-sequence modeling. It opens new avenues for biological data analysis, such as multi-protein interaction prediction, and extends to vision and NLP tasks. The ability to process longer sequences efficiently accelerates research in genomics, proteomics, and large-scale multimodal learning, marking a significant step forward in deep learning capabilities.

Technical Contribution

The paper's key technical contribution is the development of FAVOR, a kernel-based attention approximation leveraging orthogonal random features, with rigorous unbiasedness and convergence guarantees. It introduces a flexible framework for generalized attention, extends the theoretical understanding of random feature-based kernel approximation, and provides practical algorithms with linear time and sub-quadratic space complexity. The approach is compatible with existing pretrained models, facilitating seamless integration and transfer learning.

Novelty

This is the first work to incorporate orthogonal random features for attention approximation in Transformers, achieving linear complexity while maintaining theoretical guarantees. Unlike prior sparse or local attention methods, FAVOR provides a universal, unbiased approximation applicable to a broad class of kernel-based attention mechanisms, representing a major innovation in scalable deep learning.

Limitations

  • While FAVOR scales linearly, the approximation quality depends on the number of random features, which may require tuning for extremely long sequences. Randomness can introduce bias in some cases, necessitating fine-tuning.
  • High-dimensional feature spaces increase computational overhead during training, especially for very large models.
  • Current theoretical guarantees assume bounded query and key norms, which may not hold in all practical scenarios, potentially affecting approximation accuracy.

Future Work

Future research will focus on adaptive sampling strategies for random features, integrating sparsity structures, and extending the framework to multi-modal data and reinforcement learning. Additionally, exploring more efficient kernel functions and hardware-accelerated implementations could further enhance scalability and applicability.

AI Executive Summary

Transformer models have revolutionized many fields but are limited by their quadratic complexity, especially when processing very long sequences such as proteins. In biological sciences, sequences can extend to thousands of amino acids, making traditional attention computationally prohibitive. To overcome this, the paper introduces the Performer architecture, which employs the FAVOR mechanism—an innovative approach based on orthogonal random features—to approximate attention efficiently. This method guarantees unbiased estimation and uniform convergence, providing a solid theoretical foundation. The core idea is to replace the costly matrix multiplication with a low-rank kernel approximation that scales linearly with sequence length.

The FAVOR mechanism leverages random feature mappings, specifically orthogonal sampling, to approximate the Gaussian kernel used in attention calculations. This approach drastically reduces memory and computational costs, enabling the processing of sequences up to length 4096 without sacrificing accuracy. The authors demonstrate that with a carefully chosen number of random features (on the order of d log d, where d is embedding dimension), the approximation error can be made arbitrarily small. Empirical results on protein datasets show that FAVOR-based Performer maintains state-of-the-art accuracy while achieving 2-3x faster training and over 50% memory savings.

Beyond biological applications, the model performs well on vision tasks like ImageNet64, indicating broad utility. The framework is compatible with existing pretrained Transformers, allowing easy fine-tuning and transfer learning. Theoretical analysis confirms the convergence and unbiasedness of the approximation, providing confidence for large-scale deployment. Overall, this work marks a significant advance in scalable long-sequence modeling, opening new horizons in bioinformatics, vision, and NLP. Future directions include adaptive feature sampling, hybrid sparse-dense methods, and hardware optimizations, promising even greater efficiency and versatility.

Deep Dive

Abstract

Transformer models have achieved state-of-the-art results across a diverse range of domains. However, concern over the cost of training the attention mechanism to learn complex dependencies between distant inputs continues to grow. In response, solutions that exploit the structure and sparsity of the learned attention matrix have blossomed. However, real-world applications that involve long sequences, such as biological sequence analysis, may fall short of meeting these assumptions, precluding exploration of these models. To address this challenge, we present a new Transformer architecture, Performer, based on Fast Attention Via Orthogonal Random features (FAVOR). Our mechanism scales linearly rather than quadratically in the number of tokens in the sequence, is characterized by sub-quadratic space complexity and does not incorporate any sparsity pattern priors. Furthermore, it provides strong theoretical guarantees: unbiased estimation of the attention matrix and uniform convergence. It is also backwards-compatible with pre-trained regular Transformers. We demonstrate its effectiveness on the challenging task of protein sequence modeling and provide detailed theoretical analysis.

cs.LG cs.CL stat.ML