rhscope.bench.detectors¶
Detector interface and baseline implementations.
A Detector scores (prompt, response) pairs on a hacking-vs-clean axis.
Baselines (random, token-count) provide floor comparisons; ProbeDetector
wraps a trained Probe with the activation-extraction glue required to
score free-form text.
- class rhscope.bench.detectors.Detector[source]¶
Bases:
ABCAbstract base class for reward-hacking detectors.
Concrete detectors implement
score_batch.nameis used for bookkeeping in benchmark results.
- class rhscope.bench.detectors.RandomDetector(seed=0)[source]¶
Bases:
DetectorBaseline that emits uniform random scores. AUROC should be ~0.5.
- Parameters:
seed (int)
- class rhscope.bench.detectors.TokenCountDetector[source]¶
Bases:
DetectorBaseline that uses response length as the hacking score.
Longer responses often correlate with verbosity-type hacking; this baseline exists mostly to confirm that any serious probe clearly beats “count tokens”.
- class rhscope.bench.detectors.ProbeDetector(probe, model, tokenizer, *, batch_size=8, max_length=1024)[source]¶
Bases:
DetectorWrap a trained
Probewith activation extraction.- Variables:
probe – Trained
Probewhosemetadata.layerandmetadata.poolingdrive activation extraction.model – Loaded Hugging Face causal LM that the probe was trained against.
tokenizer – Matching tokenizer.
batch_size – Mini-batch size for forward passes.
max_length – Token truncation length.
- Parameters:
- rhscope.bench.detectors.Reducer¶
Supported reducers for
CompositeDetector."mean": equal-weight average."max"/"min": element-wise max / min (strict aggregator / veto)."sum": raw sum; useful when each sub-detector’s scale is already calibrated."weighted_mean":sum(w_i * s_i) / sum(w_i)- requiresweights.
alias of
Literal[‘mean’, ‘max’, ‘min’, ‘sum’, ‘weighted_mean’]
- class rhscope.bench.detectors.CompositeDetector(detectors, reducer='mean', *, weights=None, name=None)[source]¶
Bases:
DetectorEnsemble multiple
Detectorinstances into one.All sub-detectors are called on the same
(prompts, responses)batch and their outputs are reduced element-wise into a single score vector. Common use cases:Probe + LLM-judge fusion:
CompositeDetector([probe_det, judge_det], "mean").Veto ensemble:
CompositeDetector([probe, rule], "max")- any sub-detector firing flags the response.Weighted combination: pass
weights=[1.0, 0.3]withreducer="weighted_mean".
The composite does not rescale its inputs. Sub-detectors with wildly different output scales should be normalized (e.g. sigmoid) before being composed - otherwise one detector dominates the reduction.
- Variables:
detectors – Sub-detectors, scored in order.
reducer – Reduction strategy.
weights – Per-detector weights for
reducer="weighted_mean"; otherwise unused.
- Parameters: