slicktune.rewards

Verifiable reward helpers for GRPO / RL objectives.

Functions

substring_must_contain_reward(→ list[float])

Score completions against required substrings.

Module Contents

slicktune.rewards.substring_must_contain_reward(completions: list[Any], must_contain: list[str], **kwargs: Any) list[float][source]

Score completions against required substrings.

Full case-insensitive substring match → 1.0. Otherwise return the fraction of content keywords from must_contain that appear in the completion (denser signal for GRPO when the base model rarely emits the exact phrase).

Parameters:
  • completions (list) – Generated completions (strings or chat message lists).

  • must_contain (list[str]) – Required substrings aligned with completions.

  • **kwargs (Any) – Unused TRL extras (prompts, trainer_state, …).

Returns:

list[float] – Per-completion rewards in [0.0, 1.0].