Abstract
Standard Transformer architectures face a quadratic computational bottleneck when processing long sequences, limiting their effectiveness for long-context tasks. We present Cluster-Former, a hybrid architecture that alternates between local sliding-window attention and a novel clustering-based global attention. By grouping semantically similar tokens via the K-Means algorithm, Cluster-Former enables long-range dependencies without the $O(n^2)$ cost. Our approach achieves state-of-the-art performance on major benchmarks, including the Natural Questions leaderboard.
Introduction
The "quadratic bottleneck" is a fundamental challenge in Transformer models: as sequence length doubles, memory and compute requirements quadruple. For open-domain Question Answering (QA), where models must digest thousands of words to locate specific facts, this scaling issue is prohibitive. While common workarounds like sliding windows or fixed sparse patterns exist, they often fail to capture the complex, long-range relationships required for difficult questions. Cluster-Former addresses this by implementing a learnable, semantic-based sparse attention mechanism.
Methodology
The authors introduce a dual-layer architecture that balances local detail with global context through two alternating layer types.
1. Sliding-Window Layer
This layer processes text in small, overlapping chunks. It is optimized for capturing local syntax and immediate context, such as recognizing that a sequence of words forms a specific entity name.
2. Cluster-Former Layer
The Cluster-Former layer is the core innovation of the architecture. Instead of attending to adjacent tokens, it groups hidden states into clusters based on semantic similarity using the K-Means algorithm.
- Mechanism: The model maintains a "memory bank" of hidden states. Periodically, it runs K-Means to identify cluster centroids.
- Sparse Attention: During a forward pass, each token is assigned to the cluster whose centroid it most resembles. Attention is then performed exclusively between tokens within the same cluster.
- Efficiency: To avoid the overhead of running K-Means at every step, the model uses "stale" centroids that are updated periodically (e.g., every epoch), providing a significant speedup with negligible accuracy loss.
By stacking these layers, the model iteratively refines local representations and integrates them into a global understanding, allowing a token at the beginning of a 5,000-word document to attend to a relevant token at the very end.
Experiments and Results
Cluster-Former was evaluated on several high-stakes QA and Language Modeling benchmarks, including Natural Questions (NQ), SearchQA, Quasar-T, and Wikitext-103.
Key Results
- Leaderboard Dominance: Cluster-Former achieved the No. 1 position on the Natural Questions leaderboard for long-answer tasks and No. 4 for short-answer tasks at the time of publication.
- Superiority over LSH: The model consistently outperformed Locality-Sensitive Hashing (LSH)—the method used in the Reformer model—demonstrating that clustering is a more robust way to handle long-range dependencies in text.
- Scalability: The architecture successfully handled context lengths up to 5,000 tokens, significantly outperforming standard sliding-window baselines.
Key Insights
The success of Cluster-Former highlights that semantics are often more important than position for attention. Clustering creates a "learnable" sparse pattern that adapts to the data rather than relying on a rigid human-designed grid. Additionally, the researchers found that placing Cluster-Former layers deeper in the network (e.g., layers 15 and 20 of a 24-layer model) is most effective, suggesting the model needs a solid local foundation before establishing global connections.
Limitations and Future Work
Despite its performance, Cluster-Former is sensitive to hyperparameters like the number of clusters and memory bank size. The "centroid lag" from periodic updates also presents a minor limitation. Future work may explore more advanced clustering algorithms to further optimize the training pipeline and performance.
Summary updated