Causal2Vec: Improving Decoder-only LLMs as Embedding Models through a Contextual Token

Ailiang Lin, Zhuoyun Li, Yusong Wang, Kotaro Funakoshi, Manabu Okumura

TL;DR

Causal2Vec is a novel framework that adapts decoder-only Large Language Models (LLMs) into high-performance text embedding models without altering their architecture. By prepending a single, pre-computed "Contextual token" to the input, it allows standard causal attention mechanisms to capture global context efficiently. This approach achieves state-of-the-art results on the MTEB benchmark among models trained on public datasets while maintaining fast inference speeds.

What Problem Does This Paper Address?

Decoder-only LLMs are incredibly powerful, but adapting them to generate text embeddings introduces a fundamental architectural challenge: causal attention. Because these models are trained to predict the next token, a token can only attend to preceding tokens, not future ones. This creates an information bottleneck where early tokens lack full sentence context.

To fix this, common approaches either:

  1. Force bidirectional attention by removing the causal mask during fine-tuning. However, this creates an attention mismatch between pre-training and fine-tuning, often degrading the model's ability to extract its well-learned semantic knowledge.
  2. Repeat the input text or add in-context examples, which forces the model to look back at previous repetitions. While effective, this drastically increases sequence length, leading to high computational costs and slow inference.

Additionally, standard embedding models rely on "last-token pooling" (using the hidden state of the EOS token), making them highly sensitive to noise near the end of the text—a flaw known as recency bias.

Comparison of different embedding methods for decoder-only LLMs

Methods

The authors introduce Causal2Vec, a method that preserves the LLM's original causal attention while injecting global context through a specialized token.

  1. The Contextual Token: The input text is first passed through a lightweight, off-the-shelf bidirectional encoder (like E5-base, which has only 110M parameters). Mean pooling is applied to its output to create a single dense vector.
  2. Dimensionality Alignment: This vector passes through a trainable two-layer Multi-Layer Perceptron (MLP) with GELU activation to match the embedding dimension of the target LLM. This creates the Contextual token.
  3. Sequence Construction: The Contextual token is prepended to the LLM's input sequence, right after the task instruction and before the actual text: [Instruction; Contextual Token; Input Text; EOS]. Because it sits at the front, every subsequent token can attend to it via standard causal attention, instantly gaining access to compressed global context.
  4. Dual-Token Concatenation: To combat recency bias, the final text embedding is formed by concatenating the last hidden states of both the Contextual token and the EOS token.
Overview of the Causal2Vec pipeline

Datasets

  • Training: The model was trained on a curated collection of 1.5 million publicly available retrieval pairs (including datasets like ELI5, HotpotQA, FEVER, MIRACL, MSMARCO, and SQuAD).
  • Evaluation: Performance was measured using the Massive Text Embeddings Benchmark (MTEB) across 56 datasets spanning 7 tasks. For rapid ablation testing, the authors also utilized MTEB-MINI, a representative 30-dataset subset.

Key Insights and Ideas

  • Don't Mess with the Mask: The authors demonstrate that changing causal attention to bidirectional attention during fine-tuning harms performance for most LLMs (such as LLaMA and Qwen) due to pre-train/fine-tune mismatch. Mistral-7B is a rare exception, likely due to its unique pre-training nature.
  • One Token is Enough: Trying to use multiple contextual tokens via cross-attention actually degraded performance by introducing redundancy and noise. A single token provides the optimal balance of compressed information.
  • Robustness to Noise: Concatenating the Contextual token with the EOS token makes the embedding significantly more resilient to trailing noise or irrelevant text compared to standard last-token pooling.

Key Results

Causal2Vec was evaluated across four LLM backbones (ranging from 1.3B to 7B parameters) and achieved top-tier results:

  • State-of-the-Art Performance: Causal2Vec-Mistral-7B achieved an average MTEB score of 66.10, outperforming competitive bidirectional models like MGH and LLM2Vec under identical training setups. When paired with In-Context Learning (ICL), it reached 66.85.
  • High Efficiency: Unlike text-repetition methods, Causal2Vec adds virtually zero length to the sequence. It reduced inference time by up to 82% compared to the state-of-the-art unidirectional model bge-en-icl.
Inference time comparison across different MTEB subsets

Limitations and Future Work

  • Storage Overhead: Concatenating two hidden states doubles the final embedding dimension (e.g., from 4096 to 8192 dimensions for a 7B model), which increases downstream vector database storage requirements.
  • Scale and Language Limits: The framework was only validated on models up to 7B parameters and evaluated primarily on English benchmarks. Future work will explore its scalability to larger LLMs and multilingual tasks.

Summary updated

BibTeX
@inproceedings{lin2026causal,
  author = {Ailiang Lin and Zhuoyun Li and Yusong Wang and Kotaro Funakoshi and Manabu Okumura},
  title = {{Causal2Vec: Improving Decoder-only LLMs as Embedding Models through a Contextual Token}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.acl-long.1042},
}
Figure