Length-Induced Embedding Collapse in Transformer-based Models

Yuqi Zhou, Sunhao Dai, Zhanshuo Cao, Xiao Zhang, Jun Xu · DOI

Abstract

Transformer-based Pre-trained Language Models (PLMs) exhibit a systematic performance degradation as input text length increases. This paper identifies "Length Collapse" as a primary cause, where embeddings of longer texts cluster together, losing distinctiveness. By modeling self-attention as a low-pass filter, the authors demonstrate that increasing sequence length intensifies this filtering effect. To mitigate this, they propose TempScale, a temperature-scaling mechanism that preserves high-frequency information. Empirical results on MTEB and LongEmbed benchmarks show consistent improvements, establishing TempScale as a simple, zero-shot solution for long-text embedding tasks.

Introduction

Modern text embedding models, crucial for Retrieval-Augmented Generation (RAG) and search, often struggle with long documents. For example, models like BGE show significant accuracy drops (up to 16.6% on IMDB classification) when processing 500-token texts compared to short snippets. This research argues that this is not merely a context window limitation but a structural issue termed Length Collapse. As text length grows, embeddings converge toward the center of the vector space, increasing cosine similarity between unrelated documents and creating a distributional gap between short queries and long documents.

Theoretical Framework: Attention as a Low-Pass Filter

The authors bridge Transformer architecture with signal processing by treating self-attention as a low-pass filter. Token features are viewed as signals, where "high-frequency" components represent unique, local details and "low-frequency" components represent global averages.

  1. Mathematical Proof of Collapse: The paper proves that as sequence length ($n$) increases, the low-pass filtering effect of the attention mechanism intensifies. Specifically, the variance of token features collapses because the model increasingly retains only the "Direct Component" (the average signal).
  2. TempScale Solution: To counteract this, the authors introduce Temperature Scaling (TempScale). By dividing attention scores by a temperature $\tau < 1$ before the softmax operation, the attention map is "sharpened." This reduces the filtering rate for long texts, allowing them to retain the high-frequency features necessary for maintaining distinctiveness in the embedding space.

Analysis of Embedding Distribution

The phenomenon of Length Collapse leads to a "Center vs. Periphery" problem. Long-text embeddings cluster at the center (the DC component), while short-text embeddings remain at the periphery. This explains retrieval failures: a short query at the periphery may be closer to a "noisy" short document than to the relevant long document buried in the central cluster.

Conceptual illustration of Length Collapse across different tasks.

Experimental Results

The authors validated TempScale across major benchmarks, including MTEB and LongEmbed. Key findings include:

  • Performance Gains: TempScale achieved average improvements of 0.94% on MTEB and 1.10% on LongEmbed. The E5 model (4k window) saw a notable boost of 1.72%.
  • Retrieval Accuracy: On the NFCorpus dataset, TempScale improved the ranking of long documents by reducing the inherent length bias in the original embedding space.
  • Visual Confirmation: t-SNE plots and cosine similarity analyses confirm that while original long-text embeddings are tightly packed, TempScale-adjusted embeddings spread out, mimicking the distribution of successful short-text embeddings.
Empirical evidence of Length Collapse and the corrective effect of TempScale.

Conclusion and Future Work

TempScale provides a zero-shot, structural fix for the length-induced collapse in PLM-based embedding models. While highly effective for bidirectional models, future research is needed to adapt this approach for unidirectional (causal) LLM-based models. Additionally, exploring dynamic temperature scaling based on input length and investigating the roles of LayerNorm and Feed-Forward Networks in embedding collapse remain promising directions.

Summary updated

BibTeX
@inproceedings{zhou2025length,
  author = {Yuqi Zhou and Sunhao Dai and Zhanshuo Cao and Xiao Zhang and Jun Xu},
  title = {{Length-Induced Embedding Collapse in Transformer-based Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure