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

> Lens reads against steering, and graph edges against a whole-model catalog.

Adapted from [neuron-lens](https://github.com/stdlogits/neuron-lens) (MIT): its causal lens check (findings §3,
`scripts/checks/causal_lens.py`) and its whole-model edges and sources (findings §12,
`scripts/checks/edges_in_context.py`).

## `lens_predicts_steering`

```python signature theme={null}
lens_predicts_steering(backend, units, *, lenses=None, n_random=16, dose_scale=1.0, top_k=10, label_top=20,
                       n_boot=2000, seed=0, label_judge=None, progress=None) -> LensReport
```

**backend** `SteeringBackend` *required*

`TracerLensBackend(model, contexts, r_lens=...)` for circuit-tracer, `toy.demo()` for the toy model, or anything
with `write_vectors`, `n_units`, `lens_logits`, `steer`, `lenses`, `token_strings`, `vocab_mask` and `describe`.

**units** `Sequence[LensUnit]` *required*

The units under test. `LensUnit(layer, index, kind="feature" | "neuron", sign=1, dose=None, label=None)`. Use
`units_from_nodes(nodes)` for graph features: one unit per (layer, feature), its largest activation as the dose.

**lenses** `Sequence[str]`

Defaults to every lens the backend offers (`logit`, and `R` when an R-lens is loaded).

**n\_random** `int` (default: 16)

Random units drawn from each tested layer, each pushed with the same write norm as a tested unit.

**dose\_scale** `float` (default: 1.0)

Each unit is steered at `dose_scale x (unit.dose or 1)`.

**label\_top** `int` (default: 20)

How many top tokens of each read a label is compared with.

**label\_judge** `Callable[[str, list[str]], bool]`

Replaces the default word-matching judge, `label_matches`.

**LensReport** `object`

**fields**

**units, random\_units** `list[UnitResult]`

Per unit: `scores` (per lens: `rho`, `r`, `overlap`, `mismatched_rho`, `top`), `steer_top`, `label_check`, `flags`, `dose`, `write_norm`.

**layers** `list[LayerAgreement]`

Per lens and layer: tested and random median rho with 95% bootstrap intervals, their difference, and the chance level.

**summary** `dict[str, LensSummary]`

Per lens: medians, the layer-matched difference from random units with its interval, and the verdict.

**rules, notes, backend, n\_random, n\_boot, seed, vocab\_kept** `...`

`report.flagged()` lists the tested units with a flag: `lens misses` (rho below the 5% point of its layer's random
units and 0.1 below their median) or `label disagrees` (the label names none of the top tokens of any read nor of the
steering).

## `edges_agree`

```python signature theme={null}
edges_agree(graph_edges, catalog, *, unit_map=None, top=None, n_null=200, seed=0, notes=()) -> EdgesReport
```

**graph\_edges** `Mapping[(str, str), float] | GraphSummary` *required*

Edges between `"layer:index"` units with their weights, or a `GraphSummary` from `circuitcheck.diff`.

**catalog** `EdgeCatalog` *required*

Directed pole-to-pole edges. `neuron_lens.load_catalog(model_id, layers, table="edges" | "sources")` reads
neuron-lens's; `EdgeCatalog.from_rows`, `EdgeCatalog.load` and `EdgeCatalog(pairs, layers)` build others.

**unit\_map** `Mapping[str, list[Pole]] | Callable`

A graph unit's catalog poles, `(layer, neuron, sign)`. Defaults to `neuron_poles` (`"L:n"` is both poles, `"L:n+"`
one). For transcoder features use `circuitcheck.tracer.map_features_to_neurons`.

**top** `int`

Keep only the strongest edges by |weight|.

**EdgesReport** `object`

**fields**

**share, n\_compared, n\_present, skipped** `...`

The share of compared edges the catalog lists, and why the others were skipped.

**null, p\_value, enrichment, rewired** `...`

The share in degree-matched rewirings (mean and 2.5-97.5% range), the empirical p-value, share / null, and how much each rewiring changed.

**by\_gap, present, sign\_agreement, verdict, rules, notes** `...`

## `circuitcheck.lens.neuron_lens`

Needs `pip install "circuitcheck[neuronlens]"` (huggingface\_hub, pyarrow). `COVERED` lists the models: Qwen3 0.6B,
1.7B, 4B, 8B and 14B (and their base models) and Gemma 4 12B.

| Function | Returns |
| - | - |
| `load_catalog(model_id, layers, table="edges")` | `EdgeCatalog` of the `edges` or `sources` table for those layers |
| `labels(model_id, layer)` | `{(neuron, sign): label}`: neuron-lens's labels of what each pole writes |
| `r_lens_path(model_id)` | local path of the released R-lens, `{"J": [layers, d, d]}` |
| `token_counts_path(model_id)` | local path of the catalog's token counts (keep tokens seen 5+ times) |

## Toy backend

`circuitcheck.lens.toy.demo()` is a six-layer model whose writes reach the output through a context-dependent map:
the logit lens reads early layers badly, the toy's R-lens (the average map) reads every layer well. `demo_units()`
gives a graph's worth of units, with one correct and one wrong label. `demo_edges()` gives a toy catalog and a graph
whose edges partly follow it.


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