Contrastive Prompting Enhances Sentence Embeddings in LLMs through Inference-Time Steering
Zifeng Cheng, Zhonghui Wang, Yuchen Fu, Zhiwei Jiang, Yafeng Yin, Cong Wang, Qing Gu

TL;DR
This paper introduces Contrastive Prompting, a simple inference-time technique that improves sentence embeddings from large language models by focusing on core semantics through contrastive auxiliary prompts.
Contribution
It proposes a novel contrastive prompting method that enhances sentence embeddings without additional training, applicable across various prompt-based approaches and models.
Findings
Improves performance on Semantic Textual Similarity tasks
Enhances downstream classification accuracy
Works as a plug-and-play inference-time intervention
Abstract
Extracting sentence embeddings from large language models (LLMs) is a practical direction, as it requires neither additional data nor fine-tuning. Previous studies usually focus on prompt engineering to guide LLMs to encode the core semantic information of the sentence into the embedding of the last token. However, the last token in these methods still encodes an excess of non-essential information, such as stop words, limiting its encoding capacity. To this end, we propose a Contrastive Prompting (CP) method that introduces an extra auxiliary prompt to elicit better sentence embedding. By contrasting with the auxiliary prompt, CP can steer existing prompts to encode the core semantics of the sentence, rather than non-essential information. CP is a plug-and-play inference-time intervention method that can be combined with various prompt-based methods. Extensive experiments on Semantic…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
Taxonomy
TopicsTopic Modeling · Advanced Graph Neural Networks · Text Readability and Simplification
MethodsFocus
