LLMs are Also Effective Embedding Models: An In-depth Overview

Chongyang Tao, Tao Shen, Shen Gao, Junshuo Zhang, Zhen Li, Kai Hua, Wenpeng Hu, Zhengwei Tao, Shuai Ma

For years, the gold standard for text embeddings—the numerical vectors that allow computers to "understand" semantic similarity—was dominated by encoder-only models like BERT. But a new paradigm has arrived. In their survey paper, "LLMs are Also Effective Embedding Models: An In-depth Overview," Chongyang Tao and colleagues explore how the generative giants we use for chat (GPT, LLaMA, Mistral) are being repurposed to become the most powerful retrieval tools in existence.

TL;DR

This paper surveys the shift from traditional BERT-style encoders to decoder-only Large Language Models (LLMs) for representation learning. It details how researchers use clever prompting and massive synthetic datasets to transform generative models into state-of-the-art embedding engines that dominate benchmarks like MTEB.

What Problem Does This Paper Address?

Text embeddings are the backbone of modern AI, powering everything from Google Search to Retrieval-Augmented Generation (RAG). Historically, we used "encoder-only" models (like BERT) because they look at a whole sentence at once. However, these models have a performance ceiling.

LLMs, while much more powerful, are "decoder-only"—they are trained to predict the next token, not to summarize an entire sequence into a single vector. The challenge is: how do we take a model designed to "talk" and turn it into a model designed to "index"? This paper synthesizes the methods used to bridge this gap, from architectural tweaks to data-centric training strategies.

Fig. 1. An overview of our survey on deploying LLMs as embedding models, covering both 1○direct prompting as embedding models, 2○fine-tuning as embedding models and 3○specialized embedding mdels.

Methods

The authors categorize LLM-based embedding methods into two primary camps:

  1. Tuning-Free (Direct Prompting): This approach treats the LLM as a black box. By using specific templates—like "This sentence: '[X]' means in one word:"—researchers can extract the hidden state of the model at a specific token to serve as the embedding.
  2. Tuning-Based (Fine-Tuning): This is the current state-of-the-art. Models are fine-tuned using Contrastive Learning (specifically the InfoNCE loss), which teaches the model to pull "positive" pairs (like a question and its answer) closer together in vector space while pushing "negative" pairs apart.

A key technical evolution highlighted is the move from the bidirectional context of BERT to the causal (one-way) context of GPT-style models, as shown below:

Fig. 3. An illustration of the evolution of text embeddings from ELMo and BERT to GPT-style models, from [188].

Datasets

The paper emphasizes that the "secret sauce" of modern embeddings isn't just the model, but the data.

  • MTEB (Massive Text Embedding Benchmark): The primary yardstick for evaluation, covering tasks like clustering, classification, and retrieval.
  • Synthetic Data: Because high-quality human-labeled pairs are scarce, researchers use "teacher" models (like GPT-4) to generate millions of synthetic query-document pairs to train "student" embedding models.
  • Specialized Benchmarks: The paper notes new benchmarks for specific domains, such as FinMTEB (Finance), ChemTEB (Chemistry), and LONGEMBED (Long-context retrieval).

Key Insights and Ideas

  • Generative Knowledge is a Superpower: The massive scale of LLM pre-training gives these models a "semantic head start." They understand nuances, idioms, and complex logic that smaller BERT models simply miss.
  • Bidirectional Attention is Optional (But Helpful): While LLMs are naturally unidirectional, some models (like LLM2Vec) "unlock" bidirectional attention during fine-tuning to help the model see the whole sentence at once, often leading to better representations.
  • The Scaling Law Applies: Just as LLMs get smarter at talking as they get bigger, they also get better at embedding. However, the paper notes diminishing returns as models move from 4B to 8B parameters.
  • Matryoshka Embeddings: A clever technique where models are trained so that the most important information is stored in the first few dimensions of the vector. This allows users to truncate a 4096-dimensional vector down to 256 dimensions for speed without losing much accuracy.

Key Results

The results are clear: LLMs have taken over the leaderboards. On the MTEB benchmark, traditional models like BERT or Contriever score in the 38–56 range. In contrast, LLM-based models like NV-Embed and Qwen-embedding are pushing scores above 75.

Even smaller LLM-based models (around 1.5B parameters), when distilled from larger teachers (like the Gecko model), can outperform 7B-parameter models that were trained from scratch.

Limitations and Future Work

Despite their power, LLM embeddings face several "open problems":

  • The Efficiency Wall: LLM embeddings are huge (often 4096 dimensions). Storing and searching these vectors is computationally expensive compared to BERT’s 768 dimensions.
  • Reasoning Gaps: While they are better than BERT, LLMs still struggle with "Reasoning-Intensive Retrieval"—tasks that require multi-step logic to determine if a document is relevant.
  • Data Bias: LLMs inherit the biases of their training data. If the pre-training data is biased, the resulting embeddings will cluster concepts in potentially unfair or harmful ways.
  • Long Context Coherence: Maintaining a "global" understanding of a 30-page document in a single vector remains a significant architectural challenge.

Summary updated

BibTeX
@misc{tao2024llms,
  author = {Chongyang Tao and Tao Shen and Shen Gao and Junshuo Zhang and Zhen Li and Kai Hua and Wenpeng Hu and Zhengwei Tao and Shuai Ma},
  title = {{LLMs are Also Effective Embedding Models: An In-depth Overview}},
  year = {2024},
  eprint = {2412.12591},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.12591},
}
Figure