Family recipes match models by config fields read without loading weights (model_type, architectures, layer/parameter/hidden-size ranges, model-id globs) and express placement relative to depth: layer windows and extraction layers as fractions, resolved to absolute indices per model by a documented rule. Individual recipes may inherit from a family recipe; resolution merges per field and records provenance and the resolved layers. RecipeRegistry.resolve applies the order: accepted exact individual, individual inheriting from a family, accepted family match, none; two matching accepted families are an error naming both. Adds a candidate Llama 3 Instruct family seed resting on one member. Fixes #546
5.6 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. Pipeline application is tracked in #541.