TL;DR
SCSP (Semantic Compression-guided Selective Pooling) is a training-free framework that improves long-context text embeddings by identifying and aggregating only the most informative tokens. By leveraging an LLM's internal attention patterns elicited by compression prompts, it prevents salient information from being diluted by redundant content, consistently outperforming standard mean-pooling methods across various models and benchmarks.
What Problem Does This Paper Address?
In the world of Large Language Models (LLMs), turning long documents into compact "embeddings" (vector representations) is a major challenge. Most current methods use mean pooling, which simply averages the representations of every single token in a document.
While this works for short snippets, it fails for long-context documents. In a 10,000-word text, the "signal" (the core meaning) is often buried under a mountain of "noise" (redundant words, filler, and weakly informative sentences). Mean pooling treats every token as equally important, effectively diluting the most salient information. The authors ask a simple but profound question: Can we identify and selectively aggregate only the informative tokens without needing to retrain the model?
Methods
The authors introduce SCSP, a plug-and-play framework that uses the LLM's own internal logic to decide what matters. The process follows four main steps, illustrated in the overview below:
- Sentence-Aware Prompted Input Construction: The document is partitioned into chunks at sentence boundaries. To each chunk, a short "semantic compression prompt" (e.g.,
Brief summary: ") is appended. This prompt encourages the LLM to focus its internal attention on the most important parts of that chunk. - Prompt-Isolated Attention Mask: A custom attention mask is used to ensure the inserted prompts don't interfere with the document's original representations. Document tokens can see each other normally (causal attention), but the prompts are restricted to "reading" only their specific chunk.
- Semantic Compression-Guided Token Selection: The model performs a single forward pass. The authors then look at the attention weights of the final token in each summary prompt. Tokens that receive high attention are deemed "informative." A token is selected if its importance score exceeds a threshold ($\alpha$) relative to uniform attention.
- Intermediate-Layer Selective Pooling: Instead of using the final layer (which is optimized for next-token prediction), SCSP extracts representations from an intermediate layer (typically the 6th or 7th from the end). The selected tokens are then averaged to create the final embedding.
Datasets
The researchers evaluated SCSP on five real-world long-context datasets from the LongBench and LongEmbed benchmarks:
- QMSum: Meeting summarization.
- 2WikiMQA: Multi-hop question answering.
- SumFD: Document summarization.
- NarrativeQA: Reading comprehension.
- MultiFieldQA: Diverse long-context QA.
- LOCOV1: A benchmark for long-context retrieval and understanding.
Key Insights and Ideas
- LLMs are "Self-Aware" Summarizers: The core "aha" moment is that LLMs already know which tokens are important for a summary. By simply asking the model to summarize a chunk (via a prompt) and looking at where it "looks" (attention), we can extract a high-quality importance signal for free.
- Less is More: The authors found that you only need a small fraction of tokens to build a better embedding. For example, using HTP as a baseline, SCSP achieved better results by retaining only 8.64% of the tokens.
- Max-Pooling the Attention: When calculating token importance, taking the maximum attention weight across all layers and heads works better than averaging them. This suggests that if even one "expert" head in the model finds a token critical, it probably is.
- Positional Gaps Help: Interestingly, keeping the "positional gaps" created by the inserted prompts (rather than re-indexing tokens to be contiguous) helped the model better distinguish between different semantic chunks.
Key Results
SCSP consistently improved performance across different backbones (Mistral-7B, Llama-3.1-8B, Gemma2-9B, Qwen2.5-7B) and context lengths (512 to 16,384 tokens).
- Massive Gains on Llama-3.1: On an 8,192-token context, combining SCSP with the "Echo Mean" baseline improved average nDCG@10 scores by 60% (from 26.41 to 42.34).
- Zero-Shot Superiority: Even without fine-tuning, "Vanilla Mean + SCSP" often outperformed more complex training-free methods like HTP.
- Fine-Tuned Enhancement: SCSP isn't just for raw LLMs; it also improved state-of-the-art fine-tuned embedding models like GritLM (+11.33 points) and NV-EMBED (+3.06 points).
Limitations and Future Work
- Computational Overhead: While training-free, SCSP does require a single forward pass with extra prompt tokens. While the authors describe this as "marginal," it is still an increase over standard mean pooling.
- Hyperparameter Sensitivity: The method relies on a threshold parameter ($\alpha$) and the choice of chunk size. As shown in the ablation studies, the optimal values for these can vary depending on the baseline model used.
- Future Directions: The authors suggest exploring more sophisticated ways to aggregate the selected tokens beyond simple mean pooling, although their initial experiments with importance-weighted aggregation didn't yield further gains.
Summary updated