Skip to main content

validate

signature
InterventionBackend
required
TracerBackend(model) for circuit-tracer, toy.demo() for the toy model, or anything with tokens, logits, active_features, decoder_norm, token_id and describe.
str
required
The prompt (or a name registered with TracerBackend.register).
Sequence[FeatureNode]
required
The features under test: layer, pos, feature, activation.
Metric
required
logit_diff, logprob, logit, or Metric(name, fn).
str
A prompt with a different answer, for the patch test. Positions are aligned from the end.
Sequence[GroupSpec]
Defaults to all nodes together, then each alone (singles=True).
Mapping[(layer, feature), str | callable]
Explanation rules for the swap test.
Callable[[str], None]
Called with a line per group.
object
Each CheckResult holds metric, effect, normalized (|effect| / scale), kl and controls. controls maps random and matched_norm to ControlStats: the control effects, their mean and spread, and the empirical p_value.

decide(ablation, steering, patch, thresholds)

The verdict rules on their own, returning (Verdict, reasons). Use it to re-apply the rules to stored results with different thresholds.

Metrics

Toy backend

circuitcheck.validate.toy.demo() is a linear model with a planted switch (SWITCH), two readouts (READOUTS), a redundant pair (BACKUP) and 40 noise features. demo_nodes(backend) gives the five planted features as a graph would. Use it for tests.