Loading…
Understanding BigBird's Block Sparse Attention
Vasudev Gupta
Summary
Transformer-based models face severe computational bottlenecks due to quadratic time and memory complexity, making sequences longer than 512 tokens impractical. BigBird addresses this limitation by approximating full attention with block sparse attention, scaling context lengths up to 4096 tokens at a lower computational cost. Instead of attending to all tokens, BigBird combines sliding attention for local context, global tokens for long-range relationships, and random tokens to accelerate information transfer. The model is integrated into HuggingFace Transformers, enabling fine-tuning for tasks like long-document summarization and extractive question answering. When sequences are shorter than 1024 tokens, using original full attention remains recommended.
Context
Standard transformer models exhibit O(n^2) time and memory complexity, which makes processing long sequences (n > 512) computationally expensive and creates severe memory constraints.
Approach / What changed
BigBird replaces standard full attention with block sparse attention by combining sliding local tokens, global tokens (first and last blocks), and random tokens into block-based computations.
Takeaways
- BigBird handles sequence lengths up to 4096 tokens by approximating full attention with block sparse attention.
- The sparse attention mechanism combines sliding window tokens, global tokens, and randomly selected tokens to capture local and long-range dependencies efficiently.
- In Hugging Face Transformers, the sequence length must satisfy specific lower bounds relative to block configurations, or the implementation falls back to original_full attention.
Related reading
huggingface.co ·
The Reformer - Pushing the limits of language modeling
Standard transformer models hit memory bottlenecks on long sequence modeling tasks due to the quadratic asymptotic memory complexity of global self-attention and oversized positional embedding matrices. The Reformer architecture overcomes these constraints to train sequences of up to half a million tokens using under 8GB of RAM. It re-engineers transformer operations using local and Locality Sensitive Hashing self-attention, chunked feed forward layers, reversible residual layers, and axial positional encodings. In empirical benchmarks using google/reformer-crime-and-punishment, axial positional encodings reduce the model parameter count from over 136 million to approximately 2.58 million by factorizing the positional dimensions. This architectural change cuts inference memory consumption from 959 MB down to 447 MB for evaluated benchmark workloads.
Patrick von PlatenIntroducing RTEB: A New Standard for Retrieval Evaluation
Public embedding benchmarks often fail to measure true generalization because training sets overlap with public evaluation data, rewarding memorization over general search quality. The Retrieval Embedding Benchmark (RTEB) beta introduces a standardized evaluation framework designed for real-world enterprise retrieval applications. To prevent overfitting while preserving transparency, RTEB combines fully public datasets with private evaluation sets managed exclusively by MTEB maintainers. The suite spans 20 languages across domains like healthcare, law, finance, and code, measuring ranked retrieval quality using NDCG@10 on datasets of at least 1,000 documents. While currently limited to text-only retrieval and containing repurposed question-answering datasets, the benchmark provides clear signals when models degrade on unseen data.