GRACE: Generative Representation Learning via Contrastive Policy Optimization

Jiashuo Sun, Shixuan Liu, Zhaochen Su, Xianrui Zhong, Pengcheng Jiang +4 more
10/6/2025
cs.CLcs.AIcs.IR

Official code: GasolSun36/GRACE (39 stars, last commit 2026-02-03).

Abstract

Prevailing methods for training Large Language Models (LLMs) as text encoders rely on contrastive losses that treat the model as a black box function, discarding its generative and reasoning capabilities in favor of static embeddings. We introduce GRACE (Generative Representation Learning via Contrastive Policy Optimization), a novel framework that reimagines contrastive signals not as losses to be minimized, but as rewards that guide a generative policy. In GRACE, the LLM acts as a policy that produces explicit, human-interpretable rationales--structured natural language explanations of its semantic understanding. These rationales are then encoded into high-quality embeddings via mean pooling. Using policy gradient optimization, we train the model with a multi-component reward function that maximizes similarity between query positive pairs and minimizes similarity with negatives. This transforms the LLM from an opaque encoder into an interpretable agent whose reasoning process is transparent and inspectable. On MTEB benchmark, GRACE yields broad cross category gains: averaged over four backbones, the supervised setting improves overall score by 11.5% over base models, and the unsupervised variant adds 6.9%, while preserving general capabilities. This work treats contrastive objectives as rewards over rationales, unifying representation learning with generation to produce stronger embeddings and transparent rationales. The model, data and code are available at https://github.com/GasolSun36/GRACE.

View on arXivView PDF

Code Implementations(1)

GasolSun36/GRACEOfficial100%

Official repo for paper: "GRACE: Generative Representation Learning via Contrastive Policy Optimization"

392Shell, PythonOct 2, 20258 months ago

Cite this paper

@article{sun2025grace,
  title  = {GRACE: Generative Representation Learning via Contrastive Policy Optimization},
  author = {Jiashuo Sun and Shixuan Liu and Zhaochen Su and Xianrui Zhong and Pengcheng Jiang and Bowen Jin and Peiran Li and Weijia Shi and Jiawei Han},
  year   = {2025},
  eprint = {2510.04506},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2510.04506v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2510.04506.svg)](https://codeofpaper.com/paper/2510.04506)

Discussion