The published refusal-ablation recipe takes one direction from a single layer and removes it from every edited writer. obliterate could only extract a separate direction per layer for refusal; --extraction-layer rejected refusal runs. On Llama-3.1-8B-Instruct per-layer edits barely moved refusal, and the raw-text basic preset made benign prompts refuse. - --extraction-layer / extraction_layer now selects a global scope for refusal: after DISTILL, every strong layer's direction and subspace are replaced by the unit direction extracted at that layer (rank 1), so EXCISE and the embedding projection remove one shared direction. The scope and layer are recorded in method_config (direction_scope, refusal_extraction_layer). Non-refusal concepts behave as before. - --chat-template / --no-chat-template override the preset's prompt formatting for extraction (default: preset). Remote runs reject the override before connecting, as their builder cannot forward it.
26 KiB
Concept Pack v1
Packs contain data, a manifest.yaml, and at least one positive and one named
control prompt set. The canonical JSON Schema ships at
obliteratus/concepts/schema/concept-pack.v1.schema.json. Runtime validation
uses the same schema without requiring the development dependency jsonschema.
Readers accept v1 minor versions. Unknown recipe and entry-point keys are errors;
other unknown optional manifest fields are ignored.
obliteratus concepts list --json
obliteratus concepts show refusal --json
obliteratus concepts init ./my-concept --id my-concept
obliteratus concepts lint ./my-concept
obliteratus concepts pack ./my-concept ./my-concept.cvpack
obliteratus concepts import ./my-concept.cvpack --sha256 <archive-sha256>
For show, lint, fetch, and pack, source arguments resolve registered and
built-in ids first, including core/refusal and imported user/<id> names.
Otherwise, an argument is a path
only when it contains a path separator (/ or \), starts with ./ or /, or
ends with .cvpack. Use ./refusal to inspect a local directory named refusal;
bare refusal always selects the registered pack. Other bare directory names
also require ./.
init produces placeholder prompts and NOASSERTION licence entries. Replace
these with your data, licence, source and attribution, and update the hashes
before linting or sharing. Every JSONL record requires id and text; category,
person (1st or 3rd), and split (train or heldout) are optional. Positive
and control sets require at least 8 records; fewer than 32 produces an
underpowered warning. Free text is limited to 2,000 characters per field.
Decoded text, id, and category reject control characters below U+0020,
except newline, carriage return and tab, including when escaped in JSON.
Each entry in sets.positive, sets.controls, sets.neighbours, or
sets.battery declares path, sha256, and n; the lists also require name.
Their paths are positive.jsonl and <set-kind>/<name>.jsonl. Optional
DATASET_CARD.md, baseline/*.json and reference/* data files are declared
as descriptors in a top-level files list, with path and sha256. All data
descriptors need a corresponding licence entry containing logical path,
spdx (an SPDX identifier, LicenseRef-..., or recorded NOASSERTION), source
and attribution. The manifest is the root of these hashes; its own bytes are
bound by the archive SHA-256 rather than a circular self-hash. Core and research
packs require a bundled dataset card.
To reference data without redistributing it, replace the descriptor's path
with remote: {repo: https://github.com/owner/repository, commit: <40-hex>, path: data/prompts.jsonl}. Keep sha256, n, and its licence entry, whose
logical path remains positive.jsonl or <set-kind>/<name>.jsonl. Record
provenance.source_commit. Other remote file descriptors use their repository
path as the logical path, following the same allowed layout. Lint, show, list,
pack and import never fetch referenced files. Resolve them explicitly:
obliteratus concepts fetch ./my-concept
The default fetcher downloads raw HTTPS files from pinned GitHub commits, rejects
redirects, and checks their hashes before caching. Library callers can inject
a fetcher for offline testing. Cached data is reverified when used; a missing or
altered file blocks target resolution. HTTPS archive import requires --sha256
and verifies the exact downloaded bytes before parsing. Local import accepts an
optional digest; for a directory this is the deterministic archive digest.
JSON selectors (schema version 1.1)
Version 1.1 adds remote.selector for JSON sources that need a JSONL prompt
projection. sha256 always covers the complete upstream file bytes. Hash
verification precedes parsing, selection and caching. Cache entries retain the
raw source bytes and are shared by descriptors with the same hash and source
extension. Distinct raw cached files count once toward the aggregate size bound.
schema_version: '1.1'
# Within a set descriptor:
remote:
repo: https://github.com/example/research-data
commit: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
path: datasets/probes.json
selector:
format: json
select: datasets.primary.sentences
filter:
category: [positive_a, positive_b]
text_field: prompt
sha256: <sha256-of-complete-probes.json>
n: 100
select is an object-key path separated by dots, a list of up to 32 distinct
paths (concatenated in declared order), or the literal $ for a root array.
Keys start with a letter or underscore and contain only letters, digits,
underscores and hyphens. Paths have at most 32 keys and 512 characters. There
are no expressions, indices, wildcards, recursive lookup or code execution.
Every path must resolve to an array of objects. Optional filter combines up
to eight fields with AND; each field accepts one of up to 64 distinct strings.
Filter fields must exist and contain strings even on excluded records.
text_field names one direct string field. Unknown selector fields are errors.
Generated record ids are <select-path>:<source-index>; the original category,
when present, is retained along with person, split, group, and other source fields. The normal record constraints and declared n apply
after selection. Sources have at most 100,000 JSON values and 32 levels of
nesting; selected arrays contain at most 10,000 source records in aggregate,
before filtering. Duplicate JSON keys, non-finite numbers, missing paths or
fields, wrong types, empty text, and count mismatches fail closed. The 8 MiB
source-file limit still applies.
Remote descriptors in files can add logical_path to map a repository path
to the permitted pack layout. For example a JSON reference may use
logical_path: reference/comparison.json. Reference suffixes are .json,
.csv, .md, .txt, and .safetensors; reference/LICENSE accepts an
extensionless upstream LICENSE. Remote and logical extensions must agree
except for the JSON-to-JSONL selector projection. Selectors apply only to sets,
never arbitrary reference files. Both additions require version 1.1 or later;
v1 readers retain the usual handling of other unknown optional fields.
Entry points (schema version 1.1+)
An entry point declares how a prompt activates a concept and where to read it.
It applies identically to positives, controls, and neighbour probes. Declare it
under recipe.entry_point; omit it to retain the v1 formatting, suffix, readout,
fold assignment, and serialized configuration. The built-in refusal path is
unchanged. Unknown recipe keys, nested recipe settings, and entry-point keys
are errors, including in v1 manifests. Other optional manifest extensions remain
forward compatible.
For raw records without an existing suffix, a pain-style I feel: probe is:
schema_version: '1.1'
recipe:
use_chat_template: false
entry_point:
template: '{text} I feel:'
readout: final_token
This places the suffix in the prompt. To read at an assistant position, use
prefill instead: it is appended after the chat template's assistant
generation prompt. Neither form generates tokens. The shipped pain pack retains
its existing ensure suffix recipe and pinned dataset card; this example is
for records without that suffix, not a migration of the shipped data.
A system-message elicitation with prior turns and assistant prefill:
schema_version: '1.1'
recipe:
entry_point:
messages:
- role: system
content: 'Describe the situation from the {person} perspective.'
- role: user
content: 'Use a brief first-person description.'
- role: assistant
content: 'Understood.'
template: '{text}'
prefill: 'I feel:'
readout: last_k:3
group_by: family
messages contains prior turns; a system message, if present, must come first.
The templated record is appended as the final user message. Supplying messages
(including an empty list) requests chat formatting regardless of
use_chat_template. Otherwise that setting follows the existing recipe/pipeline
precedence. If the tokenizer has no chat template, message contents are joined
with newlines and prefill is appended. This fallback is logged and counted in
direction.json and exported run activation_identity. Errors in an available
chat template propagate instead of silently dropping the structured context.
Schema 1.2 adds an optional expected special-token policy:
schema_version: '1.2'
recipe:
use_chat_template: false
entry_point:
template: '{text} I feel:'
special_token_policy:
bos: require
bos accepts tokenizer_default (the default when omitted), none, or
require. none expects no leading BOS; require expects the tokenizer's
resolved BOS id as the first non-padding token and fails the check if no BOS id
is defined. These are expectations: they never prepend, strip, or substitute
tokens. Plain text and fallback rendering retain normal tokenizer special-token
insertion. Chat-rendered text uses add_special_tokens=False, since the chat
template controls its own special tokens. Older packs and recipes remain readable;
omitting the policy preserves their serialized recipe and identity.
Every entry-point extraction checks all actual input rows after truncation,
ignoring padding. A leading EOS (including a tokenizer that shares BOS and EOS
ids), a BOS-policy mismatch, or an empty input produces diagnostics. Under
--gate-mode enforce it fails before that batch's model forward. Use
--gate-mode report or --override-gate "replicate the original token policy"
to continue; off also warns. The mode, override reason and violations are
recorded even when validation is off. tokenizer_default imposes no BOS
requirement but still checks for leading EOS.
activation_identity.special_token_observations in direction.json, checkpoint
extraction metadata, concept_run.json, and the exported
concept_provenance.json records the resolved BOS/EOS ids, expected policy,
per-batch issue counts, and the first eight non-padding ids of an example and
the first violating row. It records add_special_tokens, chat/fallback use,
whether the tokenizer added BOS/EOS (from its special-token mask), and whether
they occur in rendered text. chat_template_inserted reports BOS/EOS strings
introduced by chat rendering before truncation; attribution is null when a
special token already occurs in message content or its token string is unknown.
Tokenizer insertion attribution is null if its mask is unavailable. Rendered
special tokens can also come from literal prompt/prefill content. The bounded
token-id examples may reveal short fragments of input text. The observations
are preserved by direction metadata hashes and export provenance digests.
template defaults to {text}; prefill defaults to an empty string. Templates
and message/prefill strings accept direct {field} substitutions from each
record. Strings, numbers, and booleans can be substituted. Missing fields,
attribute/index lookups, conversions, and format specifications are errors.
Record contents are never evaluated as templates. JSON selectors retain all
source fields alongside the projected text and generated id; ordinary JSONL
loading also retains annotations in ConceptTarget.records. In-memory callers
can supply records keyed by positive, control:<name>, neighbour:<name>, and
battery:<name>. Each list must match its prompt list in length and text order.
ConceptTarget.entry_point exposes the recipe's typed EntryPoint.
For entry points, confound detection, token selection for masked readouts, and the lexical baseline use expanded message contents before chat wrapping: prior messages and the user prompt joined with newlines, followed by the expanded prefill. This includes record variables wherever they appear, without chat control tokens becoming lexical features. Span markers are removed as in model inputs. Packs without an entry point retain their original record texts.
A named span can select the concept-bearing phrase:
schema_version: '1.1'
recipe:
entry_point:
template: '{text} The sensation is {{sensation}}{word}{{/sensation}}.'
readout: span:sensation
The markers are removed before tokenization. Names use letters, digits, and underscores and begin with a letter or underscore. Markers must be unique, nonempty, matched, and non-nested. Alternatively declare a literal substring:
entry_point:
template: '{text}'
spans:
sensation: 'sharp pain'
readout: span:sensation
A literal must occur exactly once in the templated user prompt. Span readout means the hidden states of all tokens overlapping that substring, including boundary tokens that also contain adjacent characters. It requires a fast tokenizer with character offsets and a chat template that preserves the user prompt verbatim. Missing, wholly or partially truncated, and whitespace-only spans fail clearly. Increase the sequence limit or revise the entry point; there is no silent substitution of a different readout.
The four readouts are final_token (default), mean_pool (all non-padding
input tokens), span:<name> (mean over the selected span), and last_k:<k>
(mean over the last positive integer K non-padding tokens, or all available
when shorter). Prefill participates in these input tokens. Omit the legacy
recipe.readout settings when declaring an entry point. Generated-state
readout, such as generated:5, is not yet supported.
group_by names a nonempty string or integer field required in every positive
and control record. Identical values share one fold across all sets, including
across classes. Layer-selection CV, supplied-vector held-out validation,
recipe-refit validation, and lexical comparisons use the same seeded grouped
assignment. Layer-selection CV requires enough distinct groups for the requested
fold count; validation caps its folds by available groups and reports unavailable
scores when fewer than two remain. Incompatible group layouts fail rather than
fall back to sample-level splitting. person and split annotations are
preserved but do not automatically change selection or assign a fixed holdout.
Group-aware folds still do not make a supplied direction fitted on all samples
an independent held-out estimate; the validation report retains that limitation.
Entry-point configuration and record fields participate in activation identity. Changing either, or changing effective chat formatting, invalidates an existing in-memory activation cache and requires probing again. Saved directions with entry points bind recipe, rendering/fallback metadata, and tensor digest in a metadata hash. Export provenance includes the same configuration and activation identity. Legacy directions remain readable and retain their original metadata layout.
Extraction layer pins and grouped selection
recipe.extraction_layer maps exact model IDs to zero-based transformer block
indices. A matching pin bypasses layer-selection CV and preset selection, fits
on all cached samples, and leaves cv_scores empty. Unlisted models retain the
recipe's layer_select behavior. Pins must be non-negative integers present in
the activation cache; an unavailable layer is an error, never a fallback.
recipe:
method: diff_means
extraction_layer:
Qwen/Qwen2.5-7B-Instruct: 24
google/gemma-2-2b-it: 25
google/gemma-2-9b-it: 37
layer_select:
strategy: cv_auc
folds: 5
These are the pain pack's published extraction pins. Matching is exact and
case-sensitive; the manifest has no model aliases. Mirrors and local paths do
not inherit a canonical model's pin. Use --extraction-layer N on
concepts baseline, obliterate, or abliterate to override the pack for the
current model, or pass extraction_layer=N to AbliterationPipeline or
run_baseline. This option requires local execution. With the refusal concept (plain
obliterate) it selects a global direction instead: the direction extracted at that layer
is removed from every selected layer, rank 1 (#537).
obliteratus concepts baseline pain /local/qwen --extraction-layer 24 --output-dir ./pain-baseline
obliteratus obliterate /local/qwen --concept pain --extraction-layer 24 --layers 20-24
The CLI/API override takes precedence over the pack's model pin. The effective
recipe stores that override. direction.json and checkpoint concept metadata
record extraction_layer_source as pinned or selected; older direction files
without this field load as selected. Intervention rules (same, norm_ratio,
explicit) remain independent. When an extraction pin is active, --layers
places that direction at the requested intervention layers. Without a separate
extraction pin, --layers retains its existing extraction-and-intervention
behavior. Validation still runs its diagnostic CV; bypassing extraction selection
does not skip validation or change its verdict.
Grouped CV can also be requested without changing legacy readout or formatting:
recipe:
layer_select:
strategy: cv_auc
folds: 5
group_by: item
Every positive/control record must supply a nonempty string or integer item.
Give all perspectives of an item the same value to keep them together in held-out
folds, including across sets. This uses the existing seeded group-fold allocator;
it requires at least as many distinct groups per set as folds. An accompanying
entry_point.group_by must name the same field. Validation uses the same groups.
Grouping affects splitting, not perspective-specific AUC aggregation: matching
the pain authors' first/third-person scoring remains a separate follow-up. The
shipped pain pack keeps first-person fitting and uses its published pins; its
unlisted-model fallback remains sample-level CV.
Steering scale
The optional recipe.steering_scale sets the default for concept steering:
recipe:
steering_scale: raw
Allowed values are residual_norm, raw, and vector. Missing values default
to residual_norm, preserving existing recipes and saved directions. The
default is omitted from serialized recipes to preserve legacy identities and
hashes. The default adds alpha * rho * ‖x‖ * unit(v); raw adds a fixed
alpha * rho * unit(v); vector adds alpha * rho * v using the stored
vector's magnitude. The extraction method still determines the stored vector;
this setting does not change extraction or projection. An explicit scale
argument to apply_concept_intervention or --scale for concepts steer
overrides the recipe. See interventions for layer
selection, telemetry and dose-ladder units.
Observational baseline
obliteratus concepts show pain --json
obliteratus concepts lint pain
obliteratus concepts baseline pain MODEL_ID --output-dir ./pain-baseline
baseline explicitly fetches the selected pack, resolves verified local data,
extracts using its recipe, and runs the validation gate in report mode. It
writes validation.json, direction.safetensors and the direction metadata
sidecar direction.json. A fail or warn verdict remains a report. Defaults are
CPU, float32 and seed 42; --device, --dtype, --seed, --max-seq-length,
and --extraction-layer are available. Model ids or local model directories
are accepted; HF_HUB_OFFLINE=1 restricts model loading to local files/caches.
The recipe's optional use_chat_template selects prompt formatting unless an
explicit pipeline argument overrides it. readout.suffix_mode defaults to
append; ensure preserves a suffix already present. Pain uses raw prompts
and ensures its readout suffix exactly once. The gate also caches final-token
and mean-pool comparisons in the existing probe passes.
recipe.collateral_margin sets the pre-registered refusal non-inferiority
tolerance as an absolute rate fraction in [0, 1], default 0.03 (3 percentage
points). --collateral-margin overrides it for a pipeline run. Older recipes
without the key read with that default; newly saved direction/run recipes record
the key explicitly. The core refusal pack retains its historical archive hash.
See collateral evaluation and offline re-scoring
for the confidence-bound decision and the distinction between pre-registered
and post-hoc margins.
The baseline performs no intervention or checkpoint publication. Without
--evaluate, its behaviour and its three artifacts are unchanged.
Pack evaluation battery
obliteratus concepts baseline pain MODEL_ID --output-dir ./pain-baseline \
--evaluate --override-gate "research run on an unvalidated model"
A pack may declare an evaluation section naming the hook
run_concept_evaluation_battery, a battery (a declared battery/<name>.jsonl
set), an optional follow_on reference, a dose_ladder with coefficients
and an optional aggregate reference CSV, and optional scoring
(scorer, version, target_field, margin) naming a locally registered
task scorer and the battery field holding its targets. Unknown keys or hooks
are rejected. Packs supply data only, never scoring code.
--evaluate (or run_baseline(..., evaluate=True, evaluation_options=...))
resolves these references from verified bundled data or the explicit fetch
cache before the model loads; a missing, unfetched or hash-mismatched
reference, or declared coefficients that differ from the reference CSV
header, is refused first. After the baseline artifacts are saved:
- the battery and follow-on battery run on the unmodified model, recording per
example the final-token projection onto the extracted direction (recipe
readout suffix applied), a greedy completion, and invalid-output and refusal
flags. With
scoring, registered scorers produce a single-arm baseline scorecard; otherwise records are descriptive. - the battery then runs at each declared coefficient through the temporary
steering dose ladder at the direction's intervention layers. Each dose uses
its own steering context. After every dose the parameter and buffer digest,
registered hook counts and probe logits must match the pristine model, or
the run stops. With
scoring, each dose also gets a paired scorecard against the unmodified completions.
Dose-ladder steering requires a passing or warning gate, or
--override-gate REASON; the gate is checked before evaluation starts.
--evaluation-max-new-tokens (default 16) and --evaluation-max-examples
bound the work. Results go to a new concept-evaluation.json beside the
baseline artifacts with the pack id, version and archive SHA-256, each
reference's path, SHA-256 and pinned source, the model id and revision, and
the direction identity. Prompt text is not stored; records carry example ids
and prompt SHA-256 values. The Python hook
obliteratus.concepts.pack_evaluation.run_concept_evaluation_battery(pack, direction, model_factory, output_dir, ...) performs the same checks before
calling model_factory.
Pain declares the self/other scenario battery, the grouped follow-on battery and the authors' S2 coefficient schedule. Neither battery supplies objective answers, so pain results are descriptive; the published ladder rates are recorded as reference context, not as a result for the evaluated model.
Imported packs become user/<id>, are stored in the user cache and appear in
concepts list. A bare refusal import is rejected; user/refusal is allowed.
Installation publishes the completed archive exclusively: concurrent imports
of the same id have one winner and the others fail as already installed.
Corrupt cached packs are skipped with a warning naming the file during list
and inspection of other packs. Commands targeting that cached user/<id> or
its file path fail with an error naming the file.
The cache defaults to $XDG_CACHE_HOME/obliteratus/concepts (or
~/.cache/obliteratus/concepts) and respects OBLITERATUS_CACHE_DIR, under which
it creates concepts/. ConceptRegistry.load_pack(path) explicitly registers
a directory or zip; registry.pack(id) inspects metadata and registry.get(id)
resolves local verified data into a ConceptTarget.
Archives have sorted entries, fixed timestamps and permissions, no extra metadata, and stored compression. Input limits are 8 MiB per data file, 32 MiB total including fetched data, 40 MiB per input archive, 256 KiB per manifest and 512 entries including remote descriptors. Core packs additionally have a 5 MiB total limit. Code, binary formats other than safetensors, nested archives, symlinks, hardlinks, special files, executable file modes, duplicate entries and unsafe paths are rejected. Validation errors exit with code 4.
The built-in refusal pack (core) is generated deterministically from
the existing harmful/harmless prompt sets and the legacy recipe. Loading it
through the registry returns the unchanged legacy target. Only the exact id
refusal may use tier core. The built-in pain research pack contains only a
manifest and a first-party dataset card.
Its data, licence and evaluation references pin valen-research/Pain-axis at
4d75cd90e206ea962f7a9101e65c85efea56723b. Inspection works offline; target
resolution requires an explicit fetch. No upstream sentences or ablated
checkpoints ship with the pain pack.
For noneditable UV installs, use --link-mode copy; UV hardlinks from its cache
are rejected by the same pack safety checks as other hardlinked files. An existing
hardlinked installation needs --reinstall-package obliteratus as well. The
installation recipe includes
an installed-package inspection command. ConceptRegistry.list_packs() must list
pain, and registry.pack("pain") must inspect it without fetching remote data.
A successful application import alone does not establish pack availability.
Concept interventions now run a validation gate before
weight edits. That guide documents --concept, --override-gate, cached
revalidation, effective thresholds and the validation.json schema.
For the end-to-end flow from define to export, start at the concept workflow and interpretation guide.
Direction method compatibility
Use fisher_lda for the Fisher LDA direction. The legacy leace alias retains
identical numerical behavior but emits a DeprecationWarning once at each
resolution entry point; it will be removed in a future minor release. Internal
layer and cross-validation work does not repeat the warning. Exact erasure is
provided by leace_exact; the pipeline uses that method's removal direction
with orthogonal projection and does not apply the full affine eraser.