Datasets:
|
Download RECIPE.md from AtomicChat/calib-corpora: direct link, hf CLI and curl.
- Browser
- Download file 15.9 kB
-
https://huggingface.co/datasets/AtomicChat/calib-corpora/resolve/main/RECIPE.md
- Command line
-
hf download hf://datasets/AtomicChat/calib-corpora/RECIPE.md
-
curl -L -o RECIPE.md https://huggingface.co/datasets/AtomicChat/calib-corpora/resolve/main/RECIPE.md
15.9 kB
| # The recipe format | |
| A recipe is the complete description of one calibration build. It is the only | |
| file you write by hand. Everything else in `builds/` is generated. | |
| `tools/build.py` is the only program that reads it. `foundry.sh` greps two | |
| values out of it (`name` and `chat.pin_date`) and never parses the rest. | |
| Every field below says who reads it, what happens if it is missing, and what | |
| changes when you change it. Fields marked NOT READ are documentation for humans | |
| and have no effect on the build. | |
| --- | |
| ## Top level | |
| ### `name` (string, required) | |
| ```yaml | |
| name: qwen3.8-27b | |
| ``` | |
| Does three things, and the third is the one that bites: | |
| 1. The build lands in `builds/<name>/`. | |
| 2. It goes into `manifest.json` as `build`. | |
| 3. **It selects the vocabulary sweep.** `build.py` looks for | |
| `pool/vocab_sweep/synthetic/<name>.jsonl` and drops every other file under | |
| `pool/vocab_sweep/synthetic/`. A sweep built for another tokenizer is not | |
| neutral filler, it is a few hundred thousand tokens of ids this model does | |
| not have. | |
| If that file does not exist, the build does not fail. The `vocab_sweep` category | |
| simply comes up empty and the corpus silently loses that share. Run | |
| `vocab_sweep.py --name <name>` with the same string before building, and check | |
| the build log line that reports the sweep. | |
| Use lowercase, digits, dots and hyphens. It becomes a directory name and a | |
| filename. | |
| ### `seed` (integer, optional, default 0) | |
| ```yaml | |
| seed: 20260814 | |
| ``` | |
| Seeds every shuffle in the build. Same pool plus same recipe plus same seed | |
| gives byte-identical output. Change it and you get a different sample of the | |
| same pool, which is a legitimate thing to want when checking that a result is | |
| not an artefact of one particular draw. | |
| Any integer. The convention here is the build date as `YYYYMMDD`, which makes it | |
| obvious at a glance when two recipes were derived from each other. | |
| Note that `seed + sum(ord(c) for c in category)` is used per category, so | |
| changing the seed reshuffles every category independently rather than rotating | |
| one shared order. | |
| --- | |
| ## `model` | |
| Almost everything here is recorded into the manifest and never acted on. Only | |
| two fields change the build. | |
| ### `model.tokenizer` (path, required, ACTS) | |
| ```yaml | |
| tokenizer: /src/tokenizer.json | |
| ``` | |
| Absolute path on the machine running the build, to the `tokenizer.json` from the | |
| original weights. Used to count tokens so the budgets are hit, and hashed into | |
| the manifest. | |
| This is why `foundry.sh` sets `FOUNDRY_MODEL_DIR=/src` and why `build_corpus` | |
| refuses to start without `/src/tokenizer.json`. | |
| Do not point this at another model's tokenizer to "get roughly the right size". | |
| The budgets would be wrong and the manifest would record a hash that does not | |
| match anything. | |
| ### `model.vocab_size` (integer, ACTS) | |
| ```yaml | |
| vocab_size: 248320 | |
| ``` | |
| Passed to the tokenizer wrapper as `n_vocab`. Read it out of `config.json`, do | |
| not type it from memory. `make_recipe` reads it off the hub for you. | |
| ### `model.pre_tokenizer` (string, optional, default `llama4`, RECORDED ONLY) | |
| Goes into the manifest so a reader knows which splitting rules applied. Does not | |
| change anything. Values seen so far: `llama4`, `tekken`. | |
| ### `model.llama_cpp_commit` (string, RECORDED ONLY) | |
| The short commit hash of the llama.cpp build that will run the imatrix. There is | |
| no mechanism that fills this in. `make_recipe` writes the placeholder | |
| `FILLED_AT_BUILD_TIME` and nothing replaces it, so it has been shipping | |
| literally into manifests. Either put a real hash there by hand before building, | |
| or write `UNRECORDED` and be honest about it. | |
| ### `model.repo`, `model.gguf`, `model.layers`, `model.sliding_window`, `model.context_length` (RECORDED ONLY) | |
| Copied verbatim into the manifest. They exist so that a reader can see the | |
| architecture facts that justified the shares below without opening the model's | |
| config. | |
| `sliding_window: null` means the model has no attention window, which is the | |
| usual argument for a larger `longctx` share. Write `null`, not `0` and not the | |
| empty string. | |
| --- | |
| ## `chat` | |
| ### `chat.format` (string, optional, default `glimmer`, ACTS) | |
| ```yaml | |
| format: auto | |
| ``` | |
| Selects the renderer that turns a pool dialogue record into the exact byte | |
| string the model sees. Looked up in the `FORMATTERS` dictionary at the top of | |
| `tools/build.py`. An unknown value stops the build immediately with | |
| `unknown chat.format`. | |
| Available: | |
| | value | module | when | | |
| | ---------- | ----------------- | -------------------------------------------------------------------------- | | |
| | `auto` | `auto_fmt.py` | any model whose own chat template `transformers` can render. **Use this.** | | |
| | `glimmer` | `glimmer_fmt.py` | Muse Glimmer. Hand-written, kept because it is what that build used | | |
| | `nemotron` | `nemotron_fmt.py` | Nemotron. Superseded by `auto`, which does the same thing without the name | | |
| The default is `glimmer`, which is wrong for every model except one. Always | |
| write this field explicitly. | |
| `auto` needs the original weights on disk. Point it at them: | |
| ```bash | |
| export FOUNDRY_MODEL_DIR=/src | |
| ``` | |
| If that directory has no chat template, `auto` refuses to render rather than | |
| quietly producing a corpus with no markup in it. | |
| ### `chat.add_bos_per_document` (boolean, optional, **default true**, ACTS) | |
| ```yaml | |
| add_bos_per_document: false | |
| ``` | |
| Whether every rendered dialogue gets the beginning-of-sequence token prepended. | |
| **The default is `true` and that is wrong for most models.** Always write it | |
| explicitly. The correct value is `add_bos_token` from the model's | |
| `tokenizer_config.json`, unless the chat template already emits BOS itself, in | |
| which case write `false` or you get two. | |
| Getting this wrong is not fatal but it puts an extra token at the start of every | |
| document, which shifts the statistics for the embedding row of that token by a | |
| few thousand occurrences. | |
| ### `chat.pin_date` (string, read by `foundry.sh`, not by `build.py`) | |
| ```yaml | |
| pin_date: '2026-08-14' | |
| ``` | |
| Only needed when the model's chat template calls `strftime_now`, meaning it puts | |
| today's date into every rendered conversation. Without a pin, two builds a week | |
| apart differ and neither is reproducible. | |
| `build_corpus` in `foundry.sh` greps this value and exports it as | |
| `FOUNDRY_PIN_DATE`, which `auto_fmt.py` reads. `auto_fmt.py` refuses to render | |
| at all if the template needs a date and none is pinned, so a missing pin is a | |
| loud failure rather than a silent one. | |
| Omit the field entirely when the template takes no date. `make_recipe` detects | |
| this and writes the field only when needed. | |
| ### `chat.current_date` (optional, ACTS in two places) | |
| Passed to the renderer, and also written into the manifest as `built_at`. When | |
| it is absent, `built_at` is `null`, which is why the Qwen manifest has no build | |
| date. If you want a date in the manifest, set this. | |
| ### `chat.knowledge_cutoff` (optional, ACTS) | |
| Passed to the renderer. Only `glimmer_fmt` does anything with it. Leave it out | |
| for `auto`. | |
| --- | |
| ## `calib_train` | |
| The main corpus. Required. | |
| ### `target_tokens` (integer, required) | |
| ```yaml | |
| target_tokens: 5000000 | |
| ``` | |
| How many tokens the build aims for. It is a target, not a guarantee: if a | |
| category's pool is exhausted the build reports it and comes up short. | |
| How to choose it. The imatrix estimates an average, so accuracy grows with the | |
| square root of the number of observations, and cost grows linearly. Two limits | |
| matter: | |
| **Convergence.** Past a certain size, more of the same text stops moving the | |
| importance vector. Measured on `nemotron-3.5-lightning` that point is about | |
| 8,500 chunks, roughly 4.3M tokens, at which zero of 186 tensors still change | |
| measurably. `tools/converge.py` finds it for any model. This is why 5M is the | |
| standing figure. | |
| **Experts.** On a mixture-of-experts model, an expert only accumulates | |
| statistics on the tokens routed to it. With `k` experts active out of `N`: | |
| ``` | |
| tokens per expert ~= target_tokens * k / N | |
| ``` | |
| For 6 of 256 at 5M tokens that is about 117k per expert. For 6 of 256 at 1.87M, | |
| which is what the DeepSeek build used, it is about 44k. Compute this for your | |
| model before accepting 5M, and check the `counts` array in the finished imatrix | |
| for experts that were never routed to at all. | |
| Range in practice: 2M is thin, 5M is the current standard, above 10M is paying | |
| for convergence you already have. | |
| ### `shares` (map of category to number, required) | |
| ```yaml | |
| shares: | |
| agentic: 25 | |
| code: 18 | |
| reasoning: 15 | |
| multilingual: 14 | |
| longctx: 12 | |
| vocab_sweep: 10 | |
| structured: 5 | |
| graphics: 3 | |
| ``` | |
| The composition of the corpus, and the only real judgement call in the file. No | |
| config file knows what a model is for. | |
| **These are weights, not percentages.** `build.py` divides each by their sum, so | |
| `25` out of a total of `102` becomes 24.51% in the manifest. The numbers above | |
| sum to 102, which is why the Qwen manifest reports 24.51 and not 25. Nothing | |
| breaks, but the comment beside them lies. Make them sum to 100 or say in the | |
| comment that they are weights. | |
| Category names must match directory names under `pool/`. A category with no | |
| matching directory silently contributes nothing. | |
| Available categories: `agentic`, `code`, `graphics`, `longctx`, `multilingual`, | |
| `reasoning`, `structured`, `vocab_sweep`. | |
| How to set them, in order of how much thought each deserves: | |
| **`agentic`** typically 20 to 30. Tool-call markup is a small, dense token set | |
| that natural text never emits. Without real weight the imatrix has no statistics | |
| for it at all. Raise it when the model is positioned for agents. | |
| **`code`** typically 15 to 25. Almost every agentic benchmark is code-shaped, so | |
| this and `agentic` move together. | |
| **`reasoning`** 10 when the thinking channel is opt-in, 15 when it is on by | |
| default. Check the chat template for `enable_thinking` or `<think>`. | |
| **`multilingual`** 10 to 15. This is the only thing that exercises non-Latin | |
| embedding rows in real text rather than as isolated ids. Raise it for a model | |
| that claims multilingual coverage. | |
| **`longctx`** 10 to 12. Raise it to 12 when `sliding_window` is `null`, because | |
| then nothing but a long document exercises long-range behaviour. Lower it to 10 | |
| when a window exists, since short documents already fill the window. | |
| **`vocab_sweep`** 8 to 10. Synthetic word lists whose only job is to make every | |
| token id appear at least once. Worth the most on an architecture that routes by | |
| token id, worth re-examining elsewhere: on a model without hash-routed layers | |
| the original justification does not carry over, and 10% is a lot of corpus to | |
| spend on inertia. | |
| **`structured`** 5. JSON, YAML, TOML and SQL, both as files and inside assistant | |
| turns. The pool for this is thin, so it tends to come up short of its target. | |
| **`graphics`** 3 unless the model is specifically for it. The DeepSeek build ran | |
| it at 32 because that was the deployment target. | |
| ### `max_doc_fraction` (map, optional, default 0.05) | |
| ```yaml | |
| max_doc_fraction: | |
| default: 0.05 | |
| longctx: 0.12 | |
| ``` | |
| The largest share of one category's budget that a single document may take. A | |
| document over the cap is skipped entirely, not truncated, and the build prints | |
| the ones it skipped. | |
| This is not optional in practice. Uncapped, one amalgamated header file took | |
| 59.8% of a slice, and the imatrix then describes that one file rather than the | |
| category. | |
| `default` applies to every category not named. Override per category by adding | |
| the category name as a key. `longctx` needs a higher cap because a long document | |
| is the entire point of that slice, and at 0.05 of a 600k budget nothing over 30k | |
| tokens would ever fit. | |
| Range: 0.02 to 0.05 for ordinary categories, 0.10 to 0.15 for `longctx`. Above | |
| 0.20 you are no longer capping anything. | |
| --- | |
| ## `calib_longctx` (optional block) | |
| A second, separate corpus of unbroken long documents. Written to | |
| `calib_longctx.txt` with its own manifest. Omit the block entirely and no such | |
| file is produced. | |
| ```yaml | |
| calib_longctx: | |
| target_tokens: 750000 | |
| doc_tokens_min: 16384 | |
| doc_tokens_max: 32768 | |
| sources: [longctx] | |
| ``` | |
| **`target_tokens`** how large this corpus should be. 750k is the standing value. | |
| It is small on purpose: this is a supplement, not a second calibration. | |
| **`doc_tokens_min`** documents shorter than this are skipped. Set it above the | |
| context length you will actually run, or the documents do not exercise anything | |
| the main corpus does not. | |
| **`doc_tokens_max`** documents longer than this are cut down to it, on a line | |
| boundary, keeping a contiguous prefix. Set it to about the largest context you | |
| are willing to run the imatrix at. | |
| **`sources`** which pool categories to draw from. Defaults to `[longctx]`. | |
| Documents already used in `calib_train` are excluded automatically, so the two | |
| files never share a document. | |
| Run this as a second imatrix pass at a large context, then merge the two with | |
| `llama-imatrix --in-file a,b`. Merging is a sum of squared activations, so the | |
| result is the same as one long run. | |
| --- | |
| ## `pool` (optional block) | |
| ```yaml | |
| pool: | |
| shard_deny: | |
| - legacy-dsv4 | |
| ``` | |
| `shard_deny` is a list of substrings. Any pool file whose path contains one of | |
| them is dropped before sampling. The escape hatch for material that is | |
| model-specific in a way the per-record fields do not capture. | |
| The vocabulary sweep is already handled automatically by `name`, so it does not | |
| need to be listed here. | |
| --- | |
| ## `exclude` (NOT READ) | |
| ```yaml | |
| exclude: | |
| render: [dsv4, nemotron, muse-glimmer] | |
| provenance_key: excluded_from_builds | |
| ``` | |
| **This block currently has no effect.** `build.py` decides what to skip in its | |
| `usable()` function, which hardcodes `render == "dsv4"` and checks | |
| `provenance.excluded_from_builds`. It never opens `recipe["exclude"]`. | |
| So a recipe listing three renderers excludes exactly one of them. Today nothing | |
| breaks, because `dsv4` is the only value that appears in the pool, but the | |
| config says something untrue and will bite the first time another pre-rendered | |
| set is added. | |
| Either wire it up in `usable()` or delete the block. Do not leave configuration | |
| that looks live and is not. | |
| --- | |
| ## `notes` (NOT READ) | |
| Free-form documentation carried alongside the recipe. Nothing parses it. This is | |
| the right place for the things a person needs to know and no program checks: | |
| conversion flags, tensors that collect no statistics, shapes that do not divide | |
| by 256, which types survive on the expert tensors. | |
| Write them here rather than in a chat message. Six months later the recipe is | |
| still in the repository and the message is not. | |
| --- | |
| ## Writing one from scratch | |
| The fast path generates most of it: | |
| ```bash | |
| make_recipe <name> <upstream-repo> | |
| ``` | |
| That reads `config.json`, `tokenizer_config.json` and the chat template off the | |
| hub and fills in everything under `model:` plus `add_bos_per_document` and | |
| `pin_date`. It also checks whether the shapes divide by 256, which decides which | |
| quantization types are even available later. | |
| What it cannot do for you: the shares. Those are a claim about what the model is | |
| for. Read them once, adjust them against the model card, and write down why in | |
| the comment. That comment is the only record of the reasoning. | |
| Before building: | |
| ```bash | |
| corpus_check <upstream-repo> # does the template render, are the markers | |
| # real special tokens | |
| python tools/vocab_sweep.py --tokenizer /src/tokenizer.json --name <name> | |
| ``` | |
| After building, check three numbers in the log and the manifest: | |
| 1. `shares_actual_percent` against `shares_requested_percent`. A gap over a | |
| percentage point means a category's pool is exhausted. | |
| 2. The count of documents skipped over the cap. A large number means | |
| `max_doc_fraction` is too tight for that category's material. | |
| 3. Vocabulary coverage from `tools/coverage.py`. Below about 60% means the sweep | |
| did not run or did not match. | |