> ## Documentation Index
> Fetch the complete documentation index at: https://circuitcheck.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# circuitcheck.validate

> The validator, its types and metrics.

## `validate`

```python signature theme={null}
validate(backend, prompt, nodes, *, metric, counterfactual=None, groups=None, singles=True, steer_scale=3.0,
         n_controls=20, seed=0, rules=None, thresholds=None, progress=None) -> Report
```

**backend** `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`.

**prompt** `str` *required*

The prompt (or a name registered with `TracerBackend.register`).

**nodes** `Sequence[FeatureNode]` *required*

The features under test: `layer`, `pos`, `feature`, `activation`.

**metric** `Metric` *required*

`logit_diff`, `logprob`, `logit`, or `Metric(name, fn)`.

**counterfactual** `str`

A prompt with a different answer, for the patch test. Positions are aligned from the end.

**groups** `Sequence[GroupSpec]`

Defaults to all nodes together, then each alone (`singles=True`).

**rules** `Mapping[(layer, feature), str | callable]`

Explanation rules for the swap test.

**progress** `Callable[[str], None]`

Called with a line per group.

**Report** `object`

**fields**

**groups** `list[GroupResult]`

Per group: `ablation`, `steering`, `patch`, `explanation_swap`, `verdict`, `reasons`.

**clean\_metric, counterfactual\_metric, scale** `float`

**thresholds, n\_controls, seed, backend, notes** `...`

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

| Function | Value |
| - | - |
| `logit_diff(target, contrast)` | logit(target) - logit(contrast) |
| `logprob(target)` | log p(target) |
| `logit(target)` | logit(target) |
| `kl(p_logits, q_logits)` | mean KL(p ‖ q) over positions |

## 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.