Files
OBLITERATUS/docs/MODEL_RECIPES.md
Joseph Magly cd8db6aeaa feat(recipes): resolve family recipes and inheritance
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
2026-11-19 11:56:22 -05:00

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

  • schema is obliteratus.model-recipe/v1. name is the registry key, version identifies the recipe revision, and optional inherits records a parent recipe name.
  • An individual recipe identifies stock weights through identity.model_id and identity.revision. Optional weights_sha256 and family record additional identity information. Individual recipes can use absolute zero-based placement or fractional placement.
  • A family recipe selects models through identity.match and uses fractional placement whenever it sets layer overrides.
  • edit.method names a pipeline preset. edit.overrides contains the recipe's explicit edit options, using the allow-list in obliteratus/recipes/schema/model-recipe.v1.schema.json.
  • margins is a recipe-relative spec_path and its spec_sha256. A candidate may use null. Each evidence entry supplies a kind, path, sha256 of the referenced bytes, and summary. The registry validates the references as data. Consumers can check the referenced bytes when using them.
  • status is candidate, accepted, or superseded. accepted_by and accepted_at may be null when the historical record lacks those details. notes carries 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_type is required. Supply a case-sensitive string or a list of allowed strings.
  • architectures is a list of architecture names. At least one name must appear in the profile's architectures sequence. The current profile_model() result has no architecture field. Supply an enriched profile for recipes that use this rule.
  • num_layers, total_params_b, and hidden_size each accept an inclusive range with both min and max. A missing profile value fails the rule.
  • model_id_patterns is a list of case-sensitive fnmatch globs 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:

  1. An accepted individual recipe for the exact model ID and revision.
  2. An inheriting individual recipe for that same binding. Candidate and superseded individuals at this step require include_candidates=True.
  3. An accepted family recipe that matches the profile.
  4. If include_candidates=True, an exact candidate or superseded individual or, failing that, a matching candidate or superseded family. Otherwise, or if neither matches, return None.

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.