reward-kit

raw JSON →
0.4.1 verified Mon Apr 27 auth: no python

A Python library for defining, testing, and using reward functions, particularly for RLHF and AI alignment. Version 0.4.1, pre-1.0, active development with weekly releases.

pip install reward-kit
error ModuleNotFoundError: No module named 'reward_kit'
cause Library not installed or installed in wrong environment.
fix
Run 'pip install reward-kit' in the correct Python environment.
error AttributeError: module 'reward_kit' has no attribute 'evaluate_reward'
cause Import path changed in version 0.4.0.
fix
Use 'from reward_kit import evaluate_reward' instead of 'from reward_kit.utils import evaluate_reward'.
error ValueError: Unknown model: 'morality'
cause Model name 'morality' is deprecated in 0.4.0+ and removed in some versions.
fix
Use 'morality_v2' or import Model enum: reward_kit.Model.MORALITY_V2.
breaking In version 0.4.0, the evaluate_reward function was moved from reward_kit.utils to top-level reward_kit. Old imports will break.
fix Use 'from reward_kit import evaluate_reward' instead of 'from reward_kit.utils import evaluate_reward'
breaking The RewardFunction class constructor 'model' parameter changed from string to enum in 0.4.1. Strings still work but are deprecated.
fix Pass a Model enum value, e.g., reward_kit.Model.MORALITY, or keep string but expect future removal.
deprecated The 'morality' model name is deprecated in favor of 'morality_v2' as of 0.4.0. The v1 model will be removed in 0.5.
fix Use model='morality_v2' or reward_kit.Model.MORALITY_V2.
gotcha By default, reward functions require an internet connection to call remote APIs. Offline mode is not yet supported.
fix Ensure you have internet access or expect ConnectionError.

Initialize a reward function, load a dataset, and evaluate a sample.

from reward_kit import RewardFunction
from reward_kit.data import MoralityQA
import os

# Use your own API key or prompt key
api_key = os.environ.get('REWARD_KIT_API_KEY', 'your-key-here')

reward_fn = RewardFunction(model='morality', api_key=api_key)
dataset = MoralityQA()
score = reward_fn.evaluate(dataset[0])
print(score)