Skip to content

Toxicity reward

Bases: _RubricPreset

LM judges toxic language; use as a guardrail term, not as the main objective.

Example:

program.compile(
    reward=synalinks.rewards.Toxicity(
        language_model=language_model,
    ),
    optimizer=synalinks.optimizers.RandomFewShot(),
)
Source code in synalinks/src/rewards/rubric_rewards.py
@synalinks_export(["synalinks.Toxicity", "synalinks.rewards.Toxicity"])
class Toxicity(_RubricPreset):
    """LM judges toxic language; use as a guardrail term, not as the main objective.

    Example:

    ```python
    program.compile(
        reward=synalinks.rewards.Toxicity(
            language_model=language_model,
        ),
        optimizer=synalinks.optimizers.RandomFewShot(),
    )
    ```
    """

    preset = "toxicity"