trinity.common.rewards package
Submodules
- trinity.common.rewards.accuracy_reward module
- trinity.common.rewards.agents_reward module
- trinity.common.rewards.base module
- trinity.common.rewards.composite_reward module
- trinity.common.rewards.format_reward module
- trinity.common.rewards.human_reward module
- trinity.common.rewards.reward_fn module
- trinity.common.rewards.tool_reward module
Module contents
Reward functions for RFT
- class trinity.common.rewards.RMGalleryFn(reward_name, **kwargs)[source]
Bases:
RewardFn
Reward Function from RMGallery. https://github.com/modelscope/RM-Gallery
- class trinity.common.rewards.AccuracyReward(answer_parser: Callable[[str], str] | None = None)[source]
Bases:
RewardFn
A reward function that rewards correct answers. Ref: https://github.com/huggingface/open-r1/blob/main/src/open_r1/rewards.py
- class trinity.common.rewards.CountDownRewardFn[source]
Bases:
RewardFn
A reward function that rewards for countdown task. Ref: Jiayi-Pan/TinyZero verl/utils/reward_score/countdown.py
- class trinity.common.rewards.FormatReward(pattern: str | None = None)[source]
Bases:
RewardFn
A reward function that checks if the reasoning process is enclosed within <think> and </think> tags, while the final answer is enclosed within <answer> and </answer> tags. Ref: https://github.com/huggingface/open-r1/blob/main/src/open_r1/rewards.py
- class trinity.common.rewards.MathRewardFn(answer_parser=<function simple_answer_parser>, pattern='.*?<think>.*?</think>\\s*<answer>.*?</answer>\\s*$')[source]
Bases:
RewardFn
A reward function that rewards for math task.
- DEFAULT_FORMAT_PATTERN = '.*?<think>.*?</think>\\s*<answer>.*?</answer>\\s*$'
- DEFAULT_ANSWER_PARSER() str
- class trinity.common.rewards.MathBoxedRewardFn(**kwargs)[source]
Bases:
RewardFn
A reward function that rewards for math task.
- class trinity.common.rewards.MathDAPORewardFn(enable_overlong_penalty: bool | None = None, penalty_factor: float | None = None, max_response_length: int | None = None, cache_length: int | None = None)[source]
Bases:
RewardFn
A reward function that follows the definition in DAPO for math task.