LLM-based Embeddings: Attention Values Encode Sentence Semantics Better Than Hidden States

Yeqin Zhang, Yunfei Wang, Chen Jiaxuan, Ke Qin, Yizheng Zhao, Cam-Tu Nguyen

Sentence embeddings—vector representations of text—are the foundational backbone of modern AI applications, including Retrieval-Augmented Generation (RAG), semantic search, and clustering. Currently, the standard practice is to extract these embeddings from the final-layer hidden states of Large Language Models (LLMs).

However, this paper identifies a fundamental misalignment in this approach: autoregressive LLMs are trained on a "next-token prediction" objective. This forces the hidden states to become "myopic," focusing intensely on local features necessary to guess the immediate next word, often at the expense of the sentence's broader, global meaning. For example, two semantically distinct sentences that happen to end with the same phrase might yield nearly identical hidden states. To resolve this, the authors introduce a novel perspective: extracting embeddings from the attention mechanism's Value (V) vectors rather than the hidden states.

The Core Innovation: Value Aggregation Methods

The authors propose shifting the extraction target from the layer's output (the hidden state) to the content being routed within the attention mechanism (the value vectors). They introduce three progressive strategies to capture sentence semantics:

  1. Value Aggregation (VA): A simple, training-free approach that mean-pools value vectors across multiple tokens and layers. Instead of looking at the predictive output, VA captures the semantic content being moved around inside the model.
  2. Weighted VA (WVA): This method refines VA by using the attention scores of the final token as weights. This allows the model to dynamically prioritize and "decide" which parts of the sentence are most contextually important.
  3. Aligned Weighted VA (AlignedWVA): To align these value vectors with the model's internal residual stream, the weighted values are multiplied by the output projection matrix ($W_O$). When paired with specific summarizing prompts (e.g., asking the model what a sentence "means in one word"), AlignedWVA forces the LLM to condense the entire sentence's semantic meaning into the value space.

Key Insights: The Mechanics of Semantic Representation

  • Hidden State Myopia: The authors provide formal proof using the InfoNCE loss framework to demonstrate that hidden states are mathematically pulled toward the embedding of the next token. Value vectors, being one step removed from the final predictive output, retain a purer, less predictive semantic representation.
  • The "Truth-Conditional" Perspective: Drawing from philosophy, the authors argue a sentence's meaning is defined by its "continuation space"—the conditions under which it remains true. Experiments on the LongBench v2 dataset reveal that value vectors are significantly better than hidden states at predicting text continuations 100+ tokens later.
  • The "Sweet Spot" Layers: Semantic information is not distributed uniformly across an LLM. The most robust embeddings emerge from the 50% to 85% depth range of the model. The final layers become too specialized for next-token prediction, which actively degrades embedding quality.

Empirical Results

The methods were rigorously evaluated on a subset of the Massive Text Embedding Benchmark (MTEB), covering 14 tasks across clustering, retrieval, semantic textual similarity (STS), classification, and reranking.

  • State-of-the-Art Performance: VA consistently outperformed standard hidden-state pooling. Furthermore, AlignedWVA achieved the highest scores among all training-free LLM embeddings. On a Qwen-3 (8B) backbone, AlignedWVA beat the high-cost MetaEOL ensemble by over 4 points on average.
  • Computational Efficiency: Previous state-of-the-art training-free methods like MetaEOL required running a sentence through eight different prompts and averaging the results. AlignedWVA achieves superior performance in just a single forward pass, making it roughly 7x to 8x faster.
  • Dimensionality Advantage: In models utilizing Grouped-Query Attention (GQA), such as Qwen-3, value vectors have a lower dimensionality than hidden states (e.g., 1024 vs. 4096). Despite having only a quarter of the dimensions, VA still outperformed larger hidden-state embeddings.
  • Fine-Tuning Efficiency: While primarily a training-free study, the authors demonstrated that fine-tuning the VA process (Finetune-VA) matches the performance of fine-tuned hidden states while requiring 75% fewer trainable parameters.

Limitations and Future Directions

While Value Aggregation excels in retrieval and semantic similarity, performance gains in classification tasks were more modest. This suggests that category-level discrimination may still benefit from traditional hidden-state features. Additionally, selecting the optimal layers for aggregation currently requires empirical testing per model family, though the 50–85% depth rule serves as a highly reliable baseline.

The authors suggest that future research should explore designing new training objectives specifically tailored for the value space, rather than retrofitting contrastive learning techniques originally designed for hidden states.

Conclusion

By shifting focus from hidden states to attention value vectors, this research offers a highly efficient, training-free method for generating state-of-the-art sentence embeddings. AlignedWVA not only provides a more accurate representation of global semantics but also significantly reduces computational overhead, paving the way for faster, cheaper, and more effective NLP applications.

Summary updated

BibTeX
@inproceedings{zhang2026llm,
  author = {Yeqin Zhang and Yunfei Wang and Chen Jiaxuan and Ke Qin and Yizheng Zhao and Cam-Tu Nguyen},
  title = {{LLM-based Embeddings: Attention Values Encode Sentence Semantics Better Than Hidden States}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=nAfV9H2Z1u},
}
Figure