Following the Autoregressive Nature of LLM Embeddings via Compression and Alignment

Jingcheng Deng, Zhongtao Jiang, Liang Pang, Zihao Wei, Liwei Chen, Kun Xu, Yang Song, Huawei Shen, Xueqi Cheng

Abstract

A new trend uses LLMs as dense text encoders via contrastive learning. However, since LLM embeddings predict the probability distribution of the next token, they are inherently generative and distributive, conflicting with contrastive learning, which requires embeddings to capture full-text semantics and align via cosine similarity. This discrepancy hinders the full utilization of LLMs’ pre-training capabilities, resulting in inefficient learning. In response to this issue, we propose AutoRegEmbed, a new contrastive learning method built on embedding conditional probability distributions, which integrates two core tasks: information compression and conditional distribution alignment. The information compression task encodes text into the embedding space, ensuring that the embedding vectors capture global semantics. The conditional distribution alignment task focuses on aligning text embeddings with positive samples embeddings by leveraging the conditional distribution of embeddings while simultaneously reducing the likelihood of generating negative samples from text embeddings, thereby achieving embedding alignment and uniformity. Experimental results demonstrate that our method significantly outperforms traditional contrastive learning approaches and achieves performance comparable to state-of-the-art models when using the same amount of data.

Introduction

Large Language Models (LLMs) have demonstrated exceptional capabilities in text generation, yet their application as dense text encoders for embeddings has faced significant efficiency hurdles. Traditionally, text embeddings are extracted from the hidden states of an LLM and fine-tuned using contrastive learning to maximize cosine similarity between semantically related pairs.

However, this approach faces a fundamental architectural mismatch. First, LLMs are pre-trained for next-token prediction (local semantics), whereas embeddings must represent the entire sequence (global semantics). Second, contrastive learning relies on geometric distance, while LLMs are natively designed to produce probability distributions. Forcing LLMs to ignore their distributive nature often necessitates massive datasets—millions of labeled pairs—and extensive compute resources to achieve state-of-the-art (SOTA) performance.

Methodology: AutoRegEmbed

To bridge this gap, we introduce AutoRegEmbed, a framework that aligns the embedding process with the autoregressive nature of LLMs. The method consists of two primary components: Information Compression and Conditional Distribution Alignment.

The AutoRegEmbed architecture consists of two stages: Information Compression to capture global semantics and Conditional Distribution Alignment to refine embedding relationships.

1. Information Compression

To transition from local to global semantic capture, AutoRegEmbed utilizes "compressed tokens." By appending a small set of new tokens to the input text, an encoder processes the sequence. A frozen decoder is then tasked with reconstructing the original input using only the embeddings of these compressed tokens. This creates an information bottleneck, compelling the embeddings to represent the full sentence's meaning to satisfy the reconstruction objective.

2. Conditional Distribution Alignment (CDA)

Rather than relying on standard geometric similarity, AutoRegEmbed aligns the conditional probability distributions of the embeddings. The core logic is that if Sentence A is semantically similar to Sentence B, the probability of the LLM generating Sentence B given the embedding of Sentence A should be high. By redefining the similarity metric using log-probability ratios—a concept similar to Direct Preference Optimization (DPO)—the model learns to prefer positive samples over negative ones based on the likelihood of generation.

Experimental Evaluation

The model was trained on the PWC-Unique dataset (16k samples) for compression and a combination of MEDI (50k samples) and BGE (274k samples) for alignment. Evaluation spanned standard benchmarks including Semantic Textual Similarity (STS) and retrieval tasks (MS MARCO, NFCorpus).

Key Results and Efficiency

AutoRegEmbed demonstrates a superior trade-off between performance and data volume. It achieves results comparable to SOTA models like NV-Embed using up to 100x less training data.

Performance vs. Training Data Size: AutoRegEmbed establishes a new Pareto front, achieving SOTA-level performance with significantly fewer samples than traditional contrastive learning methods.

On the 10 STS benchmarks, AutoRegEmbed-Mistral achieved an average score of 85.82, surpassing other prominent models like LLM2Vec (84.01) and gte-Qwen2-7B (83.06). In retrieval tasks, it scored 42.49 (nDCG@10) on MS MARCO, ranking second only to models utilizing much larger, closed-source datasets.

Discussion and Future Work

The success of AutoRegEmbed suggests that distributional similarity is a more potent signal for LLM-based encoders than geometric similarity. By treating embeddings as prompts for reconstruction, the model naturally learns to summarize global meaning.

However, limitations remain. The high efficiency in data compression may inadvertently propagate biases present in training data, as the framework currently lacks an inherent safety filtering mechanism. Additionally, while training leverages distribution alignment, inference still utilizes inner product matching for compatibility with vector databases. Future research could explore more sophisticated inference strategies and further optimize the loss landscape by investigating the relationship between the framework's temperature parameters.

Conclusion

AutoRegEmbed represents a shift in how LLMs are adapted for embedding tasks. By embracing the generative and distributive strengths of these models rather than suppressing them, we can achieve higher performance with a fraction of the data and compute required by traditional methods.

Summary updated

BibTeX
@inproceedings{deng2025following,
  author = {Jingcheng Deng and Zhongtao Jiang and Liang Pang and Zihao Wei and Liwei Chen and Kun Xu and Yang Song and Huawei Shen and Xueqi Cheng},
  title = {{Following the Autoregressive Nature of LLM Embeddings via Compression and Alignment}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
  url = {https://openreview.net/forum?id=M7bg3zs6QF},
}
Figure