[Paper Review] LLM2Vec: Large Language Models Are Secretly Powerful Text Encoders
LLM2Vec converts decoder-only LLMs into strong text encoders using three steps—bidirectional attention, masked next token prediction, and unsupervised contrastive learning—achieving state-of-the-art unsupervised results on MTEB and strong perf with public data in supervised settings.
Large decoder-only language models (LLMs) are the state-of-the-art models on most of today's NLP tasks and benchmarks. Yet, the community is only slowly adopting these models for text embedding tasks, which require rich contextualized representations. In this work, we introduce LLM2Vec, a simple unsupervised approach that can transform any decoder-only LLM into a strong text encoder. LLM2Vec consists of three simple steps: 1) enabling bidirectional attention, 2) masked next token prediction, and 3) unsupervised contrastive learning. We demonstrate the effectiveness of LLM2Vec by applying it to 4 popular LLMs ranging from 1.3B to 8B parameters and evaluate the transformed models on English word- and sequence-level tasks. We outperform encoder-only models by a large margin on word-level tasks and reach a new unsupervised state-of-the-art performance on the Massive Text Embeddings Benchmark (MTEB). Moreover, when combining LLM2Vec with supervised contrastive learning, we achieve state-of-the-art performance on MTEB among models that train only on publicly available data (as of May 24, 2024). Our strong empirical results and extensive analysis demonstrate that LLMs can be effectively transformed into universal text encoders in a parameter-efficient manner without the need for expensive adaptation or synthetic GPT-4 generated data.
Motivation & Objective
- Motivate the use of decoder-only LLMs for text embeddings despite their causal attention limitations.
- Propose a simple, data- and parameter-efficient transformation to turn decoder-only LLMs into universal text encoders.
- Show that bidirectional attention plus targeted training yields strong token-level representations.
- Demonstrate state-of-the-art unsupervised performance on MTEB and competitive supervised results with publicly available data.
Proposed method
- Replace causal attention with bidirectional attention in decoder-only LLMs ( Bi ).
- Fine-tune with masked next token prediction to adapt to bidirectional context ( MNTP ).
- Apply unsupervised contrastive learning (SimCSE) using dropout-based positives to learn sequence representations.
- Pool token representations to obtain sequence embeddings compatible with standard evaluation tasks.
- Train on data from English Wikipedia and standard benchmarks (Wikitext-103 for MNTP; subset of Wikipedia for SimCSE).
- Fine-tune with LoRA to keep parameters low and enable efficient training (1000 steps per stage).

Experimental results
Research questions
- RQ1Can decoder-only LLMs be repurposed effectively as universal text encoders with minimal adaptation?
- RQ2How do bidirectional attention, MNTP, and SimCSE individually and collectively affect word- and sequence-level embeddings?
- RQ3What is the performance of LLM2Vec-transformed models on standard embedding benchmarks (like MTEB) compared to encoder-only models and existing unsupervised methods?
- RQ4Does combining LLM2Vec with supervised contrastive learning yield state-of-the-art results under public-data constraints?
- RQ5Is LLM2Vec parameter- and data-efficient for low-resource or compute-constrained settings?
Key findings
- LLM2Vec-transformations enable decoder-only LLMs to outperform encoder-only baselines on word-level tasks.
- Bidirectional attention alone often hurts performance; MNTP improves results, and combining MNTP with SimCSE yields strong sequence representations.
- On MTEB, LLM2Vec with MNTP and SimCSE achieves a new unsupervised state-of-the-art score (best model: Mistral-7B with LLM2Vec reaching 56.80).
- With supervised contrastive learning on public data, LLM2Vec achieves state-of-the-art results among publicly trained models across MTEB categories.
- The approach is compute- and data-efficient, requiring only 1000 training steps per stage and modest hardware (one 80GB A100).
- Mistral-7B shows intriguing out-of-the-box behavior with bidirectional attention, suggesting pre-training characteristics that warrant further study.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.