Gecko: Versatile Text Embeddings Distilled from Large Language Models

Jinhyuk Lee, Zhuyun Dai, Xiaoqi Ren, Blair Chen, Daniel Cer, Jeremy R. Cole, Kai Hui, Michael Boratko, Rajvi Kapadia, Wen Ding, Yi Luan, Sai Meher Karthik Duddu, Gustavo Hernández Ábrego, Weiqiang Shi, Nithi Gupta, Aditya Kusupati, Prateek Jain, Siddhartha Reddy Jonnalagadda, Ming-Wei Chang, Iftekhar NaimarXiv 2024 · DOI

TL;DR

This paper introduces Gecko, a compact and versatile text embedding model that achieves state-of-the-art performance by distilling knowledge from large language models (LLMs). By using LLMs to generate and refine training data, Gecko significantly outperforms existing models, even those with much larger parameter counts and higher dimensionality.

What Problem Does This Paper Address?

Creating effective text embedding models that can generalize across a wide range of downstream tasks (like search, similarity, and classification) is challenging. Traditional methods often require massive, manually curated datasets, which are expensive to create and can introduce biases. While large language models (LLMs) possess vast knowledge, directly applying them for embedding tasks is computationally prohibitive. This paper addresses the need for a compact, versatile, and high-performing text embedding model that can leverage the knowledge embedded within LLMs without their associated computational cost.

Methods

Gecko employs a two-step knowledge distillation process:

  1. LLM-Generated Data (FRet Dataset): The core innovation is the creation of a synthetic dataset called FRet. This process starts with a large corpus of web passages. An LLM is then used in a few-shot manner to:
  2. Generate diverse task descriptions (e.g., "find a passage that answers the query").
  3. Generate a relevant query for each passage based on the task.
  4. Crucially, instead of just using the original passage as the positive example, the LLM is used to retrieve and re-rank candidate passages, identifying a more relevant positive passage and a hard negative passage. This LLM-based relabeling is key to improving data quality.
  5. Two-Stage Training:
    • Pre-finetuning: The model is first pre-finetuned on a large corpus of unsupervised text pairs (like question-answer pairs and title-body pairs) using a contrastive learning objective. This exposes the model to broad textual diversity.
  6. Fine-tuning: The pre-finetuned model is then fine-tuned on a mixture of datasets, including the newly created FRet dataset and several academic datasets. This stage uses a contrastive loss that incorporates "same-tower negatives" (other queries in the batch) to improve performance on symmetric tasks. The authors also incorporate a Matryoshka Representation Learning (MRL) loss to support multiple embedding dimensions.

Datasets

  • Training Datasets:
    • FRet (Few-shot Prompted Retrieval): A novel, LLM-generated synthetic dataset comprising task descriptions, queries, positive passages, and hard negative passages.
  • Community QA dataset (Ni et al., 2021)
    • Web crawl corpus (title-body pairs)
    • Academic datasets: Natural Questions, HotpotQA, FEVER, MedMCQA, SNLI, MNLI, and various classification datasets from Huggingface.
  • MIRACL (for the multilingual version).
  • Evaluation Benchmark: Massive Text Embedding Benchmark (MTEB), which covers a wide range of tasks including classification, clustering, pair classification, reranking, retrieval, STS, and summarization.

Key Insights and Ideas

  • LLMs as Data Curators: The most significant insight is that LLMs can be effectively leveraged not just for generating synthetic data, but for curating high-quality training data by relabeling positive and negative examples. This goes beyond simple data augmentation.
  • Re-ranking is Crucial: The original passage associated with a generated query is not always the best positive example. LLMs can identify more relevant passages, which significantly improves training data quality.
  • Diversity is Key: The FRet dataset's diversity, stemming from varied web content and explicitly generated diverse task descriptions, is crucial for building a versatile model that generalizes well.
  • Compactness with Performance: Gecko demonstrates that high performance doesn't necessarily require massive models or extremely high-dimensional embeddings. Distillation from LLMs can achieve competitive results with much smaller models.
  • Unified Format Benefits: Standardizing diverse datasets into a unified format (task description, query, positive, negative) is important for effective training, especially for asymmetric tasks.

Key Results

  • MTEB Performance: Gecko-1B-256 (256-dimensional embeddings) outperforms all existing entries with 768-dimensional embeddings on the MTEB benchmark.
  • Gecko-1B-768: Achieves an average score of 66.31 on MTEB, competing with models that are 7x larger and have 5x higher dimensional embeddings.
  • Zero-Shot Performance: A Gecko model trained solely on the FRet dataset (without any MTEB in-domain training data) shows strong zero-shot performance.
  • Multilingual Transfer: A multilingual version of Gecko, trained with English-only FRet data, achieves superior performance on multilingual retrieval tasks.
  • LLM Reranker Effectiveness: Ensembling LLM rerankers (Query Likelihood and Relevance Classification) using Reciprocal Rank Fusion (RRF) significantly improves retrieval quality and robustness across tasks.

Limitations and Future Work

  • LLM Dependence: The quality of Gecko is inherently tied to the capabilities of the LLMs used for data generation and relabeling.
  • Computational Cost of LLM: While Gecko itself is compact, the initial data generation phase still relies on powerful LLMs, which can be computationally intensive.
  • Future Work: The authors suggest exploring more sophisticated LLM-based relabeling strategies and further investigating the impact of data diversity and formatting on model performance. They also highlight the potential for Gecko to serve as a strong baseline for future research in versatile text embeddings.

Summary updated

BibTeX
@misc{lee2024gecko,
  author = {Jinhyuk Lee and Zhuyun Dai and Xiaoqi Ren and Blair Chen and Daniel Cer and Jeremy R. Cole and Kai Hui and Michael Boratko and Rajvi Kapadia and Wen Ding and Yi Luan and Sai Meher Karthik Duddu and Gustavo Hernández Ábrego and Weiqiang Shi and Nithi Gupta and Aditya Kusupati and Prateek Jain and Siddhartha Reddy Jonnalagadda and Ming-Wei Chang and Iftekhar Naim},
  title = {{Gecko: Versatile Text Embeddings Distilled from Large Language Models}},
  year = {2024},
  eprint = {2403.20327},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.20327},
}
Figure