mlsanityData to 14 Oct 2026

CoCA: Fusing Position Embedding with Collinear Constrained Attention in Transformers for Long Context Window Extending

arXiv 2309.08646 ↗First posted 15 Sep 2023cs.LG cs.AI cs.CLcited by 6

Not on the map. Why?

Abstract (arXiv)

Self-attention and position embedding are two key modules in transformer-based Large Language Models (LLMs). However, the potential relationship between them is far from well studied, especially for long context window extending. In fact, anomalous behaviors harming long context extrapolation exist between Rotary Position Embedding (RoPE) and vanilla self-attention unveiled by our work. To address this issue, we propose a novel attention mechanism, CoCA (Collinear Constrained Attention). Specifically, we enforce a collinear constraint between Q and K to seamlessly integrate RoPE and self-attention. While only adding minimal computational and spatial complexity, this integration significantly enhances long context window extrapolation ability. We provide an optimized implementation, making it a drop-in replacement for any existing transformer-based models. Extensive experiments show that CoCA performs extraordinarily well in extending context windows. A CoCA-based GPT model, trained with a context length of 512, can seamlessly extend the context window up to 32K (60×), without any fine-tuning. Additionally, by dropping CoCA in LLaMA-7B, we achieve extrapolation up to 32K within only 2K training length. Our code is publicly available at: https://github.com/codefuse-ai/Collinear-Constrained-Attention

Key facts. Cited by 6 papers in the map (data through 14 Oct 2026). Builds on 14 of its 31 references that are in the map. First posted on arXiv 15 Sep 2023.

Builds on

14 of 31 references.

References · 14

  1. 2017Attention Is All You Needcited by 60,361
  2. 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
  3. 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,673
  4. 2020Longformer: The Long-Document Transformercited by 3,413
  5. 2020The Pile: An 800GB Dataset of Diverse Text for Language Modelingcited by 2,411
  6. 2018SentencePiece: A simple and language independent subword tokenizer and detokenizer for Neural Text Processingcited by 1,989
  7. 2017Decoupled Weight Decay Regularizationcited by 1,831
  8. 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,103
  9. 2023Extending Context Window of Large Language Models via Positional Interpolationcited by 740
  10. 2019Compressive Transformers for Long-Range Sequence Modellingcited by 726
  11. 2022GPT-NeoX-20B: An Open-Source Autoregressive Language Modelcited by 713
  12. 2023Landmark Attention: Random-Access Infinite Context Length for Transformerscited by 213
2 more
  1. 2023LongNet: Scaling Transformers to 1,000,000,000 Tokenscited by 204
  2. 2022KERPLE: Kernelized Relative Positional Embedding for Length Extrapolationcited by 86

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2024: 1; 2025: 3; 2026: 2.

6 papers.