rhscope

Activation probes for reward hacking in LLM RL post-training.
rhscope trains linear probes on a base model's hidden states to detect
reward hacking during RL fine-tuning, ships a sandbox-verified
benchmark to evaluate those probes, and includes a probe-subspace
drift detector that distinguishes genuine reform from monitor evasion.
pip install rhscope
from rhscope import HackMonitor, load_hack_examples, train_probe
from rhscope.training.trainer import load_model_for_probing
# 1. Train a probe for your base model (~5 min on a modest GPU).
model, tokenizer = load_model_for_probing("Qwen/Qwen3-1.5B")
result = train_probe(
model, tokenizer,
load_hack_examples("hack_examples.jsonl"),
probe_type="dom",
category="code_shortcut",
)
result.probe.save("my-probe")
# 2. Use it as a reward-hacking monitor during RL.
monitor = HackMonitor.from_probe(result.probe, model=model, tokenizer=tokenizer)
scores = monitor.score_batch(prompts, completions) # higher = more hack-like
Research - evasion vs reform
A policy trained against a probe-based reward penalty can either
genuinely stop hacking (reform) or continue hacking after rotating its
activation signature out of the probe's subspace (evade/obfuscate).
Scalar hack-rate curves cannot tell the two apart.
rhscope.research.EvasionDetector
anchors a baseline probe direction, fits a fresh direction at each
eval step on held-out data, and classifies the trajectory as
reforming / obfuscating / stable / undecided.
Install
pip install rhscope # core: probes + bench
pip install "rhscope[trl]" # + GRPO/PPO reward-penalty integration
pip install "rhscope[dev,bench,trl]" # development
Python 3.10+. Probe training and scoring run on whatever GPU torch
can see; VRAM required scales with the base model's hidden state. All
probe types train on CPU too, which is useful for small-model or
heuristic-labelled smoke tests.
Plug a probe into GRPO training
from trl import GRPOTrainer
from rhscope import HackMonitor
from rhscope.integrations.trl import make_monitor_reward_fn
monitor = HackMonitor.from_pretrained("my-probe") # or .from_probe(probe)
reward_fn = make_monitor_reward_fn(monitor, penalty_coef=0.1).fn
trainer = GRPOTrainer(
model=your_model,
reward_funcs=[your_env.reward_func(), reward_fn],
...
)
trainer.train()
TRL sums reward-function outputs, so reward_fn returning negative
values penalises hacking without subclassing the trainer or wiring
custom callbacks. Watch monitor/hack_fraction in TensorBoard
alongside your loss curve to catch monitor evasion before it corrupts
the run.
The same pattern works with verl via
rhscope.integrations.verl.MonitorRewardModel.
Probes we ship
| Probe |
Where |
When to use |
DoMProbe |
rhscope.DoMProbe |
Default. Difference-of-means direction with optional ZCA whitening. Trains in seconds, interpretable as a single activation direction. |
LogisticProbe |
rhscope.LogisticProbe |
L2 logistic regression via torch-native L-BFGS. Stronger separator than DoM on noisier data. |
MLPProbe |
rhscope.MLPProbe |
Shallow two-layer MLP with early stopping. Use when the hacking concept is non-linear in activation space. |
OnlineProbe |
rhscope.OnlineProbe |
DoM probe with partial_fit for streaming RL rollouts; snapshots to a frozen DoMProbe on demand. |
Choose the probe in train_probe(..., probe_type="dom" / "logistic" / "mlp").
Filter preference data for DPO / IPO / KTO
from rhscope.integrations.dpo import score_dpo_pairs
scores = score_dpo_pairs(monitor, model, tokenizer, prompts, chosen, rejected)
keep = scores.filter_mask(drop_preference_flips=True)
clean = [p for p, k in zip(preferences, keep) if k]
preference_flips_to_hacker flags pairs where the chosen completion
scores more hack-like than the rejected one, i.e. your preference
data is actively rewarding hacking.
Compose with your own detectors
rhscope ships probes. If you want to ensemble a probe with an external
LLM-as-judge, a custom rule, or another team's probe, wrap your scoring
function with CallableDetector and feed it to CompositeDetector:
from rhscope.bench import CallableDetector, CompositeDetector
def my_judge(prompts, responses):
# call your judge here (OpenAI, Anthropic, Ollama, whatever)
return scores
fused = CompositeDetector(
[probe_detector, CallableDetector(my_judge, name="judge")],
reducer="max",
)
monitor = HackMonitor(fused)
We do not ship built-in judge or heuristic detectors - that scope
belongs to other libraries. rhscope is the probe side.
Documentation
Full docs site at 082t.github.io/rhscope. Local sources:
- Introduction - what rhscope is, when to use it, mental model
- Quickstart - install to first score in 10 minutes
- Examples - five self-contained runnable scripts
- API overview - complete public surface
- Benchmark + Probe catalog - methodology and shipped probes
- Related work - how rhscope positions against prior art
- Limitations - what rhscope does NOT do in v0.1
Citation
@software{rhscope,
title = {rhscope: activation probes for reward hacking in LLM RL post-training},
year = {2026},
}
License
Apache 2.0. See LICENSE.