Getting started
Getting Started with Reward Functions
This guide will help you understand the basics of creating, testing, and deploying reward functions using the Reward Kit.
What is a Reward Function?
A reward function is a mechanism for evaluating the quality of model outputs in reinforcement learning from machine feedback (RLMF) workflows. Reward functions help:
- Evaluate model responses based on specific criteria
- Provide numerical scores that can be used to optimize models
- Offer explanations for why specific scores were assigned
Getting started on www.fireworks.ai
You will start your journey on our evaluators page
Click on “Create Evaluator” on the upper right corner; you will be taken to the rewards page we have been working on.
You can check out how to define an evaluator in our tutorials or in our examples for out of the box evaluators. But before we decide on authoring any evaluators, let’s actually pick a dataset creating_your_first_reward_function. Let’s take a look at eval-result-job17-epoch1.
It is a tool calling dataset, with messages and tools field. Let’s update the evaluator to run this. We will say that if the message is longer than 3 rows, then we have engaged user for long enough and call it a success (score is 1), otherwise it is a failure (score is 0).
Installation
To get started with Reward Kit, install it via pip:
For development, you may want to install it in editable mode:
Authentication Setup
To use Reward Kit with the Fireworks AI platform, set up your authentication credentials:
For development environments, you might use:
Basic Reward Function Structure
Here’s a simple reward function that evaluates responses based on word count:
Testing Your Reward Function
You can test your reward function with sample conversations:
Previewing Your Reward Function
Before deployment, you can preview how your reward function performs on a set of sample data:
Or programmatically:
Deploying Your Reward Function
When you’re ready, deploy your reward function to use in training workflows:
Or using the CLI:
Next Steps
Now that you understand the basics of reward functions:
- Learn about Reward Function Anatomy for deeper insights
- Explore Core Data Types to understand the components
- Try creating advanced reward functions with multiple metrics
- Follow our step-by-step tutorial for a complete walkthrough