liveBook · Manning

Policy

As explained in Reinforcement Learning from Human Feedback

A policy is a function that maps an environment state to a probability distribution over actions.

A policy determines how an agent acts in an environment. It maps a state s to a probability distribution over actions: π(a | s) is the probability of choosing action a in state s. In deep reinforcement learning, a neural network can learn this mapping. section 3.1

The policy chooses actions; the environment determines how the state changes afterward. Together with the initial state distribution, policy choices and transitions define a distribution over trajectories. Training seeks a policy with high expected cumulative reward, optionally discounting rewards further in the future. section 3.1

Equation 3.1
\[\label{eq:rl_dynam} {p_{\pi}(\tau)=\rho_0(s_0)\prod_{t=0}^{T-1}\pi(a_t\mid s_t)p(s_{t+1}\mid s_t,a_t).}\]

The trajectory probability combines the initial state probability, policy action probabilities, and environment transition probabilities. section 3.1

Thermostat policy

For a room with a 70°F target, the state is the current temperature and the actions are heater on or off. One policy turns the heater on below 70°F and off otherwise. A reward of +1 is given within 2°F of the target and 0 otherwise. This policy is sensible but not necessarily optimal: the result also depends on how quickly the room heats and cools. section 3.1.1

Policy-gradient methods directly optimize a parameterized policy πθ. A basic update combines the direction that increases the probability of a sampled action with a scalar score for its outcome. A positive score favors making that action more likely; a negative score favors making it less likely. section 6.1 section 6.2

Equation 6.1
\[\label{eq:policy_gradient_intuition} \Delta \theta \propto \Psi_t \nabla_\theta \log \pi_\theta(a_t \mid s_t).\]

The update multiplies the action’s log-probability gradient by an outcome score Ψt. section 6.2

In language-model RLHF, the policy is the model being trained. The general state–action notation can also be expressed as prompt and completion; some implementations treat the entire completion as one action. PPO, GRPO, and REINFORCE are policy-gradient algorithms used in this setting. section 6.1 section 6.2

Data collection matters because a policy changes during training. In reinforcement learning, on-policy data for a gradient update comes from the most recent policy. For preference data, the term is often used more loosely for data generated by the current family of models, whose outputs are closely related to those being optimized. section 11.2

How Reinforcement Learning from Human Feedback covers it

How deep it goes
Defines policies and trajectory objectives, then interprets parameterized policy-gradient updates and their action-probability effects.
Examples
Illustrates learned action rules with a thermostat and CartPole, and maps language-model prompts and completions to states and actions.
What you can do after
Evaluate/understand how policy choices shape trajectories and how gradient updates change action probabilities.
How it connects
Connects policies to environment dynamics, discounted return, policy gradients, value functions, and on-policy data.

Also explained in

Compare how 13 books explain policy →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Reinforcement Learning from Human Feedback. The section links point to the parts of the book it draws on.