[论文解读] LLM2Vec: Large Language Models Are Secretly Powerful Text Encoders
LLM2Vec 将解码器仅 LLM 转换为强文本编码器,使用三步——双向注意力、屏蔽下一个标记预测、以及无监督对比学习——在 MTEB 上实现无监督的最先进结果,并在公开数据的监督设置中展现出强大性能。
Large decoder-only language models (LLMs) are the state-of-the-art models on most of today's NLP tasks and benchmarks. Yet, the community is only slowly adopting these models for text embedding tasks, which require rich contextualized representations. In this work, we introduce LLM2Vec, a simple unsupervised approach that can transform any decoder-only LLM into a strong text encoder. LLM2Vec consists of three simple steps: 1) enabling bidirectional attention, 2) masked next token prediction, and 3) unsupervised contrastive learning. We demonstrate the effectiveness of LLM2Vec by applying it to 4 popular LLMs ranging from 1.3B to 8B parameters and evaluate the transformed models on English word- and sequence-level tasks. We outperform encoder-only models by a large margin on word-level tasks and reach a new unsupervised state-of-the-art performance on the Massive Text Embeddings Benchmark (MTEB). Moreover, when combining LLM2Vec with supervised contrastive learning, we achieve state-of-the-art performance on MTEB among models that train only on publicly available data (as of May 24, 2024). Our strong empirical results and extensive analysis demonstrate that LLMs can be effectively transformed into universal text encoders in a parameter-efficient manner without the need for expensive adaptation or synthetic GPT-4 generated data.
研究动机与目标
- 在解码器端的因果注意力局限性下,激发使用解码器式 LLM 进行文本嵌入的动机。
- 提出一种简单、数据和参数高效的变换,将解码器-only LLM 转换为通用文本编码器。
- 证明双向注意力加上有针对性的训练能够产生强健的分词级表示。
- 展示在 MTEB 上的无监督性能达到最先进水平,并在公开数据条件下获得具有竞争力的监督结果。
提出的方法
- 在解码器式 LLM 中用双向注意力替换因果注意力(Bi)。
- 通过掩蔽下一个标记预测进行微调,以适应双向上下文(MNTP)。
- 使用基于 dropout 的正样本进行无监督对比学习(SimCSE),以学习序列表示。
- 对 token 表示进行池化以获得与标准评估任务兼容的序列嵌入。
- 在英语维基百科和标准基准数据上进行训练(MNTP 使用 Wikitext-103;SimCSE 使用维基百科子集)。
- 使用 LoRA 进行微调,以保持参数量低并实现高效训练(每阶段 1000 步)。

实验结果
研究问题
- RQ1解码器式 LLM 是否可以在最小改动下被有效改造为通用文本编码器?
- RQ2双向注意力、MNTP 与 SimCSE 分别及组合如何影响词级和序列级嵌入?
- RQ3在标准嵌入基准(如 MTEB)上,经过 LLM2Vec 转换的模型与仅编码器的模型以及现有的无监督方法相比的表现如何?
- RQ4在公开数据条件下,将 LLM2Vec 与有监督对比学习结合是否能获得最先进的结果?
- RQ5LLM2Vec 在低资源或计算受限设置下是否具备参数和数据效率?
主要发现
- LLM2Vec 的变换使解码器式 LLM 在词级任务上超越编码器基线。
- 仅有的双向注意力往往会降低性能;MNTP 提升了结果,将 MNTP 与 SimCSE 结合可获得强大的序列表示。
- 在 MTEB 上,采用 MNTP 和 SimCSE 的 LLM2Vec 实现了新的无监督最先进分数(最佳模型:Mistral-7B 与 LLM2Vec 达到 56.80)。
- 在公开数据上的有监督对比学习下,LLM2Vec 在 MTEB 类别中成为公开训练模型的最先进结果。
- 该方法具有计算和数据效率,每阶段仅需 1000 次训练步骤,硬件需求适中(一个 80GB A100)。
- Mistral-7B 在双向注意力下呈现出有趣的开箱即用行为,提示需要进一步研究的预训练特征。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。