Reward function
A reward function maps states, actions, outputs, or sequences of behavior to numerical scores that represent their value or performance.
Applied Reinforcement Learning
A reward function is a mapping that assigns numerical feedback to states, actions, transitions, or outcomes in a decision process.
- How it is used
- Translates business objectives and constraints into feedback for reinforcement learning environments and sequential decisions.
- How deep it goes
- Develops reward components, timing, constraints, scale, and shortcut checks through implemented environments and worked examples.
- Examples
- Uses factory production, warehouse picking, perishable pricing, resource allocation, recommendations, and language-model answer verification.
- What you can do after
- Build reward functions from scratch for modeled decisions and test whether their signals encourage intended behavior.
Read how Applied Reinforcement Learning explains reward function →
Building LLM Applications with DSPy
A reward function is a callable that evaluates a response and returns a score, with higher scores indicating better responses.
- How it is used
- Guides repeated language-model calls by scoring candidate responses for selection or refinement.
- How deep it goes
- Defines the callable and inference-time constraint, then explains how scores govern candidate selection and iterative refinement.
- Examples
- Uses negative answer length and a binary single-word answer score as concrete reward functions.
- What you can do after
- Apply it via DSPy BestOfN or Refine by supplying a callable that scores predictions.
Read how Building LLM Applications with DSPy explains reward function →
LLM Customization and Fine-Tuning
A function that assigns a numerical score to an output, action, or sequence of actions to represent its quality.
- How it is used
- Scores model outputs against verifiable criteria to supply automated rewards during reinforcement fine-tuning.
- How deep it goes
- Defines a callable output-to-score function and traces scoring into policy updates, but limits implementation detail to an invoice example.
- Examples
- Uses invoice-field matching, math answers, code tests, and diagnostic conversations as scoring cases.
- What you can do after
- Build a callable verifier that returns numeric response scores, then use it in a GRPO training setup.
Read how LLM Customization and Fine-Tuning explains reward function →
Also covered in
- Context EngineeringIn early access (MEAP)
What to know first
- ground truthGround truth is reference information treated as correct for assessing the accuracy or correctness of predictions, labels, or other outputs.
- reinforcement learningReinforcement learning is a machine-learning paradigm in which an agent learns behavior or a decision policy through interaction with an environment and evaluative feedback, such as rewards.
- reward signalA reward signal is a value or feedback indicating the desirability, benefit, or cost associated with an action, outcome, or behavior.
- trajectoryA trajectory is an ordered record of states, actions, events, or operations showing how an agent or system progresses through an execution or process.
Related concepts
- Group Relative Policy Optimizationused by · Group Relative Policy Optimization is a reinforcement-learning algorithm that updates a policy using relative rewards or advantages estimated from groups of sampled actions or outputs.
- Refineused by · Refine is a DSPy module that iteratively evaluates responses and uses feedback to improve subsequent outputs.
- ground truthuses · Ground truth is reference information treated as correct for assessing the accuracy or correctness of predictions, labels, or other outputs.
- JSONuses · JSON is a language-independent text-based data-interchange format that represents structured values using objects, arrays, strings, numbers, booleans, and null.
- Markov decision processpart of · A Markov decision process is a mathematical model of sequential decision-making defined by states, actions, probabilistic transitions, and rewards, with future dynamics depending on the current state and action.
Questions about reward function
What is reward function?
A reward function maps states, actions, outputs, or sequences of behavior to numerical scores that represent their value or performance.
Which Manning books explain reward function?
Applied Reinforcement Learning, Building LLM Applications with DSPy and LLM Customization and Fine-Tuning.
What should I know before learning reward function?
Manning books that teach reward function usually introduce ground truth, reinforcement learning, reward signal and trajectory first.
What is reward function part of?
Reward function is part of Markov decision process. A Markov decision process is a mathematical model of sequential decision-making defined by states, actions, probabilistic transitions, and rewards, with future dynamics depending on the current state and action.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


