Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:OpenRLHF OpenRLHF Reward Shaping

From Leeroopedia
Revision as of 18:25, 16 February 2026 by Admin (talk | contribs) (Auto-imported from principles/OpenRLHF_OpenRLHF_Reward_Shaping.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Reinforcement_Learning
Last Updated 2026-02-07 00:00 GMT

Overview

A technique that combines environment reward with KL divergence penalty to create per-token reward signals for policy optimization.

Description

Reward Shaping transforms a sparse scalar reward (given at end of sequence) into a dense per-token reward signal by combining it with a KL divergence penalty at each token. The KL penalty discourages the policy from diverging too far from the reference model, while the environment reward (from a reward model or rule-based function) provides the task-specific signal.

Usage

Used in PPO and Math-GRPO workflows during experience generation. The shaped reward is used for advantage estimation and policy gradient computation.

Theoretical Basis

The shaped reward at each token position: rt=βKLt+{Rif t=Teos0otherwise

where:

  • β (kl_coef) controls the KL penalty strength
  • KLt is the per-token KL divergence estimate
  • R is the scalar reward placed at the EOS position
  • Teos is the last non-padding token position

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment