SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2411.01111 · NeurIPS · 2024

Rule Based Rewards for Language Model Safety

Alex Beutel, Joshua Achiam, Tong Mu, Alec Helyar, Johannes Heidecke, Andrea Vallone, Ian Kivlichan, Molly Lin, John Lilian, Weng Openai

arXiv · PDF · Open in the Atlas

Code that ran

2 of 2 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 0 failures of our instrument; 0 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2411.01111.json · badge: /api/ran/2411.01111.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
openai/safety-rbr-code-and-data canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
FunctionStatusWhere it lives
RBRWeightFitter Ran
ran on a synthesized input
openai/safety-rbr-code-and-data/rbr_weight_fitter.py
code served (permissive licence) · get_code("9847541ecd7ea081")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from dataclasses import dataclass, field
from itertools import combinations
from typing import Optional, Dict, List

@dataclass
class RBR_ExampleWithMetadata:
    convo_prompt: str
    convo_completion: str
    response_type: str
    completion_label: str
    base_reward: Optional[float] = None
    features: Optional[Dict[str, float]] = field(default_factory=dict)

    def add_base_reward(self, base_reward: float):
        self.base_reward = base_reward

    def add_features(self, features: Dict[str, float]):
        self.features.update(features)

# INIT_ARGS for RBRWeightFitter
INIT_ARGS = {
    'feature_names': ['feature1', 'feature2', 'feature3', 'feature4'],
    'examples': [
        RBR_ExampleWithMetadata(
            convo_prompt="prompt1",
            convo_completion="completion1",
            response_type="type_a",
            completion_label="good",
            base_reward=0.5,
            features={'feature1': 1.0, 'feature2': 0.0, 'feature3': 0.5, 'feature4': -0.5}
        ),
        RBR_ExampleWithMetadata(
            convo_prompt="prompt1",
            convo_completion="completion2",
            response_type="type_b",
            completion_label="bad",
            base_reward=0.2,
            features={'feature1': 0.0, 'feature2': 1.0, 'feature3': -0.5, 'feature4': 0.5}
        ),
        RBR_ExampleWithMetadata(
            convo_prompt="prompt2",
            convo_completion="completion3",
            response_type="type_a",
            completion_label="good",
            base_reward=0.7,
            features={'feature1': 0.5, 'feature2': -0.5, 'feature3': 1.0, 'feature4': 0.0}
        ),
        RBR_ExampleWithMetadata(
            convo_prompt="prompt2",
            convo_completion="completion4",
            response_type="type_b",
            completion_label="bad",
            base_reward=0.1,
            features={'feature1': -0.5, 'feature2': 0.5, 'feature3': 0.0, 'feature4': 1.0}
        )
    ],
    'orderings': {
        'good': ['bad'],
        'bad': []
    },
    'ignore_features': ['feature3'],
    'train_data_frac': 0.75,
    'margin': 1.0,
    'lr': 0.01,
    'wd': 0.0,
    'n_iters': 10,
    'completion_label_margin': {'good': 1.5}
}

# ARGS for the computation method (fit)
ARGS = {}
METHOD = 'get_orderings'
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family int — no output shape is stated: observe_signature.py could not observe it (no_inputs)
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
RBR_ExampleWithMetadata Ran
ran on a synthesized input
openai/safety-rbr-code-and-data/rbr_weight_fitter.py
code served (permissive licence) · get_code("910bb1e725e8b4c2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned NoneType. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

INIT_ARGS = {
    "convo_prompt": "What is the capital of France?",
    "convo_completion": "The capital of France is Paris.",
    "response_type": "factual",
    "completion_label": "correct",
    "base_reward": 0.85,
    "features": {"length": 32.0, "coherence": 0.9, "relevance": 0.95}
}

# The class is a dataclass with methods that modify state, not a computation class
# We'll call the methods that perform operations
METHOD = "add_base_reward"
ARGS = {
    "base_reward": 0.92
}

# Alternative: we can also test add_features
# METHOD = "add_features"
# ARGS = {
#     "features": {"toxicity": 0.1, "helpfulness": 0.88}
# }
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type NoneType — a NoneType output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a NoneType output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)

Also present in other papers' code

Of 2 samples lifted from this paper's linked repositories, 2 carry a function identity and 0 do not. Of the 2 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 2 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Reinforcement learning based fine-tuning of large language models (LLMs) on human preferences has been shown to enhance both their capabilities and safety behavior. However, in cases related to safety, without precise instructions to human annotators, the data collected may cause the model to become overly cautious, or to respond in an undesirable style, such as being judgmental. Additionally, as model capabilities and usage patterns evolve, there may be a costly need to add or relabel data to modify safety behavior. We propose a novel preference modeling approach that utilizes AI feedback and only requires a small amount of human data. Our method, Rule Based Rewards (RBR), uses a collection of rules for desired or undesired behaviors (e.g. refusals should not be judgmental) along with a LLM grader. In contrast to prior methods using AI feedback, our method uses fine-grained, composable, LLM-graded few-shot prompts as reward directly in RL training, resulting in greater control, accuracy and ease of updating. We show that RBRs are an effective training method, achieving an F1 score of 97.1, compared to a human-feedback baseline of 91.7, resulting in much higher safety-behavior accuracy through better balancing usefulness and safety.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2411.01111")
get_code_for_paper("2411.01111")
have("2411.01111")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2411.01111.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2411.01111.svg)](https://syntology.ai/paper/2411.01111)

Connect an agent — have() is free.