Unshackling Context Length: An Efficient Selective Attention Approach through Query-Key Compression

Haoyu Wang, Tong Teng, Tianyu Guo, An Xiao, Duyu Tang +2 more
2/20/2025
cs.CL

No confident code implementation found for this paper.

Abstract

Handling long-context sequences efficiently remains a significant challenge in large language models (LLMs). Existing methods for token selection in sequence extrapolation either employ a permanent eviction strategy or select tokens by chunk, which may lead to the loss of critical information. We propose Efficient Selective Attention (ESA), a novel approach that extends context length by efficiently selecting the most critical tokens at the token level to compute attention. ESA reduces the computational complexity of token selection by compressing query and key vectors into lower-dimensional representations. We evaluate ESA on long sequence benchmarks with maximum lengths up to 256k using open-source LLMs with context lengths of 8k and 32k. ESA outperforms other selective attention methods, especially in tasks requiring the retrieval of multiple pieces of information, achieving comparable performance to full-attention extrapolation methods across various tasks, with superior results in certain tasks.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Cite this paper

@article{wang2025unshackling,
  title  = {Unshackling Context Length: An Efficient Selective Attention Approach through Query-Key Compression},
  author = {Haoyu Wang and Tong Teng and Tianyu Guo and An Xiao and Duyu Tang and Hanting Chen and Yunhe Wang},
  year   = {2025},
  eprint = {2502.14477},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.14477v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.14477.svg)](https://codeofpaper.com/paper/2502.14477)

Discussion