arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2602.01572cs.CLcs.IR
收藏

基于LLM的嵌入:注意力值比隐藏状态更好地编码句子语义

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

State Key Laboratory for Novel Software Technology, Nanjing University, China(新型软件技术国家重点实验室,南京大学,中国);School of Artificial Intelligence, Nanjing University, China(人工智能学院,南京大学,中国)

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

AI总结:

本文提出Value Aggregation方法,利用LLM的注意力值向量而非隐藏状态来生成句子嵌入,在无训练设置下超越现有方法,甚至匹配或超越集成方法MetaEOL。

摘要:

句子表示是许多自然语言处理(NLP)应用的基础。虽然近期方法利用大型语言模型(LLM)来推导句子表示,但大多数依赖于最终层的隐藏状态,这些隐藏状态针对下一个词预测进行了优化,因此通常无法捕捉全局的句子级语义。本文引入了一个新颖的视角,证明注意力值向量比隐藏状态更有效地捕捉句子语义。我们提出了值聚合(VA),一种简单的方法,它跨多个层和词索引池化标记值。在无训练设置中,VA优于其他基于LLM的嵌入,甚至匹配或超越了基于集成的MetaEOL。此外,我们证明,当与合适的提示配对时,层注意力输出可以被解释为对齐的加权值向量。具体来说,最后一个标记的注意力分数充当权重,而输出投影矩阵($W_O$)将这些加权值向量与LLM残差流的公共空间对齐。这种改进的方法,称为对齐加权VA(AlignedWVA),在无训练的基于LLM的嵌入中达到了最先进的性能,大幅超越了高成本的MetaEOL。最后,我们强调了通过微调值聚合来获得强LLM嵌入模型的潜力。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑