When Text Embedding Meets Large Language Model: A Comprehensive Survey

Zhijie Nie, Zhangchi Feng, Mingxin Li, Cunwang Zhang, Yanzhao Zhang, Dingkun Long, Richong Zhang

TL;DR

This comprehensive survey maps out the rapidly evolving landscape where text embedding meets Large Language Models (LLMs). It organizes recent advancements into a clean taxonomy: using LLMs to augment training data, adapting LLMs directly as high-quality text embedders, and leveraging LLMs to interpret or compress embedding spaces. The paper provides a vital framework for understanding how dense retrieval and generative AI are merging to solve classic NLP challenges while introducing new frontiers like long-context compression and privacy security.

What Problem Does This Paper Address?

Text embeddings—dense vector representations of text—are the unsung heroes of practical NLP, powering everything from semantic search and clustering to the retrieval stage of Retrieval-Augmented Generation (RAG). While generative LLMs excel at open-ended understanding, many production applications still rely on traditional text embeddings for their extreme computational efficiency.

However, traditional embedding models (like BERT variants) lack the deep semantic nuances of modern LLMs. Conversely, native decoder-only LLMs are notoriously bad at producing embeddings out of the box because their causal attention mechanisms cause "anisotropy"—a phenomenon where embeddings cluster into a narrow cone, making distinct concepts look deceptively similar. This survey addresses the fragmented state of recent research attempting to bridge this gap, unifying diverse methodologies into a structured overview.

Methods

The authors categorize the interplay between LLMs and text embeddings into three overarching interaction patterns:

  1. LLM-Augmented Text Embedding: LLMs act as advanced data engines. Instead of using the LLM as the final embedder, it is used to synthesize highly diverse training instructions, positive pairs, or hard negative samples to train smaller, highly efficient encoder models.
  2. LLMs as Text Embedders: Researchers modify the backbone of an LLM (such as Mistral or LLaMA) to output embeddings directly. This involves discarding the final token-generation layer and implementing specialized pooling strategies (e.g., prompt-based last pooling like "The sentence [X] means in a word:") or altering the attention mask from causal (unidirectional) to bidirectional during fine-tuning.
  3. Text Embedding Understanding with LLMs: LLMs are used to interface with existing embedding spaces for emerging tasks. This includes Long Context Compression (ICC), which packs massive prompt contexts into a few dense vectors to save LLM compute tokens, and Embedding Inversion, an adversarial technique where an LLM attempts to reconstruct the exact original text from an embedding to probe privacy risks.
An overview of the five relationships between text embedders and LLMs.

Datasets

The survey compiles a massive list of standard datasets across five major categories:

  • Information Retrieval (IR): MS MARCO, BEIR, NFCorpus, SciFact, and multilingual sets like MIRACL and Mr.TyDi.
  • Question Answering (QA): Natural Questions, SQuAD, TriviaQA, and HotpotQA.
  • Natural Language Inference (NLI): SNLI and MNLI (frequently used to bootstrap semantic similarity).
  • Classification & Multi-task: AmazonCounter, Emotion, and MEDI.
  • Evaluation Benchmarks: The MTEB (Massive Text Embedding Benchmark) serves as the gold standard for universal embedding evaluation, alongside its multilingual counterpart, MMTEB.

Key Insights and Ideas

  • The Bidirectional Attention Fix: Decoder-only LLMs inherently struggle with text representation because tokens can only "see" preceding tokens. Converting these models to use bidirectional attention during incremental fine-tuning dramatically improves embedding quality without destroying the model's underlying semantic knowledge.
  • Model Merging over Multi-Tasking: Different embedding tasks often conflict (e.g., optimization for Information Retrieval can degrade performance on Semantic Textual Similarity). Instead of complex multi-task training setups, researchers are successfully using post-hoc model merging techniques (like Spherical Linear Interpolation or SLERP) to blend task-specific embedding checkpoints.
  • The Compression-Inversion Duality: The paper highlights a fascinating tension between long-context compression and embedding inversion. While compression researchers strive to pack text into vectors losslessly for LLMs to read, inversion research warns that if an LLM can easily decode those vectors back into text, it poses a severe privacy risk for commercial vector databases.

Key Results

  • Mistral Dominance: Among open-source decoder-only backbones, Mistral (7B) has emerged as the most popular choice for text embedders due to its unique resilience and high performance when adapted to bidirectional attention.
  • The Power of Synthetic Data: Models like Google's Gecko demonstrate that leveraging LLMs for two-stage synthetic data generation allows smaller models (around 1B parameters) to achieve state-of-the-art results on competitive benchmarks like MTEB.
  • Matryoshka Embeddings: Commercial architectures (like OpenAI's latest embedding APIs) successfully implement Matryoshka Representation Learning (MRL), allowing systems to truncate a high-dimensional embedding vector to much smaller sizes to save storage without catastrophic drops in accuracy.

Limitations and Future Work

The authors identify several critical roadblocks for the next generation of embedding models:

  • The Curse of Low-Resource Languages: Multilingual embedders perform exceptionally well in dominant languages but fail in low-resource domains because Unicode tokenizers and LLM pre-training corpuses remain heavily biased.
  • Complex Instruction Following: While modern embedders can follow simple instructions (e.g., "Retrieve documents relevant to this query"), they fail when given complex, multi-step, or chronological constraints.
  • Compute Overhead: Moving from traditional 110-million-parameter BERT encoders to 7-billion-parameter LLM embedders dramatically escalates the computational cost of indexing large vector databases, making model compression and sparsification urgent priorities.

Summary updated

BibTeX
@misc{nie2024when,
  author = {Zhijie Nie and Zhangchi Feng and Mingxin Li and Cunwang Zhang and Yanzhao Zhang and Dingkun Long and Richong Zhang},
  title = {{When Text Embedding Meets Large Language Model: A Comprehensive Survey}},
  year = {2024},
  eprint = {2412.09165},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.09165},
}
Figure