mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-06 11:04:06 +01:00
Extend candidate scanning from two prompts to distributions over a labeled activation set (F07). - Candidates with explicit coordinate identities: individual channels at a site and residual directions (a difference-of-means refit and the pack's stored basis rows). Binary (positive vs controls) or per-set contrasts. - Measures reported separately, never combined: held-out AUC and balanced accuracy over group-disjoint folds, standardized mean difference, group-bootstrap intervals and fold stability. Everything fitted is refitted per training fold; recipe_top1 reports the honest held-out score of each fold's own top channel. Independent validation uses select rows; in-sample and basis-overlap scores are labelled. - Nulls: a group-level shuffled-label null rerunning the full recipe (max over channels for channels) and random-direction/channel nulls, each with the observed quantile. - Confounds: token-count and hashed-token lexical baselines plus length correlation, flagged beside each candidate; features are built in memory and no text is stored. - Locked test is refused for discovery and excluded from acknowledged sets. Caps bound channels, bootstraps and permutations. - `obliteratus experiments discover` and a Python API write versioned candidate tables; the Explorer lists them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
2.7 KiB
Python
48 lines
2.7 KiB
Python
"""Argument parsing for ``obliteratus experiments discover``."""
|
|
|
|
from obliteratus.analysis.candidate_report import DEFAULTS
|
|
|
|
_ROLES = ("fit", "select", "calibrate", "test")
|
|
_CAPPED = ("folds", "top_n", "max_channels", "n_bootstrap", "n_permutations", "n_random",
|
|
"top_examples")
|
|
|
|
|
|
def add_discover(commands):
|
|
sub = commands.add_parser(
|
|
"discover", help="Dataset-level candidate discovery (channels and residual directions) "
|
|
"on labeled activations")
|
|
sub.add_argument("--layer", type=int, required=True, help="Decoder layer index (site)")
|
|
sub.add_argument("--run", help="Observation run directory (pack and model from its spec)")
|
|
sub.add_argument("--pack", help="Pack reference when no run directory is given")
|
|
sub.add_argument("--model", help="Model id when no run directory is given")
|
|
sub.add_argument("--dtype", default="float32")
|
|
sub.add_argument("--revision")
|
|
sub.add_argument("--device", default="cpu")
|
|
sub.add_argument("--mode", choices=("binary", "sets"), default="binary",
|
|
help="binary: positive vs controls; sets: each set vs the other sets")
|
|
sub.add_argument("--discovery-role", action="append", choices=_ROLES,
|
|
help="Role scanned with group-disjoint folds (repeatable; default fit)")
|
|
sub.add_argument("--validation-role", action="append", choices=_ROLES,
|
|
help="Independent validation role (repeatable; default select)")
|
|
sub.add_argument("--no-validation", action="store_true",
|
|
help="Skip independent validation (for example legacy fit-only packs)")
|
|
sub.add_argument("--direction", help="Extracted direction.safetensors to include as "
|
|
"residual-direction candidates")
|
|
sub.add_argument("--out", help="Output directory (default <run>/candidates)")
|
|
sub.add_argument("--seed", type=int, default=0)
|
|
sub.add_argument("--budget-bytes", type=int, help="Capture byte budget")
|
|
for name in _CAPPED:
|
|
sub.add_argument(f"--{name.replace('_', '-')}", type=int, default=DEFAULTS[name],
|
|
dest=name, help=f"default {DEFAULTS[name]}")
|
|
|
|
|
|
def run_discover_command(args):
|
|
from obliteratus.experiments.discover import resolve_and_run
|
|
return resolve_and_run(
|
|
layer=args.layer, run=args.run, pack=args.pack, model=args.model, dtype=args.dtype,
|
|
revision=args.revision, device=args.device, mode=args.mode,
|
|
discovery_roles=args.discovery_role,
|
|
validation_roles=[] if args.no_validation else args.validation_role,
|
|
direction=args.direction, out=args.out, seed=args.seed, budget_bytes=args.budget_bytes,
|
|
options={name: getattr(args, name) for name in _CAPPED})
|