Improving Text Embeddings with Large Language Models

Liang Wang, Nan Yang, Xiaolong Huang, Linjun Yang, Rangan Majumder, Furu Wei

Abstract

Traditional text embedding models rely on complex multi-stage pipelines and massive datasets of weakly-supervised web pairs. This paper introduces a simplified yet superior approach by leveraging Large Language Models (LLMs) to generate high-quality synthetic training data. By fine-tuning a Mistral-7B model using a "synthetic-first" strategy and instruction-based training, the researchers achieved state-of-the-art results on the Massive Text Embedding Benchmark (MTEB) with significantly fewer training steps than traditional methods.

1. Introduction

Text embeddings—vector representations of semantic meaning—are fundamental to modern natural language processing tasks, particularly semantic search and Retrieval-Augmented Generation (RAG). Historically, achieving top-tier performance required a grueling process: pre-training on billions of noisy web-scraped pairs followed by fine-tuning on limited human-labeled data. This paradigm suffers from high engineering complexity, data diversity constraints, and a reliance on aging BERT-style architectures.

Researchers from Microsoft have proposed a shift in this methodology, demonstrating that the latent knowledge within modern LLMs can be harnessed to create superior embeddings through synthetic data generation and instruction-based fine-tuning.

2. Methodology

The core of the proposed approach is a "synthetic-first" pipeline that replaces manual data curation with LLM-driven generation.

2.1 Two-Step Synthetic Data Generation

Instead of scraping the web for potentially noisy pairs, the authors utilized proprietary LLMs (such as GPT-4) to build a diverse training set. This was achieved through a two-step prompting strategy:

  1. Brainstorming: The LLM is prompted to identify hundreds of thousands of potential embedding tasks across various domains (e.g., "Retrieve scientific papers supporting a medical diagnosis").
  2. Generation: For each identified task, the LLM generates a triplet consisting of a query, a positive document, and a hard negative document.

This method produced a dataset covering 93 languages and hundreds of thousands of distinct tasks without requiring manual labeling.

2.2 Fine-tuning Decoder-Only LLMs

While traditional embedding models are typically encoder-only (like BERT), this research utilizes a decoder-only model, specifically Mistral-7B. The model is fine-tuned using a standard InfoNCE loss, which optimizes the vector space by pulling queries closer to positive documents and pushing them away from negatives.

A critical component of this fine-tuning is the use of instruction-based embeddings. By prepending a natural language task description to the query (e.g., "Instruct: Retrieve documents that help verify or refute the claim"), the model can dynamically adjust its embedding strategy based on the specific goal of the retrieval task.

3. Evaluation and Results

The researchers evaluated their model, E5-mistral-7b, against the Massive Text Embedding Benchmark (MTEB), which encompasses 56 datasets across classification, clustering, and retrieval tasks. They also utilized the BEIR and MIRACL benchmarks for retrieval and multilingual performance testing.

3.1 State-of-the-Art Performance

E5-mistral-7b achieved an average score of 66.6 on MTEB, surpassing previous leaders such as BGE and commercial offerings from OpenAI and Cohere. Notably, the model achieved this with fewer than 1,000 training steps.

3.2 The Power of Synthetic Data

One of the most significant findings was the efficacy of synthetic data. A version of the model trained only on synthetic data (no human labels) achieved a score of 63.1. This performance is competitive with, or superior to, many established models trained on massive, human-curated datasets.

4. Key Insights

  • LLMs as Latent Experts: The study suggests that LLMs already possess sophisticated internal representations of text due to their auto-regressive pre-training. Fine-tuning serves to "unlock" these representations for embedding tasks rather than teaching them from scratch.
  • Optional Contrastive Pre-training: Unlike BERT-style models, Mistral-7B did not require contrastive pre-training to perform well, as its existing linguistic understanding was already sufficient.
  • Instructional Flexibility: Natural language instructions allow a single model to distinguish between different semantic goals, such as finding a paraphrase versus finding a direct answer.

5. Limitations and Future Directions

Despite its performance, the model faces challenges regarding deployment efficiency. Mistral-7B is significantly larger than standard 110M-parameter BERT models, leading to higher inference latency and computational costs. Furthermore, the 4096-dimensional embeddings require more storage and slower vector search operations than traditional 768-dimensional vectors.

Future research may focus on "Matryoshka representation learning" to reduce dimensionality without sacrificing accuracy, as well as exploring smaller, more efficient LLM backbones to mitigate inference costs.

6. Conclusion

By prioritizing high-quality synthetic data over massive, noisy web-scraped datasets, this research provides a more efficient and effective path to state-of-the-art text embeddings. The success of E5-mistral-7b highlights the potential of decoder-only LLMs to redefine standard practices in semantic representation.

Summary updated

BibTeX
@inproceedings{wang2024improving,
  author = {Liang Wang and Nan Yang and Xiaolong Huang and Linjun Yang and Rangan Majumder and Furu Wei},
  title = {{Improving Text Embeddings with Large Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.642},
}
Figure