Files
OBLITERATUS/docs/LABELED_SUBSPACE.md
Joseph MaglyandClaude Opus 5.5 5f0eafe14b feat(experiments): controlled interventions on direction and subspace estimates
Extend the controlled intervention harness beyond single channels.

- Fixed directions (rows of the pack's stored basis) and rank-k
  subspaces load from their direction artifact before the model does.
  The artifact must match the file, tensor and metadata digests that the
  dossier's source report recorded; discovery and subspace reports now
  record that binding, and reports without it are refused. Refitted
  difference-of-means directions stay refused.
- Subspace ablation removes the dose fraction of the projection onto the
  whole span. Steering a rank > 1 span needs one declared direction
  inside it (within 1e-4).
- Random controls are rank- and norm-matched: a seeded rank-k span
  orthogonal to the target span, and for a declared steering direction a
  rank-1 vector orthogonal to the whole span. Mismatched controls are
  refused before the arms run and at attachment.
- Each arm records target kind, rank, digests and orthogonalization.
  Evaluation rows on the artifact's own fit role and revision are
  refused. Channel specs and digests are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 20:26:07 -05:00

112 lines
5.6 KiB
Markdown

# Labeled activation sets and the model-level subspace report
A labeled activation set captures a pack's sets (positive, each control, each
neighbour and optionally each battery set) for declared dataset roles at chosen
decoder sites, and keeps, per row, the set label, partition role, record id,
logical path, independence group and `family_id`. The model-level subspace
report runs the full-subspace report (see the "Full-subspace report" section of
`docs/geometry-measurement-validity.md`) on those rows with the pack's
extracted rank-k basis at one site.
```bash
# next to an observation run: pack, model and role come from <run>/spec.json
obliteratus experiments subspace --run ./observations/<digest> \
--direction ./baseline/direction.safetensors --layer 3
# or explicitly
obliteratus experiments subspace --pack ./my-pack --model org/model \
--direction ./baseline/direction.safetensors --layer 3 --role select --out ./subspace
```
```python
from obliteratus.analysis.labeled_activations import capture_labeled_set, load_labeled_set
from obliteratus.analysis.labeled_subspace import labeled_subspace_report
from obliteratus.experiments.subspace import run_subspace
capture_labeled_set(model, tokenizer, {"layer.3": layer}, pack, "./labeled",
model_id="org/model", roles=["select"])
labeled = load_labeled_set("./labeled", model, tokenizer, {"layer.3": layer}, pack,
model_id="org/model")
rows = labeled.select(roles="select", sets=["positive", "control:harmless"])
splits = rows.folds(5, seed=0) # group-disjoint, label-stratified
result = labeled_subspace_report(labeled, direction, "layer.3", roles=["select"])
```
`--role` is repeatable; `--battery` adds battery sets; `--allow-locked-test`
is required for role `test`, both when capturing and when loading. Repeated
runs reuse a stored labeled set only after it passes every check below.
## Storage and identity
```
<out>/labeled-<site>-<roles>/
capture/ ordinary activation capture (manifest.json + raw/*.safetensors)
labels.json text-free per-row labels (obliteratus.labeled-activation-labels/1)
labeled-set.json manifest (obliteratus.labeled-activations/1)
<out>/<site>-<roles>.json report (obliteratus.labeled-subspace-report, schema_version 1)
```
The report's `basis` block records the stored basis identity and, when the
basis came from a file (`--direction`), its artifact binding
`artifact: {path, file_sha256, tensor_sha256, metadata_sha256}` (as for
candidate discovery); it is `null` for a basis passed in memory. A controlled
intervention on the subspace uses only an artifact matching this binding.
Each record is one unpadded batch, so row `i` of every site is label row `i`.
The capture manifest schema is unchanged. `labeled-set.json` records the
SHA-256 of `labels.json`, the capture identity digest, the dataset revision,
the pack id/version/sha256 and the roles. Loading recomputes the rows from the
pack for the stored roles and the capture identity from the supplied model,
tokenizer, sites, model id, phase and readout, then refuses (`CaptureRefused`
with a `field`) when:
- the labels file is missing or its digest differs (`labels_sha256`);
- the dataset revision changed (`dataset_revision`), or, for a legacy pack,
its bytes changed (`pack.sha256`);
- a label row differs from the pack's current row, including order (`labels`),
or its recorded input digest differs from the captured input (`labels`);
- any capture identity field differs, for example `checkpoint.model_id`,
`weights.sha256`, `tokenizer.name_or_path`, `readout.phase` or `sites`;
- the manifest points at another capture (`capture_identity_sha256`).
Labels never contain prompt text.
## Groups and legacy packs
For dataset packs the group of a row is its independence unit: the closure of
`group_id`, `family_id`, `pair_id`, ancestry and exact text that the dataset
partition already keeps inside one role. Folds and bootstrap resampling use
whole units. `group_folds(groups, folds, seed, labels)` orders groups by
`sha256("<seed>:<group>")`, so assignment depends on the seed and group names,
not on row order.
Legacy packs (no declared dataset) have no partitions. Only role `fit` is
accepted and every row is labelled `fit`, with `partitioned: false`, because
extraction may have used any row. Their groups are `group_id`, else
`family_id`, else the record itself, which is weaker than the dataset closure.
## Basis fit overlap
`basis_fit_on_evaluation_data` is derived, not declared by the caller. Dataset
extraction fits only on role `fit` rows and records a receipt
(`pack_provenance.dataset_access`: revision and role) in the direction
metadata.
| Case | Value | Effect |
| --- | --- | --- |
| Same revision, evaluated roles include the receipt's role | `true` | qualifiers `basis_fit_data_not_declared_disjoint` and `basis_fit_on_evaluation_data: ...` |
| Same revision, evaluated roles exclude it (`select`, `calibrate`, `test`) | `false` | no overlap qualifier |
| No receipt, or a different revision | `null` | `basis_fit_data_not_declared_disjoint` and `basis_fit_overlap_unknown: ...` |
| Legacy pack, basis names the same pack bytes | `true` | as for `true` |
| Legacy pack, basis names other bytes | `null` | as for `null` |
Each set label is one class, so a binary positive/control comparison supports
at most rank 1; select at least `k + 1` sets to test rank `k`. The verdict is a
held-out linear readout of set labels at one site, not a causal or
intervention claim.
## Explorer
When `<run>/subspace/` holds reports, the Explorer's "Subspace reports"
section lists site, roles, classes with counts, rows, verdict, the fit-overlap
value and the qualifiers as a descriptive table.