论文名称:Simple Techniques for Enhancing Sentence Embeddings in Generative Language Models

论文地址:https://arxiv.org/pdf/2404.03921

论文代码:https://https://github.com/ZBWpro/PretCoTandKE


过去大家使用Sentence Embedding模型大多都是使用m3e, bge这种encoder端模型。

在生成式大模型火热的当下,如何借助LLM来得到sentence embedding也成为一个火热的话题。

1 origin LLM sentence embedding

最简单的LLM获取sentence embedding的方法是构建如下prompt,使sentence的语义汇聚到一个词上,使用该次的embedding为sentence embedding:

  • please make this sentence [X] to one word.

然后使用word该词的最后一层的embedding作为整句话的embedding。

2 论文做法

论文在初始的LLM sentence embedding的基础上加入了两种增强手段:

  • 伪装思维链 – pretended-COT
  • 知识增强

2.1 伪装思维链

将prompt升级为携带思维链的prompt,其核心思想是在提示中加入“After thinking step by step,”(逐步思考后)这样的前置语句。这样做的目的并不是真的要求模型输出中间推理步骤,而是希望通过这种方式激发模型更加细致地处理句子表示。

  • Think step by step, and please make this sentence [X] to one word.

2.2 知识增强

这种方法通过在提示中加入关于文本摘要的人类经验,以文本形式直接指导模型如何提炼句子的主要信息。具体来说,它强调句子的主语和动作承载了更大的语义权重,而描述性词汇虽然重要但属于附加信息。

  • The essence of a sentence is often captured by its main subjects and actions, while descriptive terms provide additional but less central details. With this in mind , this sentence : “[X]” means in one word:“