TLDR: GRACE (Generative Representation Learning via Contrastive Policy Optimization) is a novel framework that reimagines contrastive signals as rewards to guide an LLM’s generative policy. Instead of static embeddings, GRACE trains LLMs to produce explicit, human-interpretable rationales for their semantic understanding, which are then encoded into high-quality embeddings. This approach significantly improves text embedding performance on the MTEB benchmark (11.5% supervised, 6.9% unsupervised gains) while preserving the LLM’s general capabilities and offering transparent, inspectable reasoning.
Large Language Models (LLMs) have transformed Natural Language Processing, excelling in understanding, reasoning, and generation. A crucial application is their use as universal text encoders, providing high-quality semantic representations (text embeddings) for tasks like semantic retrieval and text clustering. However, current methods often treat LLMs as ‘black boxes,’ forcing them to produce static embeddings and suppressing their inherent generative and reasoning capabilities. This leads to a lack of interpretability, making it difficult to understand why an LLM deems two texts similar.
Introducing GRACE: A New Paradigm for LLM Embeddings
A novel framework called GRACE (Generative Representation Learning via Contrastive Policy Optimization) redefines how LLMs learn text representations. Instead of viewing contrastive signals as losses to be minimized, GRACE treats them as rewards that guide a generative policy. This innovative approach transforms the LLM from an opaque encoder into an interpretable agent, making its reasoning process transparent and inspectable.
In GRACE, the LLM acts as a policy that generates explicit, human-interpretable ‘rationales.’ These rationales are structured natural language explanations of the model’s semantic understanding. For example, when comparing two documents, the LLM might generate a rationale explaining the key concepts and relationships it identified. These rationales are then encoded into high-quality embeddings using a technique called mean pooling.
How GRACE Works
The core of GRACE lies in its policy gradient optimization, which uses a multi-component reward function. This function is designed to maximize the similarity between query-positive pairs (texts that should be similar) and minimize similarity with negative pairs (texts that should be dissimilar). This reinforcement learning framework allows the LLM to learn by generating better rationales that lead to more accurate similarity judgments.
The reward function in GRACE has several synergistic components:
- Contrastive Learning Reward: Encourages semantic alignment between queries and relevant documents while penalizing irrelevant ones.
- Consistency Reward: Ensures semantic coherence across multiple interpretations (rationales) of the same document.
- Hard Negative Mining: Identifies challenging negative samples (positives from other instances that are spuriously similar) to further refine the model’s discrimination abilities.
This comprehensive reward system guides the LLM to generate faithful rationales while simultaneously learning effective text representations.
Performance and Interpretability
GRACE has demonstrated significant improvements on the Massive Text Embedding Benchmark (MTEB), a standardized framework covering 7 task categories and 56 datasets. Averaged over four different LLM backbones, the supervised version of GRACE improves the overall MTEB score by 11.5% compared to base models. The unsupervised variant also shows strong gains, adding 6.9% to the overall score.
Crucially, GRACE achieves these performance boosts while preserving the general capabilities of the LLMs. Unlike traditional contrastive learning methods that can sometimes degrade an LLM’s ability to perform general tasks (like mathematics, knowledge reasoning, or code generation), GRACE maintains these competencies. This stability is attributed to how the contrastive signal is integrated: as a reward within an RL framework, aligning updates with the generative policy and resisting representation collapse.
One of the most compelling aspects of GRACE is its enhanced interpretability. By generating explicit rationales, the model’s reasoning process becomes transparent. Users can inspect these textual outputs to understand why the model made a particular similarity judgment, a significant advancement over opaque embedding models.
Also Read:
- Enhancing Multimodal Embeddings with Generative Reasoning
- Targeted Expert Guidance Enhances LLM Reasoning and Exploration
Availability
The models, data, and code for GRACE are publicly available, fostering reproducibility and future research in this domain. You can find more details about this research in the full paper. Read the full research paper here.
In conclusion, GRACE represents a substantial step forward in text representation learning, unifying generative capabilities with contrastive objectives to produce stronger, more transparent, and interpretable text embeddings without sacrificing the broad utility of Large Language Models.


