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

📄 arXiv: 2602.01572 📥 PDF

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

分类: cs.CL, cs.IR

发布日期: 2026-06-12


💡 一句话要点

提出基于注意力值的句子表示方法以提升语义捕捉能力

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 句子表示 注意力机制 大型语言模型 值聚合 自然语言处理 无训练方法 语义捕捉

📋 核心要点

  1. 现有方法主要依赖最终层的隐藏状态,难以有效捕捉句子级的全局语义。
  2. 本文提出值聚合(VA)方法,通过跨层和标记索引汇聚注意力值,提升句子表示的语义捕捉能力。
  3. 在无训练的设置下,VA方法超越了其他LLM嵌入,并在性能上显著优于高成本的MetaEOL。

📝 摘要(中文)

句子表示是许多自然语言处理应用的基础。尽管近期方法利用大型语言模型(LLMs)来获取句子表示,但大多数依赖于最终层的隐藏状态,这些状态优化用于下一个标记预测,因此常常无法捕捉全局的句子级语义。本文提出了一种新视角,证明注意力值向量比隐藏状态更有效地捕捉句子语义。我们提出了值聚合(Value Aggregation, VA)方法,该方法在无训练的情况下,通过跨多个层和标记索引汇聚标记值,超越了其他基于LLM的嵌入,甚至与基于集成的MetaEOL相匹配或超越。此外,我们展示了当与合适的提示配对时,层注意力输出可以被解释为对齐的加权值向量。最终,我们强调通过微调值聚合获得强大的LLM嵌入模型的潜力。

🔬 方法详解

问题定义:本文要解决的问题是现有基于LLM的句子表示方法依赖于最终层的隐藏状态,导致无法有效捕捉句子级的全局语义。

核心思路:论文的核心思路是利用注意力值向量来捕捉句子语义,提出值聚合(VA)方法,通过汇聚多层和多标记的注意力值来提升表示效果。

技术框架:整体架构包括多个层的注意力机制,通过对每个标记的注意力值进行聚合,形成全局句子表示。VA方法在无训练的情况下直接应用,简化了传统方法的复杂性。

关键创新:最重要的技术创新点在于提出了注意力值比隐藏状态更有效地捕捉句子语义的观点,并通过VA方法实现了这一点,与现有方法相比,提供了新的思路。

关键设计:在设计上,VA方法通过对不同层的注意力值进行加权聚合,利用最后一个标记的注意力分数作为权重,并通过输出投影矩阵($W_O$)将加权值向量对齐到LLM残差流的公共空间。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

在实验中,VA方法在无训练的设置下表现优异,超越了其他基于LLM的嵌入,且在性能上显著优于高成本的MetaEOL,展示了其在句子表示任务中的强大能力。

🎯 应用场景

该研究的潜在应用领域包括文本分类、情感分析和机器翻译等自然语言处理任务。通过提升句子表示的语义捕捉能力,能够显著提高这些任务的性能,具有重要的实际价值和未来影响。

📄 摘要(原文)

Sentence representations are foundational to many Natural Language Processing (NLP) applications. While recent methods leverage Large Language Models (LLMs) to derive sentence representations, most rely on final-layer hidden states, which are optimized for next-token prediction and thus often fail to capture global, sentence-level semantics. This paper introduces a novel perspective, demonstrating that attention value vectors capture sentence semantics more effectively than hidden states. We propose Value Aggregation (VA), a simple method that pools token values across multiple layers and token indices. In a training-free setting, VA outperforms other LLM-based embeddings, even matches or surpasses the ensemble-based MetaEOL. Furthermore, we demonstrate that when paired with suitable prompts, the layer attention outputs can be interpreted as aligned weighted value vectors. Specifically, the attention scores of the last token function as the weights, while the output projection matrix ($W_O$) aligns these weighted value vectors with the common space of the LLM residual stream. This refined method, termed Aligned Weighted VA (AlignedWVA), achieves state-of-the-art performance among training-free LLM-based embeddings, outperforming the high-cost MetaEOL by a substantial margin. Finally, we highlight the potential of obtaining strong LLM embedding models through fine-tuning Value Aggregation.