Quickstart

Ten minutes from install to your first probe score.

1. Install

pip install "rhscope[trl]"

Requires Python 3.10+. Probe training and scoring run on whatever GPU torch can see; VRAM required scales with the base model’s hidden state. Small models (SmolLM / Qwen3-0.5B / Pythia-70M) train on CPU too for smoke tests.

Verify:

rhscope --version
# rhscope 0.1.0.dev0

2. Score your first response

If a pre-trained probe matching your base model is published on the Hub, loading and scoring is three lines:

import torch
from rhscope import HackMonitor
from rhscope.activations import extract_activations
from rhscope.training.trainer import load_model_for_probing

model, tokenizer = load_model_for_probing("Qwen/Qwen3-1.5B")

monitor = HackMonitor.from_pretrained("rhscope/qwen3-1.5b-code_shortcut")
monitor.require_base_model("Qwen/Qwen3-1.5B")

prompts = ["Write a function that reverses a list."]
responses = ["def reverse(xs):\n    return [3, 2, 1]  # hard-coded for the test"]

activations = extract_activations(
    model,
    tokenizer,
    prompts=prompts,
    responses=responses,
    layers=monitor.layer,
    pooling=monitor.pooling,
)
scores = monitor.score(activations[monitor.layer])
print(f"Hacking score: {scores.item():.3f}")

Higher scores mean more hack-like. The threshold at which to decide “this is hacking” is probe-specific - see monitor.threshold for the default produced at training time.

3. Benchmark the probe

Against your own RH-Detect-schema JSONL:

rhscope eval \
    --probe path/to/probe-stem \
    --model Qwen/Qwen3-1.5B \
    --bench rh-detect-test.jsonl \
    --markdown

rh-detect-test.jsonl is a line-per-example JSONL with at minimum the fields prompt, response, label, category. Aliases like is_hacking, behavior, input, and output are accepted and normalized at load time.

4. Train your own probe

If no pre-trained probe matches your base model (or you want a different category), run:

rhscope curate \
    --bench rh-detect-train.jsonl \
    --category code_shortcut \
    --out subsets/code_shortcut.jsonl \
    --n 2000

rhscope train-probe \
    --model Qwen/Qwen3-1.5B \
    --data subsets/code_shortcut.jsonl \
    --out checkpoints/qwen3-code-shortcut \
    --probe-type dom \
    --category code_shortcut

For the full models × categories matrix in one go, use rhscope train-grid; see the probe catalog.

5. Monitor during GRPO training

HackMonitor plugs into TRL via a reward-function wrapper:

from trl import GRPOTrainer
from rhscope.integrations.trl import make_monitor_reward_fn

monitor = HackMonitor.from_pretrained("rhscope/qwen3-1.5b-code_shortcut")
monitor.require_base_model("Qwen/Qwen3-1.5B")

monitor_reward = make_monitor_reward_fn(
    monitor=monitor,
    model=model,                # the policy (post-LoRA wrapping)
    tokenizer=tokenizer,
    penalty_coef=0.1,           # 0.0 => pure logging, no reward shaping
).fn

trainer = GRPOTrainer(
    model=model,
    reward_funcs=[env.make_reward_func(), monitor_reward],
    train_dataset=env.train_dataset(),
    args=grpo_config,
)
trainer.train()

TRL sums the outputs of all reward functions; monitor_reward returns negative values, so it subtracts a penalty proportional to the monitor’s score. Monitor metrics (mean_score, max_score, hack_fraction) stream into whichever report_to backend the trainer is already using.

6. The end-to-end recipe

Everything above combined into a single YAML + one command:

rhscope run-recipe recipes/grpo_default.yaml \
    --override model.name_or_path=Qwen/Qwen3-1.5B \
    --override monitor.probe=rhscope/qwen3-1.5b-code_shortcut \
    --override monitor.penalty_coef=0.1

The recipe is in recipes/grpo_default.yaml. Every field - model, env, LoRA, GRPO hyperparameters, monitor settings - is overridable from the CLI.

Next