ACL 2025long0 citations

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

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) technique 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 Textual Similarity (STS) tasks and downstream classification tasks demonstrate that our method can improve the performance of existing prompt-based methods across different LLMs.

BibTeX
@inproceedings{cheng-etal-2025-contrastive,
    title = "Contrastive Prompting Enhances Sentence Embeddings in {LLM}s through Inference-Time Steering",
    author = "Cheng, Zifeng  and
      Wang, Zhonghui  and
      Fu, Yuchen  and
      Jiang, Zhiwei  and
      Yin, Yafeng  and
      Wang, Cong  and
      Gu, Qing",
    editor = "Che, Wanxiang  and
      Nabende, Joyce  and
      Shutova, Ekaterina  and
      Pilehvar, Mohammad Taher",
    booktitle = "Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
    month = jul,
    year = "2025",
    address = "Vienna, Austria",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2025.acl-long.174/",
    doi = "10.18653/v1/2025.acl-long.174",
    pages = "3475--3487",
    ISBN = "979-8-89176-251-0"
}
Contrastive Prompting Enhances Sentence Embeddings in LLMs through Inference-Time Steering · ACL 2025