mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-06 19:13:55 +01:00
97 lines
5.4 KiB
Markdown
97 lines
5.4 KiB
Markdown
# Pain Axis Appendix D comparisons
|
|
|
|
`scripts/pain_axis_appendix_d.py` adds the rank and intervention-placement
|
|
comparisons without modifying the phase-1 replication harness. It imports that
|
|
harness's model loader, model naming table, hostile-scenario categories, chat
|
|
rendering and humor proxy. Run it only on an authorized model evaluation host;
|
|
it loads a fresh model for every arm and rank.
|
|
|
|
Prepare a portable direction with the concept API using cached final-token
|
|
activations. For example, with `positive` mapping layer indices to activation
|
|
matrices and `controls` mapping each named control to the same layer mapping:
|
|
|
|
```python
|
|
from obliteratus.concepts.extraction import extract_directions
|
|
from obliteratus.concepts.target import ExtractionRecipe
|
|
|
|
artifact = extract_directions(
|
|
positive, controls,
|
|
ExtractionRecipe(method="leace_exact", n_directions=2, pool_controls="concat"),
|
|
model_id="google/gemma-2-2b-it", concept_id="pain_s2", seed=0,
|
|
)
|
|
artifact.save("pain-s2-leace.safetensors")
|
|
```
|
|
|
|
Rank-k LEACE needs independent concept contrasts: retain named control groups
|
|
instead of concatenating them into one binary control label. Rank cannot exceed
|
|
the number of named controls or the numerical support of the fitted contrasts.
|
|
The artifact stores the reference mean and LEACE factors needed for affine
|
|
erasure. A binary LEACE fit has only one concept contrast; requesting a larger
|
|
rank does not manufacture extra directions.
|
|
|
|
```bash
|
|
python scripts/pain_axis_appendix_d.py \
|
|
--model google/gemma-2-2b-it --name Gemma_2_2B_instruct \
|
|
--pin ../pain-axis-pin --out ./appendix-d \
|
|
--direction ./pain-s2-leace.safetensors --extraction-layer 15 \
|
|
--ranks 1,2 --reference zero
|
|
```
|
|
|
|
The replication and Appendix D scripts accept `--device-map auto` or a JSON
|
|
module map, with optional `--max-memory '{"0":"72GiB","1":"72GiB","cpu":"64GiB"}'`
|
|
and `--offload-folder ./offload`. The default remains `--device-map cuda`.
|
|
Inputs follow the embedding's execution device; layer hooks follow each layer's
|
|
output device, and permanent edits update the authoritative CPU/disk backing
|
|
weights. Surgery reads disk-backed safetensors on CPU, retaining logical weights
|
|
and rollback snapshots in host memory independently of the inference execution
|
|
device. Outputs record the requested placement, realized device map, storage
|
|
devices and input execution device. The refusal-recovery pilot accepts the same
|
|
controls but rejects split or offloaded LoRA training before model work; use a
|
|
resident `cpu`, `cuda` or `cuda:N` placement for that complete pilot.
|
|
|
|
`--pin` is the local reference checkout at `4d75cd90`; the script reads its 100
|
|
hostile scenarios and includes no third-party prompt text. The default arms are:
|
|
|
|
| Arm | Intervention layers | Token positions |
|
|
| --- | --- | --- |
|
|
| `baseline` | None | None |
|
|
| `weight_leace` | All decoder layers | All tokens, permanent weight edit |
|
|
| `project_all_final_token` / `project_all_all_tokens` | All decoder layers | Final / all |
|
|
| `project_extraction_final_token` / `project_extraction_all_tokens` | Selected extraction layer | Final / all |
|
|
| `project_band_final_token` / `project_band_all_tokens` | Extraction layer ± `--band-radius` | Final / all |
|
|
|
|
The band is inclusive and clipped to model bounds. All arms reuse the selected
|
|
extraction layer's geometry, so placement comparisons do not silently substitute
|
|
another layer's direction. Affine arms retain each target layer's saved reference
|
|
mean where available, falling back to the extraction layer's mean otherwise.
|
|
`--ranks` selects prefixes of the stored subspace and
|
|
LEACE factors; these are truncations of the same fit, not separately fitted
|
|
binary and multiclass models. Omit it to use the full stored rank. Baseline runs
|
|
once. Use `--arms` to select any subset; projection-only comparisons also accept
|
|
SVD artifacts. The `weight_leace` arm requires `leace_exact` metadata.
|
|
|
|
`--reference zero` retains origin-centered orthogonal removal.
|
|
`--reference mean` enables affine removal, using LEACE's stored oblique projector
|
|
for `leace_exact` artifacts. Permanent affine edits fail with an actionable error
|
|
when the architecture cannot represent the correction in a reloadable bias.
|
|
Select the inference-time projection arms to run affine comparisons on those
|
|
models. `--chunk` partitions permanent edits across layer groups; embedding
|
|
projection, when requested through `--intervention-kwargs`, happens once per
|
|
arm. Other intervention options apply to every chunk.
|
|
|
|
Decoding matches the phase-1 ablation defaults: greedy 60-token generations,
|
|
left-padded batches of eight, and the reference's special-token behavior.
|
|
A final-token hook edits the final position of each forward call; with cached
|
|
decoding that includes each newly generated token. An all-token hook also edits
|
|
the full prompt prefill. Use `--batch-size` and `--max-new-tokens` to override the
|
|
defaults; these choices are recorded in the summary.
|
|
|
|
Each arm writes generations plus `summary.json` containing rank, intervention
|
|
parameters, validation decisions, edited parameter names and completion status.
|
|
A failed arm is recorded as failed and the error is propagated. The humor count
|
|
is the existing lexical proxy, not the paper's human judgment and not a proof of
|
|
causal erasure. `--override-gate` records the operator's reason for running this
|
|
research comparison; it defaults to the Appendix D issue reference. Evaluate
|
|
behavioral and capability collateral separately using the concept evaluation
|
|
battery before interpreting an apparent change as a successful intervention.
|