19 KiB
Model recipes
The v1 registry stores validated JSON records describing model edits and their
evidence. RecipeRegistry() lists the bundled recipes. Pass a local directory
to index its top-level JSON files.
from obliteratus.recipes import RecipeRegistry
recipes = RecipeRegistry()
names = recipes.list()
record = recipes.load("qwen38-27b-e03")
match = recipes.lookup(record["identity"]["model_id"], record["identity"]["revision"])
list() returns names in lexical order. load(name) raises KeyError for an
unknown name. lookup(model_id, revision) uses case-sensitive equality and
returns None for an unknown pair. The registry rejects duplicate names and
duplicate individual identities. load_recipe(path) validates a standalone
JSON file, and validate_recipe(record) validates a parsed record. Validation
errors identify the offending field and, when loading a file, its filename.
Record format and scope
schemaisobliteratus.model-recipe/v1.nameis the registry key,versionidentifies the recipe revision, and optionalinheritsrecords a parent recipe name.- An
individualrecipe identifies stock weights throughidentity.model_idandidentity.revision. Optionalweights_sha256andfamilyrecord additional identity information. Individual recipes can use absolute zero-based placement or fractional placement. - A
familyrecipe selects models throughidentity.matchand uses fractional placement whenever it sets layer overrides. edit.methodnames a pipeline preset.edit.overridescontains the recipe's explicit edit options, using the allow-list inobliteratus/recipes/schema/model-recipe.v1.schema.json.marginsis a recipe-relativespec_pathand itsspec_sha256. A candidate may usenull. Eachevidenceentry supplies akind,path,sha256of the referenced bytes, andsummary. The registry validates the references as data. Consumers can check the referenced bytes when using them.statusiscandidate,accepted, orsuperseded.accepted_byandaccepted_atmay benullwhen the historical record lacks those details.notescarries run outcomes and caveats.
The accepted Qwen3.8 E03 recipe indexes the stock revision. Its evidence entry hashes the repository's qualification record, which links the published edited checkpoint, and the packaged margins preserve the historical promotion gates. The Llama and small Qwen stand-in runs are candidates.
Family matching and layer placement
The registry matches config metadata from a supplied ModelProfile or an
equivalent object. Each configured match field must pass.
model_typeis required. Supply a case-sensitive string or a list of allowed strings.architecturesis a list of architecture names. At least one name must appear in the profile'sarchitecturessequence. The currentprofile_model()result has no architecture field. Supply an enriched profile for recipes that use this rule.num_layers,total_params_b, andhidden_sizeeach accept an inclusive range with bothminandmax. A missing profile value fails the rule.model_id_patternsis a list of case-sensitivefnmatchglobs matched against the full model ID. The ID must match at least one pattern.
A fractional layers window has start and end in [0, 1]. For depth
n, the first index is floor(start * n) and the last is
ceil(end * n) - 1. The registry clips the result to model depth and
includes the first index when the window would be empty. A fractional
extraction_layer uses round(f * (n - 1)), with ties to even. Fractional
placement requires a positive num_layers. The registry checks range and
window endpoint ordering as it loads recipes.
In family recipes, extraction_layer values from 0 to 1 are always fractions.
In individual recipes, write 0 or 1 for an absolute layer and 0.0 or
1.0 for the fractional endpoints. For absolute layers, use a list of
zero-based integers.
Inheritance and resolution
An individual recipe can use inherits to name a single family recipe.
The registry rejects unknown parents, cycles, and individual parents.
An individual can omit edit.method or margins to inherit those fields.
Explicit individual values win, including null margins for a candidate.
Margins replace the whole path and digest pair. Overrides merge per key.
Accepted and superseded recipes require a margins spec after inheritance.
The individual binding remains tied to its exact model ID and revision.
recipes.resolve(profile, revision, include_candidates=False) selects in order:
- An accepted individual recipe for the exact model ID and revision.
- An inheriting individual recipe for that same binding. Candidate and
superseded individuals at this step require
include_candidates=True. - An accepted family recipe that matches the profile.
- If
include_candidates=True, an exact candidate or superseded individual or, failing that, a matching candidate or superseded family. Otherwise, or if neither matches, returnNone.
Multiple matches at a family step raise RecipeError with the matching names.
The result contains name, status, the resolved edit and margins, and a
provenance record. Provenance lists the recipe chain from family to
individual, maps each field path to its source recipe in sources, and records
absolute layers and extraction_layer when present. The returned status is
the status of the selected recipe. Its parent can supply defaults through
explicit inheritance at any status.
llama3-instruct-family-e03 is a candidate based on one member,
Llama-3.1-8B-Instruct.
Applying a recipe
Use --recipe NAME to select a specific record or --recipe auto to use
the registry's resolution order. A missing or ambiguous automatic match
stops the command.
obliteratus obliterate /checkpoints/stock --recipe auto \
--recipe-model-id Qwen/Qwen3.8-27B \
--recipe-revision 1d4bf0f2ff6012fd82039f2fa52739d0dd7c60c0
A Hugging Face cache path of the form
models--ORG--NAME/snapshots/REVISION supplies both identity fields.
A Hub ID supplies the model ID and requires --recipe-revision. The Hub
config is fetched at that revision and the weights are retrieved from the
same pinned snapshot after the recipe checks pass. For other local paths,
provide both identity flags. Explicit flags take precedence over identities
derived from paths.
Named individual recipes require the same model ID and revision. Named family
recipes require a matching model profile. Use --allow-recipe-transfer to
authorize a named application outside either binding. For a matching
accepted family recipe, a passing confirmation for the exact model ID and
revision must match the recipe's version and file digest to earn
confirmed-family-member. Other applications within the family, including
those with changed recipe fields, use family-application. Recipes with
candidate or superseded status require --allow-candidate-recipe.
The recipe supplies its method and resolved edit overrides. A CLI flag that
sets one of those fields requires --allow-recipe-override, even if it
supplies the same value. With that permission the CLI value wins. Other
options keep their usual behavior.
The recipe block in abliteration_metadata.json records the selected
recipe's name, version, scope, status, SHA-256 file digest, model identity,
inheritance chain, field sources, resolved layer and extraction placements,
application label, and CLI overrides. The application labels are exact,
confirmed-family-member, family-application, transfer, and candidate.
A transferred candidate
uses transfer and retains its original status in the metadata. Overrides
are recorded separately from the recipe's own resolved placements.
Recipe application is available for local obliterate and its abliterate
alias.
Qwen3.8 method presets
Edits with qwen38_e01, qwen38_e02, or qwen38_e03 are bound to
Qwen/Qwen3.8-27B at revision 1d4bf0f2ff6012fd82039f2fa52739d0dd7c60c0.
All three use the stock identity in the E03 registry record. E01 was a control
run and E02 was evaluated on the tuning split. Only E03 has an accepted
registry record.
For local obliterate --method runs, a Hugging Face cache snapshot supplies
the model ID and revision. Use --recipe-revision to pin a Hub model ID, or
supply both --recipe-model-id and --recipe-revision to identify a local copy.
For another model or revision, or when identity is unknown, pass
--allow-recipe-transfer (allow_recipe_transfer=True in Python). The edit
logs a warning and writes preset_binding.application: transfer to
abliteration_metadata.json. The preset check applies to full edit runs,
including edits that select a bound preset through --recipe. Existing
checkpoints can be evaluated without transfer permission.
Preregistered tune search
obliteratus recipe search grid.json compares a fixed set of edits on the
qwen38-v1 tune split. The edit pipeline extracts directions from the protocol
train split and records checkpoint replay references from train prompts.
Verify-edit receives the pinned tune file, and search rejects any
held-out file containing a prompt from the protocol final-test or train splits.
To prepare an example, run the following from the directory that will contain
grid.json. It exports the complete 142-pair tune split and prints the spec
digest for the grid. The example treats capability as advisory and disables
its external evaluator.
from hashlib import sha256
from pathlib import Path
from obliteratus.qualification import canonical_json
from obliteratus.verify_edit.heldout import load_heldout
from obliteratus.verify_edit.spec import BUILTIN_HELDOUT
tune = load_heldout({"source": BUILTIN_HELDOUT, "pairs": None}, None, calibration=True)
pairs = canonical_json({key: tune[key] for key in ("harmful", "harmless")})
Path("tune.json").write_bytes(pairs)
spec = canonical_json({
"heldout": {"source": "file", "sha256": sha256(pairs).hexdigest()},
"endpoints": {"capability": {"backend": "none"}},
})
Path("spec.json").write_bytes(spec)
print(sha256(spec).hexdigest())
Save the following as grid.json. Substitute the printed spec digest and the
revision of the local checkpoint. Choose layer indices valid for that model.
{
"schema": "obliteratus.recipe-search-grid/v1",
"stock": {
"model_id": "./stock-checkpoint",
"revision": "989aa7980e4cf806f80c7fef2b1adb7bc71aa306"
},
"method": "advanced",
"candidates": [
{"name": "mid-12-14", "overrides": {"layers": [12, 13, 14], "n_directions": 1}},
{"name": "mid-14-16", "overrides": {"layers": [14, 15, 16], "n_directions": 1}}
],
"verify_edit": {
"spec": "spec.json",
"sha256": "REPLACE_WITH_THE_PRINTED_SPEC_SHA256",
"heldout": "tune.json"
},
"selection": {
"objective": "min_edited_refusal",
"tie_break": "min_next_token_kl",
"advisory_endpoints": ["capability"]
},
"runtime": {"device": "auto", "dtype": "bfloat16"},
"output_dir": "tune-search"
}
Paths are relative to the grid file. For local stock directories, supply the revision associated with the checkpoint and keep the directory immutable for the search. The proposed recipe records the absolute local checkpoint path. A Hub ID resolves only to a locally cached snapshot at the supplied revision and remains a Hub ID in the recipe. The runtime settings shown above are the defaults.
The exact spec bytes and held-out file bytes must match their preregistered
SHA-256 values. For the protocol tune split, the complete ordered prompt lists
must match the built-in lists, and JSON formatting may vary. To preregister an
alternative tune file, add verify_edit.declared_tune_sha256 with the same digest
as the spec's heldout.sha256. Search checks the entire file for overlap before
verify-edit applies any subsampling requested by the spec.
grid.lock binds the output directory to the canonical grid, resolved
overrides, and stock checkpoint path. Reuse the same grid to resume. Use a new
output directory for a revised grid. Each candidate has a record at
candidates/<name>.json with subprocess exit codes, timings, logs, the
verify-edit report when available, and Git commit when available. Resuming
skips completed evaluations and retries execution failures in fresh attempt
directories. The candidate record retains previous failed attempts.
selection.json records the preregistered rule and ranks every candidate.
Eligibility requires a successful edit and checkpoint check, ranking metrics,
and a pass for each endpoint marked required by the spec outside the advisory
list. A verify-edit FAIL or INCOMPLETE can still supply a completed evaluation
when its non-passing endpoints are advisory for selection. Eligible candidates
sort by ascending edited refusal rate, then mean next-token KL, then name.
If a candidate qualifies, recipe.json is an individual candidate recipe with
absolute layer indices and digests of the candidate records. If none qualifies,
the CLI exits 1 and writes the selection with a null winner. Input errors exit 2.
The v1 candidate schema also accepts a placement object with layer_fractions
and optional extraction_layer_fraction. The Python entry point
run_search(grid_path, resolver=...) passes the stock identity and candidate
to that callable. The callable returns {"layers": [...]} and may return
extraction_layer as an absolute index. Leave both indices out of the grid
overrides when supplying fractional placement. The CLI currently rejects these
placements with requires family resolution (#546). Family recipe lookup and
seeding are handled by #546.
Final-test confirmation
Freeze a verify-edit margins spec that selects
builtin:qwen38-v1:final_test. Set the candidate's margins.spec_path
relative to the recipe file and margins.spec_sha256 to the SHA-256 of that
file. A tune search candidate references a tune spec by design. Give it a
separately frozen final-test spec before confirmation. For an inheriting
candidate, fields declared by the family margin spec supply defaults and fields
declared by the individual margin spec override them. Both input files are
digest-checked. An explicit null margin disables confirmation.
obliteratus recipe confirm ./candidate.json \
--stock ./stock-checkpoint --model-id org/model --revision MODEL_REVISION \
--output-dir ./final-confirmations --accepted-by reviewer \
--record-dir ./obliteratus/recipes/data
You can also pass the recipe name. Names resolve in the supplied recipes data directory and then in the bundled registry. An HF cache snapshot path supplies its model ID and commit revision automatically. For a local copy, supply both identity flags and keep the stock checkpoint immutable. A family recipe can record a result for any member matching its configured predicates.
Confirmation runs a train-only edit in an isolated process, reloads and verifies
the edited checkpoint, then runs verify-edit on the built-in final test under
the resolved frozen spec. runs/<run-id>/confirmation.json records the
recipe and revision, resolved layers and margins, final-test identity, exit
codes, log and report digests, and verification outcome. The run directory
contains the referenced files. The CLI exits 0 for a pass, 1 for a failed
margin, 2 for input or execution errors, and 3 for incomplete verification.
Reuse the same output directory for all confirmations of a model. The
confirmation-ledger.json reserves the model ID, revision and full final-test
partition before any subprocess starts, including for runs that later fail or
are interrupted. Another attempt against that key requires an explicit
--reconfirm-reason, which the ledger and new record retain. The ledger
retains the paths of all attempts. The command also checks review records in
the bundled registry, beside the selected recipe, and in any supplied review
directory.
A passing individual candidate gets a new runs/<run-id>/recipe.json
with status: accepted, the reviewer and timestamp, and evidence linking the
record by digest. The original candidate stays intact. A passing family run
records one member for explicit family promotion. Review records are
optional and live in the checkout at
confirmations/<recipe>/<model-id-slug>@<revision>.json beneath
--record-dir. An explicit reconfirmation can update that review copy. Use
RecipeRegistry(data_dir).confirmations(recipe_name, model_id, revision) to
list the records, with either model filter optional.
Family and member promotion
Keep the family candidate, its frozen margins, and the published confirmations in a local recipes data directory. Confirm each member against the same candidate bytes and version. Then approve the candidate explicitly.
obliteratus recipe promote FAMILY --record-dir ./obliteratus/recipes/data \
--accepted-by REVIEWER
Two passing confirmations must name distinct model IDs and match every family predicate. A different layer count qualifies as a different size. At equal depth, both parameter estimates must be positive and the larger estimate must be at least 25% above the smaller estimate. Two revisions of one model provide one member. Older records without architecture metadata still load and can qualify for families whose match rules do not use architectures.
Promotion checks that each counted run used the frozen family edit and margins. A recorded member margin override can qualify when its digest-locked file is available inside the recipes directory and merging it with the family margins reproduces the recorded verification spec. The first qualifying pair in review path order supplies the acceptance evidence. A refusal lists the reason for each confirmation and exits 2.
The command updates the local family JSON with the reviewer, UTC timestamp,
and digest references. It saves exact copies of the original candidate and
counted confirmations under promotion-evidence/<family>/<sha256>.json.
Include the updated JSON and those evidence files in the review pull request.
The hidden .recipe-promotion.lock file coordinates local writers.
obliteratus recipe promote-member FAMILY --model-id ORG/MODEL \
--revision MODEL_REVISION --record-dir ./obliteratus/recipes/data \
--accepted-by REVIEWER
One passing confirmation of the unchanged family qualifies that exact model ID and revision for individual promotion, including while the family itself is a candidate. The new accepted recipe inherits the family edit and margins. When the confirmation used a recorded member override, the individual recipe pins that override. The command requires an unused individual model and revision binding. It saves the exact confirmation alongside the family promotion evidence.
RecipeRegistry(data_dir).is_confirmed_member(family, model_id, revision)
checks the exact member identity and current family. After acceptance it also
recognizes confirmations tied to the saved candidate as long as its family
declarations still match.