--- license: other language: - en - zh - ru - ja - ar - multilingual tags: - imatrix - quantization - calibration - gguf - deepseek-v4 - three.js - webgl task_categories: - text-generation --- # calib-corpora — imatrix calibration corpus for DeepSeek-V4-Flash-0731 Calibration text for building the importance matrix (imatrix) behind the dynamic GGUF quant line of [`deepseek-ai/DeepSeek-V4-Flash-0731`](https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash-0731). An imatrix is activation statistics collected by running the model over a corpus. The corpus decides which weights the model treats as important, and therefore which weights get more bits. **This corpus is deliberately not general web text** — it is weighted toward 3D/graphics code generation and agentic tool-calling, because that is what these quants are for. ## Why this composition Three properties of this model drive the design, all confirmed against its `config.json`: | property | value | consequence for calibration | |---|---|---| | `n_routed_experts` / `num_experts_per_tok` | 256 / 6 | Any single expert sees ~2.3% of tokens. A dense-model-sized corpus gives most experts too few samples to be meaningful, so the budget has to be an order of magnitude larger. | | `num_hash_layers` | 3 | In the first three MoE layers the expert is chosen by a fixed hash of the **token id**, not by a learned gate. Coverage there depends on *vocabulary breadth*, not on volume — an unseen token id means a never-activated expert, no matter how much text you feed it. | | `compress_ratios` | alternating 4/128 over 43 layers | The CSA/HCA compression path is barely exercised by short chunks, so a real long-document slice is required rather than concatenated short ones. | The vocabulary is the binding constraint. It has 129,280 embedding rows, and by script the base vocabulary is 56.1% Latin, 27.6% CJK, 4.1% Cyrillic, 2.4% Arabic, 1.0% Thai, 0.9% Hangul, 0.7% Hebrew, 0.5% Greek, 0.4% Hiragana, 0.2% Devanagari. **Covering every Latin token in the vocabulary would still only reach 55.5%** of the embedding table, so a 60% coverage target is unreachable from English source code alone. That is why there is a 30-language Wikipedia slice and an explicit vocabulary sweep. ## Files | file | documents | tokens | purpose | |---|---:|---:|---| | `calib_train.txt` | 1,087 | 1,868,626 | fed to `llama-imatrix` | | `calib_heldout.txt` | 104 | 141,800 | same distribution, **not** used for the imatrix — for measuring generalisation | | `eval_neutral.txt` | 66 | 189,407 | disjoint neutral text and code, no overlap with calibration | Each `.txt` is flat UTF-8 with documents separated by a blank line, sharded at 500 MB (the corpus fits in one shard per split). Alongside each is a `*.manifest.jsonl` giving one record per document — id, domain, source, license, path, language, token count, character count — in the same order the documents appear in the `.txt`. The manifest exists because the flat format cannot express document boundaries unambiguously: many documents legitimately contain blank lines of their own. `legacy/` holds the previous revision of this dataset verbatim. Its content was re-split, deduplicated against the new material and carried forward into the build rather than discarded. ## Composition Shares are of **tokens**, not documents, over `calib_train` + `calib_heldout` (2,010,426 tokens). | domain | target | actual | documents | tokens | what it is | |---|---:|---:|---:|---:|---| | `graphics` | 35% | 31.4% | 448 | 631,310 | three.js scenes/materials/loaders/post-processing, WebGL & WebGPU, GLSL & WGSL shaders, animation timelines, procedural generation, 3D maths | | `code` | 15% | 13.4% | 243 | 270,098 | whole real source files — TypeScript, JavaScript, Python, Rust, C++ — plus configs, tests and build scripts | | `agentic` | 15% | 13.4% | 63 | 270,012 | multi-turn tool-calling traces in the model's own DSML chat format: read/edit files, run commands, read output, recover from a failure | | `longctx` | 10% | 13.4% | 18 | 268,568 | documents of 8k tokens and up (large real files, plus same-directory module bundles built to 8k-16k) to exercise the CSA/HCA compression path | | `vocab_sweep` | — | 9.0% | 76 | 180,582 | synthetic wordlists that carry the tail of the vocabulary; exists purely to cover the hash-routed layers | | `general` | 10% | 9.0% | 36 | 180,045 | multilingual Wikipedia across 30 languages, plus markdown/tables/unicode from the previous revision | | `reasoning` | 10% | 5.9% | 189 | 117,682 | step-by-step worked problems with reasoning kept inside `` blocks: 3D maths, numerics, algorithms, graphics debugging | | `structured` | 5% | 4.6% | 118 | 92,129 | JSON, YAML, TOML and SQL from the repositories, real `git log -p` diff patches, and the most regex-dense real sources | **Deviations from target are reported, not corrected.** Notes on the ones that matter: - `longctx` is defined by *length*, not by topic: any document of 8k tokens or more is counted here whatever its subject. Most of it is graphics code, so the effective graphics share is higher than the `graphics` row alone suggests. The origin breakdown is in the manifest under `content_domain`. - `vocab_sweep` is over and above the seven requested domains. It is synthetic and is kept as its own domain so it can be filtered out via the manifest by anyone who wants to A/B an imatrix without it. ### Sources and licences | source | licence | documents | tokens | share | |---|---|---:|---:|---:| | `synthetic/vocab-sweep` | CC0-1.0 (generated from tokenizer vocabulary) | 76 | 180,582 | 9.0% | | `fmt` | MIT | 43 | 133,281 | 6.6% | | `three.js` | MIT | 67 | 132,759 | 6.6% | | `webgl-fundamentals` | BSD-3-Clause | 61 | 123,355 | 6.1% | | `pixijs` | MIT | 68 | 99,406 | 4.9% | | `gl-matrix` | MIT | 39 | 93,756 | 4.7% | | `ripgrep` | MIT OR Unlicense | 41 | 86,938 | 4.3% | | `drei` | MIT | 64 | 79,436 | 4.0% | | `json-cpp` | MIT | 43 | 71,097 | 3.5% | | `react-three-fiber` | MIT | 66 | 69,393 | 3.5% | | `flask` | BSD-3-Clause | 41 | 60,905 | 3.0% | | `tween.js` | MIT | 51 | 59,526 | 3.0% | | `webgl-noise` | MIT | 22 | 58,134 | 2.9% | | `webgpu-samples` | BSD-3-Clause | 61 | 57,655 | 2.9% | | `requests` | Apache-2.0 | 40 | 40,938 | 2.0% | | `serde` | MIT OR Apache-2.0 | 37 | 37,921 | 1.9% | | `synthetic/agentic:webgl-fundamentals` | see embedded repo (tool results are verbatim repo content) | 6 | 32,919 | 1.6% | | `synthetic/agentic:flask` | see embedded repo (tool results are verbatim repo content) | 6 | 31,883 | 1.6% | | `synthetic/agentic:ripgrep` | see embedded repo (tool results are verbatim repo content) | 6 | 31,681 | 1.6% | | `synthetic/agentic:pixijs` | see embedded repo (tool results are verbatim repo content) | 6 | 27,468 | 1.4% | | `glTF-Sample-Viewer` | Apache-2.0 | 11 | 26,894 | 1.3% | | `vite` | MIT | 42 | 25,248 | 1.3% | | `synthetic/agentic:json-cpp` | see embedded repo (tool results are verbatim repo content) | 5 | 24,818 | 1.2% | | `synthetic/agentic:requests` | see embedded repo (tool results are verbatim repo content) | 5 | 22,881 | 1.1% | | `synthetic/agentic:drei` | see embedded repo (tool results are verbatim repo content) | 6 | 22,271 | 1.1% | | `wikimedia/wikipedia:20231101.el` | CC-BY-SA-4.0 | 2 | 21,861 | 1.1% | | `synthetic/agentic:three.js` | see embedded repo (tool results are verbatim repo content) | 6 | 21,359 | 1.1% | | `wikimedia/wikipedia:20231101.uk` | CC-BY-SA-4.0 | 2 | 20,333 | 1.0% | | `synthetic/agentic:webgpu-samples` | see embedded repo (tool results are verbatim repo content) | 6 | 18,563 | 0.9% | | `synthetic/agentic:react-three-fiber` | see embedded repo (tool results are verbatim repo content) | 6 | 18,458 | 0.9% | | `synthetic/agentic:vite` | see embedded repo (tool results are verbatim repo content) | 5 | 17,711 | 0.9% | | `wikimedia/wikipedia:20231101.my` | CC-BY-SA-4.0 | 1 | 16,783 | 0.8% | | `wikimedia/wikipedia:20231101.hi` | CC-BY-SA-4.0 | 1 | 14,126 | 0.7% | | `synthetic/reasoning:perlin-noise` | CC0-1.0 (generated) | 15 | 11,671 | 0.6% | | `synthetic/reasoning:bezier-decasteljau` | CC0-1.0 (generated) | 15 | 10,664 | 0.5% | | `wikimedia/wikipedia:20231101.fa` | CC-BY-SA-4.0 | 1 | 9,997 | 0.5% | | `synthetic/reasoning:cubic-bezier-easing` | CC0-1.0 (generated) | 15 | 9,960 | 0.5% | | `synthetic/reasoning:quaternion-product` | CC0-1.0 (generated) | 15 | 9,861 | 0.5% | | `synthetic/reasoning:moller-trumbore` | CC0-1.0 (generated) | 18 | 9,215 | 0.5% | | `wikimedia/wikipedia:20231101.ar` | CC-BY-SA-4.0 | 1 | 9,073 | 0.5% | | `synthetic/reasoning:normal-matrix` | CC0-1.0 (generated) | 12 | 8,417 | 0.4% | | `synthetic/reasoning:catmull-rom` | CC0-1.0 (generated) | 11 | 8,342 | 0.4% | | `wikimedia/wikipedia:20231101.bn` | CC-BY-SA-4.0 | 1 | 8,067 | 0.4% | | `synthetic/reasoning:quaternion-slerp` | CC0-1.0 (generated) | 15 | 7,872 | 0.4% | | `synthetic/reasoning:srgb-linear` | CC0-1.0 (generated) | 12 | 7,396 | 0.4% | | `wikimedia/wikipedia:20231101.ta` | CC-BY-SA-4.0 | 2 | 7,363 | 0.4% | | `synthetic/reasoning:rodrigues-rotation` | CC0-1.0 (generated) | 12 | 7,321 | 0.4% | | `synthetic/reasoning:look-at-basis` | CC0-1.0 (generated) | 12 | 7,042 | 0.4% | | `wikimedia/wikipedia:20231101.fr` | CC-BY-SA-4.0 | 1 | 6,784 | 0.3% | | `wikimedia/wikipedia:20231101.th` | CC-BY-SA-4.0 | 2 | 6,242 | 0.3% | | `synthetic/reasoning:perspective-projection` | CC0-1.0 (generated) | 11 | 6,171 | 0.3% | | `wikimedia/wikipedia:20231101.es` | CC-BY-SA-4.0 | 1 | 5,974 | 0.3% | | `wikimedia/wikipedia:20231101.nl` | CC-BY-SA-4.0 | 1 | 5,970 | 0.3% | | `wikimedia/wikipedia:20231101.id` | CC-BY-SA-4.0 | 1 | 5,649 | 0.3% | | `wikimedia/wikipedia:20231101.am` | CC-BY-SA-4.0 | 1 | 5,621 | 0.3% | | `AtomicChat/calib-corpora@previous` | CC-BY-SA-4.0 (StackOverflow-derived) / mixed | 31 | 5,600 | 0.3% | | `synthetic/reasoning:fresnel-schlick` | CC0-1.0 (generated) | 10 | 4,962 | 0.2% | | `wikimedia/wikipedia:20231101.en` | CC-BY-SA-4.0 | 1 | 4,735 | 0.2% | | `wikimedia/wikipedia:20231101.vi` | CC-BY-SA-4.0 | 1 | 4,468 | 0.2% | | `wikimedia/wikipedia:20231101.cs` | CC-BY-SA-4.0 | 1 | 4,467 | 0.2% | | `wikimedia/wikipedia:20231101.pt` | CC-BY-SA-4.0 | 1 | 3,217 | 0.2% | | `wikimedia/wikipedia:20231101.he` | CC-BY-SA-4.0 | 1 | 3,099 | 0.2% | | `wikimedia/wikipedia:20231101.ja` | CC-BY-SA-4.0 | 1 | 3,089 | 0.2% | | `wikimedia/wikipedia:20231101.tr` | CC-BY-SA-4.0 | 2 | 2,885 | 0.1% | | `wikimedia/wikipedia:20231101.hy` | CC-BY-SA-4.0 | 1 | 2,793 | 0.1% | | `synthetic/reasoning:instancing-vs-merging` | CC0-1.0 (generated) | 3 | 1,865 | 0.1% | | `wikimedia/wikipedia:20231101.ko` | CC-BY-SA-4.0 | 1 | 1,739 | 0.1% | | `synthetic/reasoning:debug-zfighting` | CC0-1.0 (generated) | 2 | 1,483 | 0.1% | | `wikimedia/wikipedia:20231101.pl` | CC-BY-SA-4.0 | 1 | 1,269 | 0.1% | | `synthetic/reasoning:ray-sphere` | CC0-1.0 (generated) | 4 | 1,127 | 0.1% | | `synthetic/reasoning:transparency-sorting` | CC0-1.0 (generated) | 2 | 1,122 | 0.1% | | `wikimedia/wikipedia:20231101.de` | CC-BY-SA-4.0 | 1 | 1,073 | 0.1% | | `synthetic/reasoning:debug-shader-black` | CC0-1.0 (generated) | 1 | 839 | 0.0% | | `wikimedia/wikipedia:20231101.ka` | CC-BY-SA-4.0 | 1 | 831 | 0.0% | | `wikimedia/wikipedia:20231101.ru` | CC-BY-SA-4.0 | 1 | 799 | 0.0% | | `synthetic/reasoning:bvh-complexity` | CC0-1.0 (generated) | 1 | 678 | 0.0% | | `synthetic/reasoning:float32-world-precision` | CC0-1.0 (generated) | 1 | 591 | 0.0% | | `wikimedia/wikipedia:20231101.sv` | CC-BY-SA-4.0 | 1 | 579 | 0.0% | | `synthetic/reasoning:gpu-resource-disposal` | CC0-1.0 (generated) | 1 | 565 | 0.0% | | `wikimedia/wikipedia:20231101.zh` | CC-BY-SA-4.0 | 1 | 565 | 0.0% | | `synthetic/reasoning:raycaster-stale-matrix` | CC0-1.0 (generated) | 1 | 518 | 0.0% | | `wikimedia/wikipedia:20231101.it` | CC-BY-SA-4.0 | 1 | 457 | 0.0% | Every repository was shallow-cloned and had its `LICENSE` file read before use. **`patriciogonzalezvivo/thebookofshaders` was cloned, inspected and dropped**: its licence is all-rights-reserved (*"You cannot host, display, distribute or share this Work in any form"*), so none of it appears here despite being an obvious fit for the domain. Synthetic slices (`synthetic/agentic:*`, `synthetic/reasoning:*`, `synthetic/vocab-sweep`) are generated by the build scripts in `pipeline/`. The agentic traces embed **verbatim file content from the listed repositories** as tool results, so they inherit those repositories' licences; the surrounding dialogue is generated. See [Synthetic slices](#synthetic-slices). ## Tokenizer - Model: [`deepseek-ai/DeepSeek-V4-Flash-0731`](https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash-0731) - Revision: `9e165c30e2704aec5d9d593cce3eebd58bbef1cb` - `vocab_size`: 129,280 (from `config.json`; this is the denominator for all coverage numbers below — it is the size of the embedding table, and therefore the domain the layer-0-2 hash router indexes into) Counting is done with special tokens **parsed, not escaped** — the equivalent of `llama-imatrix --parse-special`. `<|begin▁of▁sentence|>` becomes id 0 rather than a run of literal characters. This matters for the agentic and reasoning slices, which are full of them. > **The model ships no `chat_template`.** `tokenizer_config.json` has no such field and there is no `chat_template.jinja` in the repo, so `apply_chat_template()` does not work. The authoritative prompt format is the reference implementation at `encoding/encoding_dsv4.py` in the model repo, and this build imports it directly rather than reimplementing it. Its own test suite (`encoding/test_encoding_dsv4.py`, 4 cases) passes against the pinned revision, and all chat-formatted documents here are produced by `encode_messages(...)` from that file. ## Deduplication - **Exact:** SHA-256 over the document with trailing intra-line whitespace normalised. 59 documents removed. - **Near:** MinHash + LSH banding. 121 permutations, 11 bands × 11 rows, shingles of 5 whitespace-delimited tokens. **Jaccard threshold 0.8** — the banding is chosen so the LSH S-curve is centred there ((1/11)^(1/11) ≈ 0.80). Longest document in each cluster is kept. 565 documents removed. - **Combined drop rate: 5.09%** of 12,262 candidate documents. Two structural steps prevent duplication that document-level dedup cannot see: - three.js and webgl-fundamentals ship thousands of example pages sharing an identical ~600-byte HTML head. Bodies genuinely differ, so MinHash does not flag them. For most example pages only the `