McGill's LLM2Vec-Gen Turns AI Responses Into Safer, Smarter Embeddings
McGill-NLP's LLM2Vec-Gen trains frozen language models to embed the answer they would generate, not the query itself, hitting self-supervised MTEB SOTA.
ProTakeaways
- LLM2Vec-Gen trains frozen LLMs to embed their potential response, not the input query, via a new self-supervised paradigm
- Only 10 trainable special tokens plus two MLPs are updated; the LLM stays frozen (about 13M params for Qwen-3-4B)
- Hits new self-supervised MTEB SOTA at 61.9 with Qwen-3-8B, closing most of the gap to supervised methods
- Cuts harmful content retrieval by up to 22.6% and boosts reasoning-intensive retrieval on BRIGHT by up to 35.6%
- Embeddings are decodable back to natural language, enabling direct inspection of what the model stored
- Code, data, and checkpoints released at github.com/McGill-NLP/llm2vec-gen
Text embeddings have followed the same recipe for years: run text through an encoder, average the token representations, and call it a day. A team from McGill, Mila, ServiceNow Research and Cohere just published a paper arguing this input-centric view is throwing away most of what makes modern language models valuable. Their method, LLM2Vec-Gen, flips the paradigm: instead of encoding what a query says, it encodes what the LLM would respond, and the resulting embeddings inherit the model's safety alignment and reasoning ability for free.
Why input-centric embeddings leave value on the table
The dominant approach for turning an LLM into an embedder is contrastive learning on curated query-document pairs. The method fine-tunes the model to project queries and documents into a new shared space, but that space no longer coincides with the model's own response representations, discarding the rich semantic structure the LLM acquired during pretraining. That matters for two reasons the authors highlight repeatedly. First, retrieval tasks often need diverse inputs to map to similar outputs (many questions, one answer), which contrastive objectives address by restructuring the space around relevance labels. Second, capabilities that live in the model's outputs, like refusing harmful requests or chain-of-thought reasoning, simply do not exist in the input representation.
The paper's proposal is to encode the LLM's potential response to a query rather than the query itself. Given a harmful query, input-centric encoders represent the malicious intent, whereas this approach encodes the model's safe refusal, and reasoning capabilities that emerge in responses transfer naturally to the embedding space.
The trick: trainable compression tokens on a frozen LLM
The mechanics are surprisingly lightweight. The authors add a handful of new special tokens to the model's vocabulary (they use 10), append them to the input query, and train only those tokens plus two small MLP projection heads. Everything else stays frozen. For every query, the LLM generates its own response, an off-the-shelf teacher embedding model encodes that response, then two losses are computed: one comparing the special tokens' final representations to the teacher's response embedding, and one where the LLM is conditioned on the special tokens and reconstructs the response via cross-entropy.

The two objectives play different roles:
- Embedding alignment: pushes the compression tokens' pooled representation toward the teacher's embedding of the generated response, using mean squared error. This is what makes the embeddings good.
- Reconstruction: forces the compression tokens to be usable as a soft prompt from which the frozen LLM can regenerate the response via next-token prediction. This is what makes the embeddings readable in natural language.
The teacher choice matters. The team uses unsupervised LLM2Vec models as embedding teachers, arguing that an unsupervised teacher applies only light uniformity regularization and preserves the LLM's representational geometry, so the alignment target faithfully represents the response content. Using a supervised teacher hurts because its space is warped by relevance labels rather than being faithful to content.
Training cost is almost trivial
Training uses 160K single-turn questions from the Tulu instruction-following dataset, but ground-truth responses are not used, only the model's own generations. They train for one epoch with batch size 32, and an 8B model takes about 3.5 hours on 2 H100 GPUs. Because the LLM stays frozen, only around 13M parameters are updated for Qwen-3-4B. That is orders of magnitude below LoRA fine-tuning and, critically, means the same weights can serve both generation and embedding without swapping adapters.
At inference, the process collapses to a single forward pass: append the special tokens, extract their hidden states, run them through the two MLPs, and you have your embedding. No autoregressive generation, unlike prior output-centric approaches such as HyDE.
The numbers
The team applied LLM2Vec-Gen to Qwen-3 (0.6B through 8B), Qwen-2.5, and Llama-3.x models. On MTEB (English v2, 41 tasks), LLM2Vec-Gen with Qwen-3-8B establishes a new self-supervised state-of-the-art on MTEB with a score of 61.9, and the largest gains appear in clustering (+22.7%), classification (+7.0%), and semantic textual similarity (+9.8%), precisely the categories where diverse inputs must map to similar outputs. That closes most of the gap to the fully supervised LLM2Vec baseline at 65.7.
The safety and reasoning results are where the paradigm shift really shows up. On AdvBench-IR, which measures how often a retriever surfaces harmful documents for malicious queries, LLM2Vec-Gen consistently retrieves less unsafe content. On the reasoning-intensive BRIGHT benchmark, gains scale with model size:
| Model | AdvBench-IR (lower is safer) | BRIGHT (higher is better) |
|---|---|---|
| Qwen-3-0.6B LLM2Vec / LLM2Vec-Gen | 31.5 → 25.2 (-20.1%) | 10.8 → 11.6 (+7.7%) |
| Qwen-3-1.7B | 46.7 → 36.2 (-22.6%) | 14.0 → 15.6 (+11.7%) |
| Qwen-3-4B | 50.8 → 42.5 (-16.3%) | 15.7 → 18.8 (+19.7%) |
| Qwen-3-8B | 54.2 → 45.0 (-17.0%) | 14.9 → 20.2 (+35.6%) |
This scaling behavior confirms that as the underlying LLM's reasoning capabilities grow, LLM2Vec-Gen effectively transfers them into the embedding space. A better base model produces a better embedder, without any embedding-specific fine-tuning of the base model itself.
Embeddings you can actually read
Because the reconstruction loss trains the compression tokens to be decodable, you can feed a stored embedding back into the LLM and get natural language out. Applying Logit Lens to the compression tokens shows what the model "thinks" a query is about. For a fraud tutorial request, the top tokens include "security" and "illegal" rather than fraud-related terms, evidence that the embedding really is encoding the refusal, not the query. For a question about polar bears, tokens like "Arctic," "ice," and "snow" surface, meaning the embedding stores answer content, not just the words in the question.
This has real operational implications. Debugging a retrieval pipeline usually means guessing why a query and document ended up close in vector space. Here you can just decode the query embedding and read what the model believed the answer would look like.
Where it falls short
The paper is honest about limits:
- Standard retrieval regression: for Qwen-3-4B, MTEB retrieval drops marginally versus the teacher. Output-centric embeddings can miss the surface-level lexical matching that some retrieval benchmarks reward.
- Teacher-bound quality: the student's ceiling is the unsupervised teacher's representational capacity. If the teacher poorly encodes a domain, the student inherits that.
- Supervised data does not help much: swapping in a supervised teacher improves scores only modestly and does not clearly beat the supervised baseline unless LoRA is added, because relevance-optimized encoders distort the space away from faithful content representation.
Code and models
All code, training data, and pretrained models across the Qwen-2.5, Qwen-3, and Llama-3 families are available in the McGill-NLP/llm2vec-gen repository. The Hugging Face paper page links to the trained checkpoints, which drop into standard embedding pipelines with a single forward pass at inference. For teams already running Qwen-3 or Llama-3 for generation, this is a way to get an embedder out of the same weights without maintaining a second model, and to inherit whatever safety and reasoning behavior the base model already has.