Embedding-based In-Context Prompt Training for Enhancing LLMs as Text Encoders

Ailiang Lin, Zhuoyun Li, Keyu Mao, Kotaro Funakoshi, Manabu Okumura
5/2/2026
cs.CL

No confident code implementation found for this paper.

Abstract

Large language models (LLMs) have been widely explored for embedding generation. While recent studies show that in-context learning (ICL) effectively enhances the representational capability of LLMs by prepending a few task-related demonstrations, it causes substantial token overhead due to the increased sequence length.

Show full abstract

In this work, we propose EPIC, a novel embedding-based in-context prompt training strategy that leverages ICL to generate high-quality embeddings while reducing computational burden during both training and inference. This approach replaces discrete text demonstrations with their corresponding continuous embeddings, which not only encourages the LLM to align semantically-related text pairs during contrastive learning, but also requires the model to interpret demonstration embeddings as part of the in-context prompt. Consequently, EPIC-trained models achieve excellent embedding performance both with or without in-context prompts at inference time. Comprehensive experiments demonstrate that our method establishes new state-of-the-art results on the MTEB benchmark, surpassing frontier models trained solely on publicly available retrieval data. Extensive ablation studies further validate the effectiveness and necessity of our mechanism.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{lin2026embeddingbased,
  title  = {Embedding-based In-Context Prompt Training for Enhancing LLMs as Text Encoders},
  author = {Ailiang Lin and Zhuoyun Li and Keyu Mao and Kotaro Funakoshi and Manabu Okumura},
  year   = {2026},
  eprint = {2605.01372},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2605.01372v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2605.01372.svg)](https://codeofpaper.com/paper/2605.01372)

Discussion