ONNX export of NCM small models
Browse files- README.md +38 -0
- verification.json +3 -0
README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: onnx
|
| 4 |
+
base_model: hazyresearch/ncm-checkpoints
|
| 5 |
+
tags:
|
| 6 |
+
- onnx
|
| 7 |
+
- webgpu
|
| 8 |
+
- next-concept-modeling
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# NCM small models, ONNX for the browser
|
| 12 |
+
|
| 13 |
+
ONNX exports of a few of the small [Next-Concept Modeling](https://huggingface.co/papers/2610.14162)
|
| 14 |
+
checkpoints by Hazy Research ([hazyresearch/ncm-checkpoints](https://huggingface.co/hazyresearch/ncm-checkpoints),
|
| 15 |
+
code: [HazyResearch/ncm](https://github.com/HazyResearch/ncm), MIT). All credit for the models goes to the authors.
|
| 16 |
+
They are used by the in-browser demo at [mrfakename/ncm-webgpu](https://huggingface.co/spaces/mrfakename/ncm-webgpu).
|
| 17 |
+
|
| 18 |
+
| Folder | Source checkpoint |
|
| 19 |
+
| --- | --- |
|
| 20 |
+
| `tinystories/` | `tinystories` |
|
| 21 |
+
| `lm1b-small/` | `lm1b/small` |
|
| 22 |
+
| `sudoku-easy/`, `sudoku-medium/`, `sudoku-hard/` | `sudoku/{easy,medium,hard}` |
|
| 23 |
+
|
| 24 |
+
Each `model.onnx` (+ `model.onnx.data`, fp32) is one graph that runs the full coarse-to-fine
|
| 25 |
+
generation, every level unrolled with shared weights, followed by the VQ-VAE decoder read-out of each level.
|
| 26 |
+
|
| 27 |
+
- Inputs: `prefix` (int64, 1 x prefix_len). The sampled models also take `l0` (level-0 codes, drawn
|
| 28 |
+
from `level0_unigram.json`), `u` (one uniform in [0, 1) per generated code) and `temperature`.
|
| 29 |
+
Codes are drawn by inverse-CDF on `softmax(logits / temperature)`, which matches `torch.multinomial`
|
| 30 |
+
with the released `top_k=0, top_p=1` settings.
|
| 31 |
+
- Outputs: `codes`, all levels concatenated, plus the decoded tokens of every level.
|
| 32 |
+
For `lm1b-small` this is the top-128 logits per position, so the browser can run the released
|
| 33 |
+
frequency and adjacency penalties (`token_unigram.json`, `meta.json`).
|
| 34 |
+
- `meta.json` has the level sizes and special tokens. `fixtures.json` has reference inputs and outputs
|
| 35 |
+
from PyTorch. `verification.json` compares ONNX Runtime (CPU) with PyTorch.
|
| 36 |
+
|
| 37 |
+
Exported with `torch.onnx.export` (opset 17). Linear and area interpolation are rewritten as
|
| 38 |
+
constant matrix products, which is the same linear map.
|
verification.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"interp_matmul_max_abs_err": 2.384185791015625e-07
|
| 3 |
+
}
|