Skip to main content
QUICK REVIEW

[Paper Review] Cluster-Former: Clustering-based Sparse Transformer for Long-Range Dependency Encoding

Shuohang Wang, Luowei Zhou|arXiv (Cornell University)|Sep 13, 2020
Topic ModelingComputer Science41 references19 citations
TL;DR

Cluster-Former proposes a novel sparse Transformer architecture that combines sliding-window attention with clustering-based global attention to effectively model long-range dependencies in long sequences. By periodically clustering hidden states into centroids and applying Transformer attention over these clusters, it achieves state-of-the-art performance on long-context question answering benchmarks such as Quasar-T, SearchQA, and Natural Questions (long answer) without quadratic complexity growth.

ABSTRACT

Transformer has become ubiquitous in the deep learning field. One of the key ingredients that destined its success is the self-attention mechanism, which allows fully-connected contextual encoding over input tokens. However, despite its effectiveness in modeling short sequences, self-attention suffers when handling inputs with extreme long-range dependencies, as its complexity grows quadratically with respect to the sequence length. Therefore, long sequences are often encoded by Transformer in chunks using a sliding window. In this paper, we propose Cluster-Former, a novel clustering-based sparse Transformer to perform attention across chunked sequences. The proposed framework is pivoted on two unique types of Transformer layer: Sliding-Window Layer and Cluster-Former Layer, which encode local sequence information and global context jointly and iteratively. This new design allows information integration beyond local windows, which is especially beneficial for question answering (QA) tasks that rely on long-range dependencies. Experiments show that Cluster-Former achieves state-of-the-art performance on several major QA benchmarks.

Motivation & Objective

  • To address the quadratic computational and memory complexity of standard self-attention in long sequences.
  • To improve long-range dependency modeling beyond sliding-window and hand-designed sparse attention patterns.
  • To develop a flexible, learnable mechanism for capturing global context in long-context NLP tasks.
  • To achieve state-of-the-art performance on question answering tasks requiring long-context reasoning.
  • To demonstrate the generalization of the method beyond QA to language modeling.

Proposed method

  • The model uses two types of Transformer layers: Sliding-Window Layer for local context encoding within fixed-length chunks.
  • Cluster-Former Layer applies K-Means clustering to hidden states from the prior layer to group semantically or structurally similar representations.
  • Cluster centroids are updated periodically (e.g., every epoch) using a memory bank of accumulated hidden states, avoiding online computation.
  • The clustered hidden states are uniformly divided into chunks and processed by separate Transformer layers to enable cross-chunk attention.
  • The framework combines local (sliding-window) and global (cluster-based) attention in a hybrid architecture to balance efficiency and long-range modeling.
  • The number of clusters (C) is a hyperparameter, with 512 clusters shown to yield optimal performance on QA tasks.

Experimental results

Research questions

  • RQ1Can clustering-based attention outperform hand-designed sparse attention patterns in modeling long-range dependencies?
  • RQ2Does using learned cluster centroids improve global context encoding compared to random hashing or fixed-position selection?
  • RQ3How does the number of clusters affect performance on long-context question answering tasks?
  • RQ4Can the Cluster-Former architecture generalize beyond question answering to other long-context NLP tasks like language modeling?
  • RQ5Which layer positions in the Transformer stack are most effective for deploying the Cluster-Former layer?

Key findings

  • Cluster-Former achieves new state-of-the-art results on Quasar-T, SearchQA, and Natural Questions (long answer) benchmarks.
  • With 512 clusters, the model significantly outperforms both Sparse Attention and Locality-Sensitive Hashing (LSH) baselines on QA tasks.
  • The model with 512 clusters performs substantially better than the 64-cluster variant on most QA tasks, though improvements are marginal on Natural Questions long answer due to token-specific clustering patterns.
  • The best performance is achieved when at least one Cluster-Former layer is placed in the middle layers (e.g., layers 8–16), while placing it near the end (e.g., layer 22–23) leads to degraded performance.
  • On language modeling tasks (Wikitext-103 and Enwik8), Cluster-Former outperforms strong baselines, demonstrating its generalization beyond QA.
  • Qualitative analysis confirms that Cluster-Former successfully groups semantically similar tokens (e.g., time words, entities) and even distant hidden states (e.g., 6000+ tokens apart) into the same cluster, indicating effective long-range dependency detection.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.