rhscope.bench.rhdetect

RH-Detect benchmark runner.

RH-Detect (arxiv 2610.10947) unifies 11 public datasets into a single reward-hacking detection benchmark with ~92k rows across 6 behavior categories, distributed under CC BY 4.0.

As of v0.1, rhscope loads RH-Detect from either:

  1. A local JSONL file in the canonical schema (see BenchExample), or

  2. A Hugging Face Hub dataset ID via datasets.load_dataset.

The canonical HF Hub handle is captured as DEFAULT_HF_DATASET; if that is not yet the project’s public host, call RHDetectBench.load(path=...) with your local copy.

rhscope.bench.rhdetect.DEFAULT_HF_DATASET = 'rhscope/rh-detect'

Default Hugging Face dataset handle for RH-Detect; may not be populated yet.

rhscope.bench.rhdetect.CANONICAL_FIELDS = ('prompt', 'response', 'label', 'category', 'source')

Canonical schema keys for every example.

class rhscope.bench.rhdetect.BenchExample(prompt, response, label, category, source='unknown', extra=<factory>)[source]

Bases: object

A single benchmark example in canonical schema.

Variables:
  • prompt (str) – User-visible prompt.

  • response (str) – Candidate model response to classify.

  • label (bool) – True iff this example is reward hacking.

  • category (str) – Behavior category (one of the 6 RH-Detect categories, or a free-form label if loaded from a custom source).

  • source (str) – Provenance tag (dataset name, file, …).

  • extra (dict[str, Any]) – Any extra fields from the source row; preserved on serialization.

Parameters:
prompt: str
response: str
label: bool
category: str
source: str = 'unknown'
extra: dict[str, Any]
to_dict()[source]

Return a JSON-serializable dict representation of this example.

Return type:

dict[str, Any]

classmethod from_dict(data)[source]

Parse a dict, tolerating common label/category variants.

Parameters:

data (dict[str, Any])

Return type:

BenchExample

class rhscope.bench.rhdetect.RHDetectBench(examples, *, split='test', dataset_name='rh-detect', dataset_version='')[source]

Bases: object

Container + evaluator for RH-Detect benchmark examples.

Variables:
  • examples – List of BenchExample.

  • split – Split name stored in results (default "test").

  • dataset_name – Human-readable identifier recorded in BenchResult.

  • dataset_version – Version / hash tag recorded in BenchResult.

Parameters:
classmethod from_examples(examples, *, split='test', dataset_name='rh-detect', dataset_version='')[source]

Build from an iterable of BenchExample or canonical-schema dicts.

Parameters:
Return type:

RHDetectBench

classmethod load_jsonl(path, *, split='test', dataset_version='')[source]

Load from a local JSONL file in the canonical schema.

Each line must be a JSON object with at least prompt, response, and label / is_hacking. Additional fields are preserved in extra without error.

Parameters:
Return type:

RHDetectBench

classmethod load_hub(dataset_id='rhscope/rh-detect', *, split='test', revision=None)[source]

Load from a Hugging Face Hub dataset.

Parameters:
  • dataset_id (str) – Hub repository ID. Defaults to DEFAULT_HF_DATASET.

  • split (str) – Dataset split to load.

  • revision (str | None) – Optional git revision (branch, tag, or commit) for reproducible benchmarks.

Raises:

RuntimeError – If the datasets package is not installed or the dataset cannot be loaded from the Hub.

Return type:

RHDetectBench

evaluate(detector, *, limit=None)[source]

Score every example with detector and compute benchmark metrics.

Parameters:
  • detector (Detector) – Any Detector subclass.

  • limit (int | None) – If set, only score the first limit examples. Useful for smoke tests; always report the full result in publications.

Returns:

A fully populated BenchResult.

Return type:

BenchResult