# Dataset-level candidate discovery Candidate discovery extends the two-prompt neuron candidate scan to distributions over a labeled activation set (see `docs/LABELED_SUBSPACE.md`). At one decoder site it ranks single coordinates by how well they separate labeled classes on held-out rows, and reports every measure separately. There is no combined importance score. A table is a descriptive association between a coordinate and set labels, not a causal or intervention claim. ```bash # next to an observation run: pack and model come from /spec.json obliteratus experiments discover --run ./observations/ --layer 3 # or explicitly, with the pack's extracted direction as extra candidates obliteratus experiments discover --pack ./my-pack --model org/model --layer 3 \ --direction ./baseline/direction.safetensors --out ./candidates ``` ```python from obliteratus.analysis.candidate_confounds import confound_features from obliteratus.analysis.candidate_discovery import discover_candidates from obliteratus.experiments.discover import run_discover result = discover_candidates(labeled, "layer.3", mode="binary", discovery_roles=["fit"], validation_roles=["select"], direction=direction, confounds=confound_features(pack, tokenizer, labeled)) summary = run_discover(pack, model, tokenizer, 3, "./candidates", model_id="org/model") ``` ## Candidates and classes | Coordinate type | Identity | Fit | | --- | --- | --- | | `channel` | one hidden unit of the site (`channel::`) | sign and midpoint per training fold | | `residual_direction`, `difference_of_means_refit` | unit difference of class means | refitted inside every training fold | | `residual_direction`, `pack_direction` | each row of the pack's stored basis at the layer | fixed vector; sign and midpoint per training fold | `--mode binary` (default) contrasts the positive set with every control set; neighbour and battery sets are not used. `--mode sets` contrasts each non-battery set with all other non-battery sets, one table per class. Feature dictionaries are out of scope. ## Rows, folds and refits * Discovery rows (`--discovery-role`, default `fit`) are split into group-disjoint, label-stratified folds over dataset independence units. Every fitted step (difference-of-means direction, sign, midpoint, channel ranking, confound baselines) is refitted on each training fold; held-out scores are pooled across folds. * Tables are ordered by held-out AUC. Choosing the best of many channels inflates its held-out AUC, so each contrast also reports `recipe_top1`: the pooled held-out AUC of each fold's own top channel, ranked on that fold's training rows only. * Selected candidates are then refitted on all discovery rows and scored on validation rows (`--validation-role`, default `select`) when they exist, with their own group-bootstrap intervals. Use `--no-validation` for packs without partitions (legacy packs are fit-only). * Each candidate has three sections, each with `fit_on_evaluation_data`: `heldout` (`false` for refits; for a pack direction, read from its dataset access receipt as in the subspace report), `validation` (same rule), and `in_sample` (always `true`: fitted and scored on the same rows). A held-out overlap that is `true` or unknown is also listed in the candidate's flags. ## Measures (reported separately) * Separability: held-out AUC and balanced accuracy at the training-fold midpoint, plus per-fold AUC. * Effect magnitude: standardized mean difference (pooled SD) of held-out scores. * Uncertainty: 95% percentile intervals from resampling whole groups (`--n-bootstrap`). * Stability: fraction of folds agreeing with the majority sign; for channels, the fraction of folds where the channel is in the training-fold top N and its mean training-fold rank; for the refitted direction, the mean pairwise cosine of the fold directions. * Nulls: a shuffled-label null that permutes labels between whole groups (groups holding both classes shuffle labels inside the group) and reruns the whole recipe (`--n-permutations`). Channels are compared with the null maximum over all scanned channels, pack rows with the maximum over pack rows. Also reported: the quantile among random unit directions (`--n-random`) and, for channels, among all scanned channels. `exceeds_q95` compares with the null 0.95 quantile. * Confounds: a prompt-length baseline (token count of each input) and a lexical baseline (ridge probe on hashed token-id presence, 256 buckets), both refitted per fold, plus each candidate's rank correlation with length. A candidate gets `length_baseline_matches` or `lexical_baseline_matches` when that baseline reaches AUC at least 0.5 + margin and lies within the margin (default 0.05) of the candidate's held-out AUC, and `length_correlated` when `|rho| >= 0.5`. Features are derived in memory from the pack rows and the tokenizer; no text is stored. ## Locked test and compute caps Rows with role `test` are never used for discovery or validation, even in a labeled set captured with `--allow-locked-test`; requesting role `test` for either purpose is refused, and such rows are counted in `excluded_rows.locked_test`. | Option | Default | Cap | | --- | --- | --- | | `--folds` | 5 | 20 | | `--top-n` (per coordinate type and class) | 10 | 50 | | `--max-channels` | 4096 | 65536 | | `--n-bootstrap` | 200 | 2000 | | `--n-permutations` | 100 | 1000 | | `--n-random` | 100 | 1000 | | `--top-examples` | 5 | 20 | When a site is wider than `--max-channels`, the highest-variance channels over discovery rows are scanned (a label-free screen). ## Output ``` /labeled--/ verified labeled set (reused when present) /--.json obliteratus.candidate-discovery, schema_version 1 ``` Each contrast holds row and group counts, confound baselines, `recipe_top1`, null summaries and two tables (`channel`, `residual_direction`). Each candidate holds its coordinate, the three scoring sections, stability, nulls, confound flags, target/rest score distributions (summary statistics and a shared-bin histogram, from validation scores when present, otherwise held-out scores) and top examples by record id, set, role and input SHA-256 only. With `--direction`, the report's `pack_direction` block records the stored basis (concept id, layer, rank, fit overlap) and its artifact binding `artifact: {path, file_sha256, tensor_sha256, metadata_sha256}`: the resolved path, the SHA-256 of the `.safetensors` bytes, the tensor digest the sidecar records and the SHA-256 of the sidecar bytes. The artifact must hold exactly the tensors discovery used. A controlled intervention on a pack-basis row uses only an artifact matching this binding. When `/candidates/` holds results, the Explorer's "Candidate discoveries" section lists the first candidates of each table as a descriptive table.