[Paper Review] Blockwise Self-Attention for Long Document Understanding
BlockBERT introduces a sparse block structure to the self-attention mechanism in BERT, reducing memory and computation costs by limiting attention to localized blocks rather than full sequences. It achieves 18.7–36.1% lower memory usage, 12.0–25.1% faster training, and 27.8% faster inference than RoBERTa, with comparable or improved downstream performance on long document tasks.
We present BlockBERT, a lightweight and efficient BERT model for better modeling long-distance dependencies. Our model extends BERT by introducing sparse block structures into the attention matrix to reduce both memory consumption and training/inference time, which also enables attention heads to capture either short- or long-range contextual information. We conduct experiments on language model pre-training and several benchmark question answering datasets with various paragraph lengths. BlockBERT uses 18.7-36.1% less memory and 12.0-25.1% less time to learn the model. During testing, BlockBERT saves 27.8% inference time, while having comparable and sometimes better prediction accuracy, compared to an advanced BERT-based model, RoBERTa.
Motivation & Objective
- Address the high memory and computational cost of training and inferring BERT on long sequences, which limits model scalability and deployment.
- Identify dot-product self-attention as the primary memory bottleneck in BERT, due to its quadratic complexity with respect to sequence length.
- Design a lightweight BERT variant that maintains strong performance on long-context tasks while significantly reducing memory and inference time.
- Enable efficient modeling of long-distance dependencies through structured sparsity in attention matrices without sacrificing model accuracy.
- Provide a simple, implementable alternative to complex sparse attention mechanisms that rely on custom kernels or limited hardware support.
Proposed method
- Introduce block-sparse attention by partitioning the sequence into fixed-size blocks and restricting self-attention to within-block and select inter-block connections.
- Replace the full, dense attention matrix in BERT with a block-sparse matrix structure, reducing FLOPs and memory usage proportionally to the sparsity pattern.
- Maintain multi-head attention but restrict each head to attend only within or between predefined blocks, enabling both local and long-range modeling.
- Use a simple, differentiable sparsity pattern that is compatible with standard deep learning frameworks and avoids custom CUDA kernels.
- Preserve the original BERT architecture and pre-training objective, focusing only on modifying the attention mechanism to improve efficiency.
- Apply the block-sparse attention across all Transformer layers, ensuring end-to-end compatibility with existing fine-tuning pipelines.
Experimental results
Research questions
- RQ1Can structured sparsity in the attention matrix reduce memory and computation costs in BERT without degrading performance on long-context tasks?
- RQ2How does block-sparse attention compare to dense attention in terms of downstream task accuracy, especially for long documents?
- RQ3To what extent can block-sparse attention reduce training and inference time while maintaining model capacity for long-range dependencies?
- RQ4Does the block-sparse design allow attention heads to effectively capture both short- and long-range dependencies, as intended?
- RQ5How does the efficiency gain of BlockBERT compare to state-of-the-art BERT variants like RoBERTa, especially in real-world deployment scenarios?
Key findings
- BlockBERT reduces memory consumption by 18.7–36.1% during training compared to RoBERTa, primarily due to sparsified attention matrices.
- Training time is reduced by 12.0–25.1% due to fewer FLOPs and lower memory pressure enabling larger batch sizes.
- Inference time is reduced by 27.8% compared to RoBERTa, making it more suitable for real-time or resource-constrained applications.
- BlockBERT achieves comparable or better performance than RoBERTa on multiple question-answering benchmarks with varying paragraph lengths.
- The block-sparse attention mechanism successfully enables attention heads to model both local and long-range dependencies effectively.
- The method is simple and compatible with standard deep learning frameworks, avoiding the need for custom kernels or complex sparsity management.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.