tarekziade HF Staff commited on
Commit
ad271a3
·
verified ·
1 Parent(s): c538f33

MIC SmolLM-integration (files_sha256 ec9749992669)

Browse files
README.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - mic
4
+ - test-artifact
5
+ base_model:
6
+ - HuggingFaceTB/SmolLM-135M
7
+ - HuggingFaceTB/SmolLM-360M
8
+ - HuggingFaceTB/SmolLM-1.7B
9
+ ---
10
+
11
+ # MIC: SmolLM text generation
12
+
13
+ Model integration contract for one usage path, batched greedy generation, across the SmolLM checkpoints that share it. The proposed owner is Hugging Face; frameworks pin this repository by revision. The model repositories are unchanged. This repository holds the contract code and the manifest; each framework keeps its own expected results. It is a test artifact, not a model: exclude it from model search.
14
+
15
+ For agent reuse, the real model must link to this contract or expose a lookup, together with a last-passing environment and the reviewed baseline's location. A contract hidden from model search still needs to be discoverable from its covered checkpoints. A fixture pass and a real-checkpoint pass have different scopes; either establishes agreement on fixed inputs and a recorded runtime, not correctness on arbitrary prompts.
16
+
17
+ | File | What it is |
18
+ | --- | --- |
19
+ | [`integration.json`](integration.json) | Manifest: checkpoints, which fixture covers each, frameworks, entry points, variants, unsupported targets, comparison rules |
20
+ | [`integrations/transformers/usage.md`](integrations/transformers/usage.md) | Transformers contract, written as doc-builder runnable markdown: the same blocks are documentation and test |
21
+ | [`integrations/transformers.js/integration.js`](integrations/transformers.js/integration.js) | Transformers.js contract on the `onnx-community` conversions; inference only |
22
+
23
+ | Checkpoint | Slim fixture (every framework PR) | Transformers.js artifact |
24
+ | --- | --- | --- |
25
+ | `HuggingFaceTB/SmolLM-135M` | [`hf-internal-testing/proto-SmolLM-slim`](https://huggingface.co/hf-internal-testing/proto-SmolLM-slim) | `onnx-community/SmolLM-135M-ONNX` |
26
+ | `HuggingFaceTB/SmolLM-360M` | [`hf-internal-testing/proto-SmolLM-slim`](https://huggingface.co/hf-internal-testing/proto-SmolLM-slim) | `onnx-community/SmolLM-360M-ONNX` |
27
+ | `HuggingFaceTB/SmolLM-1.7B` | [`hf-internal-testing/proto-SmolLM-1.7B-slim`](https://huggingface.co/hf-internal-testing/proto-SmolLM-1.7B-slim) | unsupported: no `onnx-community` conversion |
28
+
29
+ 135M and 360M share one fixture because they have the same fixture key: byte-identical processor files and the same config wherever shrinking keeps it. 1.7B ships a different `tokenizer.json` and `tokenizer_config.json` and uses full multi-head attention, so it gets its own fixture.
integration.json ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "mic": "0.2",
3
+ "name": "SmolLM text generation",
4
+ "usage": "AutoTokenizer + AutoModelForCausalLM.generate, batched, left padding",
5
+ "architecture": "LlamaForCausalLM",
6
+ "checkpoints": {
7
+ "HuggingFaceTB/SmolLM-135M": {
8
+ "fixture": "hf-internal-testing/proto-SmolLM-slim"
9
+ },
10
+ "HuggingFaceTB/SmolLM-360M": {
11
+ "fixture": "hf-internal-testing/proto-SmolLM-slim"
12
+ },
13
+ "HuggingFaceTB/SmolLM-1.7B": {
14
+ "fixture": "hf-internal-testing/proto-SmolLM-1.7B-slim"
15
+ }
16
+ },
17
+ "fixtures": {
18
+ "hf-internal-testing/proto-SmolLM-slim": {
19
+ "built_from": "HuggingFaceTB/SmolLM-135M",
20
+ "covers": [
21
+ "HuggingFaceTB/SmolLM-135M",
22
+ "HuggingFaceTB/SmolLM-360M"
23
+ ]
24
+ },
25
+ "hf-internal-testing/proto-SmolLM-1.7B-slim": {
26
+ "built_from": "HuggingFaceTB/SmolLM-1.7B",
27
+ "covers": [
28
+ "HuggingFaceTB/SmolLM-1.7B"
29
+ ],
30
+ "why_separate": "different tokenizer.json and tokenizer_config.json; full multi-head attention instead of grouped key/value heads"
31
+ }
32
+ },
33
+ "integrations": {
34
+ "transformers": {
35
+ "entry_point": "integrations/transformers/usage.md",
36
+ "format": "runnable-markdown",
37
+ "requires": [
38
+ "transformers>=5",
39
+ "torch",
40
+ "accelerate"
41
+ ],
42
+ "targets": [
43
+ "fixtures",
44
+ "checkpoints"
45
+ ],
46
+ "variants": {
47
+ "default": {},
48
+ "eager": {
49
+ "attn_implementation": "eager"
50
+ },
51
+ "bfloat16": {
52
+ "dtype": "bfloat16"
53
+ }
54
+ },
55
+ "training": true,
56
+ "resources": {
57
+ "fixture": {
58
+ "memory_gb": 1,
59
+ "download_mb": 16
60
+ },
61
+ "HuggingFaceTB/SmolLM-135M": {
62
+ "memory_gb": 2,
63
+ "download_mb": 513
64
+ },
65
+ "HuggingFaceTB/SmolLM-360M": {
66
+ "memory_gb": 3,
67
+ "download_mb": 1300
68
+ },
69
+ "HuggingFaceTB/SmolLM-1.7B": {
70
+ "memory_gb": 12,
71
+ "disk_gb": 8,
72
+ "download_mb": 6400,
73
+ "measured": "peak RSS 10.6 GB (default) and 11.3 GB (bfloat16: the variant reload holds two copies), one process, Apple M5, 2026-10-07"
74
+ }
75
+ }
76
+ },
77
+ "transformers.js": {
78
+ "entry_point": "integrations/transformers.js/integration.js",
79
+ "format": "script",
80
+ "requires": [
81
+ "@huggingface/transformers@4.3.0"
82
+ ],
83
+ "targets": [
84
+ "checkpoints"
85
+ ],
86
+ "artifacts": {
87
+ "HuggingFaceTB/SmolLM-135M": {
88
+ "repo": "onnx-community/SmolLM-135M-ONNX",
89
+ "file": "onnx/model.onnx"
90
+ },
91
+ "HuggingFaceTB/SmolLM-360M": {
92
+ "repo": "onnx-community/SmolLM-360M-ONNX",
93
+ "file": "onnx/model.onnx"
94
+ }
95
+ },
96
+ "unsupported": {
97
+ "fixtures": "no ONNX conversion of the fixtures yet",
98
+ "HuggingFaceTB/SmolLM-1.7B": "no onnx-community conversion; the creator's float32 ONNX is 6.8 GB"
99
+ },
100
+ "variants": {
101
+ "default": {
102
+ "dtype": "fp32"
103
+ },
104
+ "webgpu": {
105
+ "dtype": "fp32",
106
+ "device": "webgpu"
107
+ },
108
+ "webgpu-fp16": {
109
+ "dtype": "fp16",
110
+ "device": "webgpu"
111
+ },
112
+ "webgpu-q4f16": {
113
+ "dtype": "q4f16",
114
+ "device": "webgpu"
115
+ }
116
+ },
117
+ "training": false
118
+ }
119
+ },
120
+ "outputs": {
121
+ "runtime": {
122
+ "compare": "exact"
123
+ },
124
+ "generated_tokens": {
125
+ "compare": "exact"
126
+ },
127
+ "generated_text": {
128
+ "compare": "exact"
129
+ },
130
+ "next_token_logits": {
131
+ "compare": "allclose",
132
+ "atol": 0.0001,
133
+ "rtol": 0.0001
134
+ },
135
+ "training.loss": {
136
+ "compare": "allclose",
137
+ "atol": 0.0001,
138
+ "rtol": 0.0001
139
+ },
140
+ "training.gradients": {
141
+ "compare": "all_true"
142
+ },
143
+ "training.updated": {
144
+ "compare": "true"
145
+ }
146
+ }
147
+ }
integrations/transformers.js/integration.js ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Transformers.js contract of the SmolLM MIC: batched greedy generation.
2
+ //
3
+ // Runs on HF-owned ONNX conversions (onnx-community/SmolLM-*-ONNX), not on the
4
+ // creator's PyTorch checkpoints. The runner sets MIC_MODEL, MIC_MODEL_REVISION,
5
+ // and MIC_MODEL_KWARGS (JSON). The last stdout line is the result record.
6
+ // Inference only: Transformers.js does not train, so there is no training probe.
7
+ // Timings are recorded for performance tracking but not compared with baselines.
8
+
9
+ import { AutoModelForCausalLM, AutoTokenizer } from "@huggingface/transformers";
10
+
11
+ const modelId = process.env.MIC_MODEL ?? "onnx-community/SmolLM-135M-ONNX";
12
+ const revision = process.env.MIC_MODEL_REVISION || "main";
13
+ const modelKwargs = JSON.parse(process.env.MIC_MODEL_KWARGS || '{"dtype": "fp32"}');
14
+
15
+ const prompts = [
16
+ "The capital of France is",
17
+ "The capital of Germany is",
18
+ "The capital of Italy is",
19
+ "The capital of the United Kingdom is",
20
+ ];
21
+ const answers = [" Paris", " Berlin", " Rome", " London"];
22
+
23
+ const tokenizer = await AutoTokenizer.from_pretrained(modelId, { revision });
24
+ tokenizer.pad_token = tokenizer.eos_token;
25
+ tokenizer.pad_token_id = tokenizer.eos_token_id;
26
+ tokenizer.padding_side = "left";
27
+ let start = performance.now();
28
+ const model = await AutoModelForCausalLM.from_pretrained(modelId, { revision, ...modelKwargs });
29
+ const timing = { load_ms: performance.now() - start };
30
+
31
+ const inputs = tokenizer(prompts, { padding: true });
32
+ const generate = () =>
33
+ model.generate({ ...inputs, max_new_tokens: 4, do_sample: false, pad_token_id: tokenizer.eos_token_id });
34
+ start = performance.now();
35
+ await generate(); // first call compiles kernels and allocates buffers
36
+ timing.first_generate_ms = performance.now() - start;
37
+ start = performance.now();
38
+ const generated = await generate();
39
+ timing.generate_ms = performance.now() - start;
40
+ const promptLength = inputs.input_ids.dims[1];
41
+ const generatedTokens = generated.tolist().map((row) => row.slice(promptLength).map(Number));
42
+ console.error(tokenizer.batch_decode(generatedTokens, { skip_special_tokens: true }));
43
+
44
+ start = performance.now();
45
+ const { logits } = await model(inputs);
46
+ timing.forward_ms = performance.now() - start;
47
+ const answerIds = answers.map((a) => tokenizer.encode(a, { add_special_tokens: false })[0]);
48
+ const [batch, length, vocab] = logits.dims;
49
+ const nextTokenLogits = [];
50
+ for (let b = 0; b < batch; b++) {
51
+ const offset = (b * length + length - 1) * vocab;
52
+ nextTokenLogits.push(answerIds.map((id) => Number(logits.data[offset + id])));
53
+ }
54
+
55
+ console.log(
56
+ JSON.stringify({
57
+ runtime: { device: modelKwargs.device ?? "cpu", dtype: modelKwargs.dtype ?? "fp32" },
58
+ generated_tokens: generatedTokens,
59
+ generated_text: tokenizer.batch_decode(generatedTokens, { skip_special_tokens: true }),
60
+ next_token_logits: nextTokenLogits,
61
+ timing,
62
+ }),
63
+ );
integrations/transformers.js/package-lock.json ADDED
@@ -0,0 +1,969 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "smollm-mic-transformers-js",
3
+ "lockfileVersion": 3,
4
+ "requires": true,
5
+ "packages": {
6
+ "": {
7
+ "name": "smollm-mic-transformers-js",
8
+ "dependencies": {
9
+ "@huggingface/transformers": "4.3.0"
10
+ }
11
+ },
12
+ "node_modules/@emnapi/runtime": {
13
+ "version": "1.11.3",
14
+ "resolved": "https://npm.registries.huggingface.tech/@emnapi/runtime/-/runtime-1.11.3.tgz",
15
+ "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==",
16
+ "license": "MIT",
17
+ "optional": true,
18
+ "dependencies": {
19
+ "tslib": "^2.4.0"
20
+ }
21
+ },
22
+ "node_modules/@huggingface/jinja": {
23
+ "version": "0.5.10",
24
+ "resolved": "https://npm.registries.huggingface.tech/@huggingface/jinja/-/jinja-0.5.10.tgz",
25
+ "integrity": "sha512-SgS1D1bglQ94ceD4ZCL6eayUDy9uV1xuyk61OjgSxU5GJh7upqZCKII0JoTYMc6wWsg3JUgaPRX0ElQzXPk3Cw==",
26
+ "license": "MIT",
27
+ "engines": {
28
+ "node": ">=18"
29
+ }
30
+ },
31
+ "node_modules/@huggingface/tokenizers": {
32
+ "version": "0.2.0",
33
+ "resolved": "https://npm.registries.huggingface.tech/@huggingface/tokenizers/-/tokenizers-0.2.0.tgz",
34
+ "integrity": "sha512-LidMHe1FpcSYH4vcSjXooda34pC0M8m1gmDOv7SQi6Iv+ib1zX7J3sHBCC9/3FPCkn2k1b55FneVqMRxrr99pg==",
35
+ "license": "Apache-2.0"
36
+ },
37
+ "node_modules/@huggingface/transformers": {
38
+ "version": "4.3.0",
39
+ "resolved": "https://npm.registries.huggingface.tech/@huggingface/transformers/-/transformers-4.3.0.tgz",
40
+ "integrity": "sha512-fL1A/WUZwouPrOlYxU5dzIwD2T5J781JiB2jDR8bFe5DwCj0Gfudq+NEXCMno49kQgajHA7xQkrRLJlqG1veEA==",
41
+ "license": "Apache-2.0",
42
+ "dependencies": {
43
+ "@huggingface/jinja": "^0.5.10",
44
+ "@huggingface/tokenizers": "^0.2.0",
45
+ "onnxruntime-node": "1.30.0",
46
+ "onnxruntime-web": "1.31.0-dev.20260914-8d85527a0",
47
+ "sharp": "^0.35.4"
48
+ }
49
+ },
50
+ "node_modules/@img/colour": {
51
+ "version": "1.1.0",
52
+ "resolved": "https://npm.registries.huggingface.tech/@img/colour/-/colour-1.1.0.tgz",
53
+ "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==",
54
+ "license": "MIT",
55
+ "engines": {
56
+ "node": ">=18"
57
+ }
58
+ },
59
+ "node_modules/@img/sharp-darwin-arm64": {
60
+ "version": "0.35.5",
61
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.5.tgz",
62
+ "integrity": "sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==",
63
+ "cpu": [
64
+ "arm64"
65
+ ],
66
+ "license": "Apache-2.0",
67
+ "optional": true,
68
+ "os": [
69
+ "darwin"
70
+ ],
71
+ "engines": {
72
+ "node": ">=20.9.0"
73
+ },
74
+ "funding": {
75
+ "url": "https://opencollective.com/libvips"
76
+ },
77
+ "optionalDependencies": {
78
+ "@img/sharp-libvips-darwin-arm64": "1.3.4"
79
+ }
80
+ },
81
+ "node_modules/@img/sharp-darwin-x64": {
82
+ "version": "0.35.5",
83
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.5.tgz",
84
+ "integrity": "sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==",
85
+ "cpu": [
86
+ "x64"
87
+ ],
88
+ "license": "Apache-2.0",
89
+ "optional": true,
90
+ "os": [
91
+ "darwin"
92
+ ],
93
+ "engines": {
94
+ "node": ">=20.9.0"
95
+ },
96
+ "funding": {
97
+ "url": "https://opencollective.com/libvips"
98
+ },
99
+ "optionalDependencies": {
100
+ "@img/sharp-libvips-darwin-x64": "1.3.4"
101
+ }
102
+ },
103
+ "node_modules/@img/sharp-freebsd-wasm32": {
104
+ "version": "0.35.5",
105
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.5.tgz",
106
+ "integrity": "sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==",
107
+ "license": "Apache-2.0",
108
+ "optional": true,
109
+ "os": [
110
+ "freebsd"
111
+ ],
112
+ "dependencies": {
113
+ "@img/sharp-wasm32": "0.35.5"
114
+ },
115
+ "engines": {
116
+ "node": ">=20.9.0"
117
+ },
118
+ "funding": {
119
+ "url": "https://opencollective.com/libvips"
120
+ }
121
+ },
122
+ "node_modules/@img/sharp-libvips-darwin-arm64": {
123
+ "version": "1.3.4",
124
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.4.tgz",
125
+ "integrity": "sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==",
126
+ "cpu": [
127
+ "arm64"
128
+ ],
129
+ "license": "LGPL-3.0-or-later",
130
+ "optional": true,
131
+ "os": [
132
+ "darwin"
133
+ ],
134
+ "funding": {
135
+ "url": "https://opencollective.com/libvips"
136
+ }
137
+ },
138
+ "node_modules/@img/sharp-libvips-darwin-x64": {
139
+ "version": "1.3.4",
140
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.4.tgz",
141
+ "integrity": "sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==",
142
+ "cpu": [
143
+ "x64"
144
+ ],
145
+ "license": "LGPL-3.0-or-later",
146
+ "optional": true,
147
+ "os": [
148
+ "darwin"
149
+ ],
150
+ "funding": {
151
+ "url": "https://opencollective.com/libvips"
152
+ }
153
+ },
154
+ "node_modules/@img/sharp-libvips-linux-arm": {
155
+ "version": "1.3.4",
156
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.4.tgz",
157
+ "integrity": "sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==",
158
+ "cpu": [
159
+ "arm"
160
+ ],
161
+ "license": "LGPL-3.0-or-later",
162
+ "optional": true,
163
+ "os": [
164
+ "linux"
165
+ ],
166
+ "funding": {
167
+ "url": "https://opencollective.com/libvips"
168
+ }
169
+ },
170
+ "node_modules/@img/sharp-libvips-linux-arm64": {
171
+ "version": "1.3.4",
172
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.4.tgz",
173
+ "integrity": "sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==",
174
+ "cpu": [
175
+ "arm64"
176
+ ],
177
+ "license": "LGPL-3.0-or-later",
178
+ "optional": true,
179
+ "os": [
180
+ "linux"
181
+ ],
182
+ "funding": {
183
+ "url": "https://opencollective.com/libvips"
184
+ }
185
+ },
186
+ "node_modules/@img/sharp-libvips-linux-ppc64": {
187
+ "version": "1.3.4",
188
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.4.tgz",
189
+ "integrity": "sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==",
190
+ "cpu": [
191
+ "ppc64"
192
+ ],
193
+ "license": "LGPL-3.0-or-later",
194
+ "optional": true,
195
+ "os": [
196
+ "linux"
197
+ ],
198
+ "funding": {
199
+ "url": "https://opencollective.com/libvips"
200
+ }
201
+ },
202
+ "node_modules/@img/sharp-libvips-linux-riscv64": {
203
+ "version": "1.3.4",
204
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.4.tgz",
205
+ "integrity": "sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==",
206
+ "cpu": [
207
+ "riscv64"
208
+ ],
209
+ "license": "LGPL-3.0-or-later",
210
+ "optional": true,
211
+ "os": [
212
+ "linux"
213
+ ],
214
+ "funding": {
215
+ "url": "https://opencollective.com/libvips"
216
+ }
217
+ },
218
+ "node_modules/@img/sharp-libvips-linux-s390x": {
219
+ "version": "1.3.4",
220
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.4.tgz",
221
+ "integrity": "sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==",
222
+ "cpu": [
223
+ "s390x"
224
+ ],
225
+ "license": "LGPL-3.0-or-later",
226
+ "optional": true,
227
+ "os": [
228
+ "linux"
229
+ ],
230
+ "funding": {
231
+ "url": "https://opencollective.com/libvips"
232
+ }
233
+ },
234
+ "node_modules/@img/sharp-libvips-linux-x64": {
235
+ "version": "1.3.4",
236
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.4.tgz",
237
+ "integrity": "sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==",
238
+ "cpu": [
239
+ "x64"
240
+ ],
241
+ "license": "LGPL-3.0-or-later",
242
+ "optional": true,
243
+ "os": [
244
+ "linux"
245
+ ],
246
+ "funding": {
247
+ "url": "https://opencollective.com/libvips"
248
+ }
249
+ },
250
+ "node_modules/@img/sharp-libvips-linuxmusl-arm64": {
251
+ "version": "1.3.4",
252
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.4.tgz",
253
+ "integrity": "sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==",
254
+ "cpu": [
255
+ "arm64"
256
+ ],
257
+ "license": "LGPL-3.0-or-later",
258
+ "optional": true,
259
+ "os": [
260
+ "linux"
261
+ ],
262
+ "funding": {
263
+ "url": "https://opencollective.com/libvips"
264
+ }
265
+ },
266
+ "node_modules/@img/sharp-libvips-linuxmusl-x64": {
267
+ "version": "1.3.4",
268
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.4.tgz",
269
+ "integrity": "sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==",
270
+ "cpu": [
271
+ "x64"
272
+ ],
273
+ "license": "LGPL-3.0-or-later",
274
+ "optional": true,
275
+ "os": [
276
+ "linux"
277
+ ],
278
+ "funding": {
279
+ "url": "https://opencollective.com/libvips"
280
+ }
281
+ },
282
+ "node_modules/@img/sharp-linux-arm": {
283
+ "version": "0.35.5",
284
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.5.tgz",
285
+ "integrity": "sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==",
286
+ "cpu": [
287
+ "arm"
288
+ ],
289
+ "license": "Apache-2.0",
290
+ "optional": true,
291
+ "os": [
292
+ "linux"
293
+ ],
294
+ "engines": {
295
+ "node": ">=20.9.0"
296
+ },
297
+ "funding": {
298
+ "url": "https://opencollective.com/libvips"
299
+ },
300
+ "optionalDependencies": {
301
+ "@img/sharp-libvips-linux-arm": "1.3.4"
302
+ }
303
+ },
304
+ "node_modules/@img/sharp-linux-arm64": {
305
+ "version": "0.35.5",
306
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.5.tgz",
307
+ "integrity": "sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==",
308
+ "cpu": [
309
+ "arm64"
310
+ ],
311
+ "license": "Apache-2.0",
312
+ "optional": true,
313
+ "os": [
314
+ "linux"
315
+ ],
316
+ "engines": {
317
+ "node": ">=20.9.0"
318
+ },
319
+ "funding": {
320
+ "url": "https://opencollective.com/libvips"
321
+ },
322
+ "optionalDependencies": {
323
+ "@img/sharp-libvips-linux-arm64": "1.3.4"
324
+ }
325
+ },
326
+ "node_modules/@img/sharp-linux-ppc64": {
327
+ "version": "0.35.5",
328
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.5.tgz",
329
+ "integrity": "sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==",
330
+ "cpu": [
331
+ "ppc64"
332
+ ],
333
+ "license": "Apache-2.0",
334
+ "optional": true,
335
+ "os": [
336
+ "linux"
337
+ ],
338
+ "engines": {
339
+ "node": ">=20.9.0"
340
+ },
341
+ "funding": {
342
+ "url": "https://opencollective.com/libvips"
343
+ },
344
+ "optionalDependencies": {
345
+ "@img/sharp-libvips-linux-ppc64": "1.3.4"
346
+ }
347
+ },
348
+ "node_modules/@img/sharp-linux-riscv64": {
349
+ "version": "0.35.5",
350
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.5.tgz",
351
+ "integrity": "sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==",
352
+ "cpu": [
353
+ "riscv64"
354
+ ],
355
+ "license": "Apache-2.0",
356
+ "optional": true,
357
+ "os": [
358
+ "linux"
359
+ ],
360
+ "engines": {
361
+ "node": ">=20.9.0"
362
+ },
363
+ "funding": {
364
+ "url": "https://opencollective.com/libvips"
365
+ },
366
+ "optionalDependencies": {
367
+ "@img/sharp-libvips-linux-riscv64": "1.3.4"
368
+ }
369
+ },
370
+ "node_modules/@img/sharp-linux-s390x": {
371
+ "version": "0.35.5",
372
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.5.tgz",
373
+ "integrity": "sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==",
374
+ "cpu": [
375
+ "s390x"
376
+ ],
377
+ "license": "Apache-2.0",
378
+ "optional": true,
379
+ "os": [
380
+ "linux"
381
+ ],
382
+ "engines": {
383
+ "node": ">=20.9.0"
384
+ },
385
+ "funding": {
386
+ "url": "https://opencollective.com/libvips"
387
+ },
388
+ "optionalDependencies": {
389
+ "@img/sharp-libvips-linux-s390x": "1.3.4"
390
+ }
391
+ },
392
+ "node_modules/@img/sharp-linux-x64": {
393
+ "version": "0.35.5",
394
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.5.tgz",
395
+ "integrity": "sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==",
396
+ "cpu": [
397
+ "x64"
398
+ ],
399
+ "license": "Apache-2.0",
400
+ "optional": true,
401
+ "os": [
402
+ "linux"
403
+ ],
404
+ "engines": {
405
+ "node": ">=20.9.0"
406
+ },
407
+ "funding": {
408
+ "url": "https://opencollective.com/libvips"
409
+ },
410
+ "optionalDependencies": {
411
+ "@img/sharp-libvips-linux-x64": "1.3.4"
412
+ }
413
+ },
414
+ "node_modules/@img/sharp-linuxmusl-arm64": {
415
+ "version": "0.35.5",
416
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.5.tgz",
417
+ "integrity": "sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==",
418
+ "cpu": [
419
+ "arm64"
420
+ ],
421
+ "license": "Apache-2.0",
422
+ "optional": true,
423
+ "os": [
424
+ "linux"
425
+ ],
426
+ "engines": {
427
+ "node": ">=20.9.0"
428
+ },
429
+ "funding": {
430
+ "url": "https://opencollective.com/libvips"
431
+ },
432
+ "optionalDependencies": {
433
+ "@img/sharp-libvips-linuxmusl-arm64": "1.3.4"
434
+ }
435
+ },
436
+ "node_modules/@img/sharp-linuxmusl-x64": {
437
+ "version": "0.35.5",
438
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.5.tgz",
439
+ "integrity": "sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==",
440
+ "cpu": [
441
+ "x64"
442
+ ],
443
+ "license": "Apache-2.0",
444
+ "optional": true,
445
+ "os": [
446
+ "linux"
447
+ ],
448
+ "engines": {
449
+ "node": ">=20.9.0"
450
+ },
451
+ "funding": {
452
+ "url": "https://opencollective.com/libvips"
453
+ },
454
+ "optionalDependencies": {
455
+ "@img/sharp-libvips-linuxmusl-x64": "1.3.4"
456
+ }
457
+ },
458
+ "node_modules/@img/sharp-wasm32": {
459
+ "version": "0.35.5",
460
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz",
461
+ "integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==",
462
+ "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
463
+ "optional": true,
464
+ "dependencies": {
465
+ "@emnapi/runtime": "^1.11.3"
466
+ },
467
+ "engines": {
468
+ "node": ">=20.9.0"
469
+ },
470
+ "funding": {
471
+ "url": "https://opencollective.com/libvips"
472
+ }
473
+ },
474
+ "node_modules/@img/sharp-webcontainers-wasm32": {
475
+ "version": "0.35.5",
476
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.5.tgz",
477
+ "integrity": "sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==",
478
+ "cpu": [
479
+ "wasm32"
480
+ ],
481
+ "license": "Apache-2.0",
482
+ "optional": true,
483
+ "dependencies": {
484
+ "@img/sharp-wasm32": "0.35.5"
485
+ },
486
+ "engines": {
487
+ "node": ">=20.9.0"
488
+ },
489
+ "funding": {
490
+ "url": "https://opencollective.com/libvips"
491
+ }
492
+ },
493
+ "node_modules/@img/sharp-win32-arm64": {
494
+ "version": "0.35.5",
495
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.5.tgz",
496
+ "integrity": "sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==",
497
+ "cpu": [
498
+ "arm64"
499
+ ],
500
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
501
+ "optional": true,
502
+ "os": [
503
+ "win32"
504
+ ],
505
+ "engines": {
506
+ "node": ">=20.9.0"
507
+ },
508
+ "funding": {
509
+ "url": "https://opencollective.com/libvips"
510
+ }
511
+ },
512
+ "node_modules/@img/sharp-win32-ia32": {
513
+ "version": "0.35.5",
514
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.5.tgz",
515
+ "integrity": "sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==",
516
+ "cpu": [
517
+ "ia32"
518
+ ],
519
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
520
+ "optional": true,
521
+ "os": [
522
+ "win32"
523
+ ],
524
+ "engines": {
525
+ "node": "^20.9.0"
526
+ },
527
+ "funding": {
528
+ "url": "https://opencollective.com/libvips"
529
+ }
530
+ },
531
+ "node_modules/@img/sharp-win32-x64": {
532
+ "version": "0.35.5",
533
+ "resolved": "https://npm.registries.huggingface.tech/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.5.tgz",
534
+ "integrity": "sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==",
535
+ "cpu": [
536
+ "x64"
537
+ ],
538
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
539
+ "optional": true,
540
+ "os": [
541
+ "win32"
542
+ ],
543
+ "engines": {
544
+ "node": ">=20.9.0"
545
+ },
546
+ "funding": {
547
+ "url": "https://opencollective.com/libvips"
548
+ }
549
+ },
550
+ "node_modules/@protobufjs/aspromise": {
551
+ "version": "1.1.2",
552
+ "resolved": "https://npm.registries.huggingface.tech/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
553
+ "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==",
554
+ "license": "BSD-3-Clause"
555
+ },
556
+ "node_modules/@protobufjs/base64": {
557
+ "version": "1.1.2",
558
+ "resolved": "https://npm.registries.huggingface.tech/@protobufjs/base64/-/base64-1.1.2.tgz",
559
+ "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==",
560
+ "license": "BSD-3-Clause"
561
+ },
562
+ "node_modules/@protobufjs/codegen": {
563
+ "version": "2.0.5",
564
+ "resolved": "https://npm.registries.huggingface.tech/@protobufjs/codegen/-/codegen-2.0.5.tgz",
565
+ "integrity": "sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g==",
566
+ "license": "BSD-3-Clause"
567
+ },
568
+ "node_modules/@protobufjs/eventemitter": {
569
+ "version": "1.1.1",
570
+ "resolved": "https://npm.registries.huggingface.tech/@protobufjs/eventemitter/-/eventemitter-1.1.1.tgz",
571
+ "integrity": "sha512-vW1GmwMZNnL+gMRaovlh9yZX74kc+TTU3FObkkurpMaRtBfLP3ldjS9KQWlwZgraRE0+dheEEoAxdzcJQ8eXZg==",
572
+ "license": "BSD-3-Clause"
573
+ },
574
+ "node_modules/@protobufjs/fetch": {
575
+ "version": "1.1.1",
576
+ "resolved": "https://npm.registries.huggingface.tech/@protobufjs/fetch/-/fetch-1.1.1.tgz",
577
+ "integrity": "sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw==",
578
+ "license": "BSD-3-Clause",
579
+ "dependencies": {
580
+ "@protobufjs/aspromise": "^1.1.1"
581
+ }
582
+ },
583
+ "node_modules/@protobufjs/float": {
584
+ "version": "1.0.2",
585
+ "resolved": "https://npm.registries.huggingface.tech/@protobufjs/float/-/float-1.0.2.tgz",
586
+ "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==",
587
+ "license": "BSD-3-Clause"
588
+ },
589
+ "node_modules/@protobufjs/path": {
590
+ "version": "1.1.2",
591
+ "resolved": "https://npm.registries.huggingface.tech/@protobufjs/path/-/path-1.1.2.tgz",
592
+ "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==",
593
+ "license": "BSD-3-Clause"
594
+ },
595
+ "node_modules/@protobufjs/pool": {
596
+ "version": "1.1.0",
597
+ "resolved": "https://npm.registries.huggingface.tech/@protobufjs/pool/-/pool-1.1.0.tgz",
598
+ "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==",
599
+ "license": "BSD-3-Clause"
600
+ },
601
+ "node_modules/@protobufjs/utf8": {
602
+ "version": "1.1.2",
603
+ "resolved": "https://npm.registries.huggingface.tech/@protobufjs/utf8/-/utf8-1.1.2.tgz",
604
+ "integrity": "sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug==",
605
+ "license": "BSD-3-Clause"
606
+ },
607
+ "node_modules/@types/node": {
608
+ "version": "26.6.4",
609
+ "resolved": "https://npm.registries.huggingface.tech/@types/node/-/node-26.6.4.tgz",
610
+ "integrity": "sha512-ldVPDCzj7fsaGZrLB0NuHuTvJcsNasysBAqMolr/cgxrLd1xbqxIr3XJiPnHHJUCxj5sNF1vnRj9aWnrVh5Jcg==",
611
+ "license": "MIT",
612
+ "dependencies": {
613
+ "undici-types": "~8.9.0"
614
+ }
615
+ },
616
+ "node_modules/adm-zip": {
617
+ "version": "0.6.1",
618
+ "resolved": "https://npm.registries.huggingface.tech/adm-zip/-/adm-zip-0.6.1.tgz",
619
+ "integrity": "sha512-Xwrja8nx9e5o2N1my4DsKCeKpdrnACyr1wtbPxBDgGzKzKyE9kRtBFA8mWldI+RVlD7CBZNWY/wQ2+ydwOR6kQ==",
620
+ "license": "MIT",
621
+ "engines": {
622
+ "node": ">=14.0"
623
+ }
624
+ },
625
+ "node_modules/define-data-property": {
626
+ "version": "1.1.4",
627
+ "resolved": "https://npm.registries.huggingface.tech/define-data-property/-/define-data-property-1.1.4.tgz",
628
+ "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
629
+ "license": "MIT",
630
+ "dependencies": {
631
+ "es-define-property": "^1.0.0",
632
+ "es-errors": "^1.3.0",
633
+ "gopd": "^1.0.1"
634
+ },
635
+ "engines": {
636
+ "node": ">= 0.4"
637
+ },
638
+ "funding": {
639
+ "url": "https://github.com/sponsors/ljharb"
640
+ }
641
+ },
642
+ "node_modules/define-properties": {
643
+ "version": "1.2.1",
644
+ "resolved": "https://npm.registries.huggingface.tech/define-properties/-/define-properties-1.2.1.tgz",
645
+ "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==",
646
+ "license": "MIT",
647
+ "dependencies": {
648
+ "define-data-property": "^1.0.1",
649
+ "has-property-descriptors": "^1.0.0",
650
+ "object-keys": "^1.1.1"
651
+ },
652
+ "engines": {
653
+ "node": ">= 0.4"
654
+ },
655
+ "funding": {
656
+ "url": "https://github.com/sponsors/ljharb"
657
+ }
658
+ },
659
+ "node_modules/detect-libc": {
660
+ "version": "2.1.2",
661
+ "resolved": "https://npm.registries.huggingface.tech/detect-libc/-/detect-libc-2.1.2.tgz",
662
+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
663
+ "license": "Apache-2.0",
664
+ "engines": {
665
+ "node": ">=8"
666
+ }
667
+ },
668
+ "node_modules/es-define-property": {
669
+ "version": "1.0.1",
670
+ "resolved": "https://npm.registries.huggingface.tech/es-define-property/-/es-define-property-1.0.1.tgz",
671
+ "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
672
+ "license": "MIT",
673
+ "engines": {
674
+ "node": ">= 0.4"
675
+ }
676
+ },
677
+ "node_modules/es-errors": {
678
+ "version": "1.3.0",
679
+ "resolved": "https://npm.registries.huggingface.tech/es-errors/-/es-errors-1.3.0.tgz",
680
+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
681
+ "license": "MIT",
682
+ "engines": {
683
+ "node": ">= 0.4"
684
+ }
685
+ },
686
+ "node_modules/escape-string-regexp": {
687
+ "version": "4.0.0",
688
+ "resolved": "https://npm.registries.huggingface.tech/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
689
+ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
690
+ "license": "MIT",
691
+ "engines": {
692
+ "node": ">=10"
693
+ },
694
+ "funding": {
695
+ "url": "https://github.com/sponsors/sindresorhus"
696
+ }
697
+ },
698
+ "node_modules/flatbuffers": {
699
+ "version": "25.9.23",
700
+ "resolved": "https://npm.registries.huggingface.tech/flatbuffers/-/flatbuffers-25.9.23.tgz",
701
+ "integrity": "sha512-MI1qs7Lo4Syw0EOzUl0xjs2lsoeqFku44KpngfIduHBYvzm8h2+7K8YMQh1JtVVVrUvhLpNwqVi4DERegUJhPQ==",
702
+ "license": "Apache-2.0"
703
+ },
704
+ "node_modules/global-agent": {
705
+ "version": "4.1.3",
706
+ "resolved": "https://npm.registries.huggingface.tech/global-agent/-/global-agent-4.1.3.tgz",
707
+ "integrity": "sha512-KUJEViiuFT3I97t+GYMikLPJS2Lfo/S2F+DQuBWzuzaMPnvt5yyZePzArx36fBzpGTxZjIpDbXLeySLgh+k76g==",
708
+ "license": "BSD-3-Clause",
709
+ "dependencies": {
710
+ "globalthis": "^1.0.2",
711
+ "matcher": "^4.0.0",
712
+ "semver": "^7.3.5",
713
+ "serialize-error": "^8.1.0"
714
+ },
715
+ "engines": {
716
+ "node": ">=10.0"
717
+ }
718
+ },
719
+ "node_modules/globalthis": {
720
+ "version": "1.0.4",
721
+ "resolved": "https://npm.registries.huggingface.tech/globalthis/-/globalthis-1.0.4.tgz",
722
+ "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==",
723
+ "license": "MIT",
724
+ "dependencies": {
725
+ "define-properties": "^1.2.1",
726
+ "gopd": "^1.0.1"
727
+ },
728
+ "engines": {
729
+ "node": ">= 0.4"
730
+ },
731
+ "funding": {
732
+ "url": "https://github.com/sponsors/ljharb"
733
+ }
734
+ },
735
+ "node_modules/gopd": {
736
+ "version": "1.2.0",
737
+ "resolved": "https://npm.registries.huggingface.tech/gopd/-/gopd-1.2.0.tgz",
738
+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
739
+ "license": "MIT",
740
+ "engines": {
741
+ "node": ">= 0.4"
742
+ },
743
+ "funding": {
744
+ "url": "https://github.com/sponsors/ljharb"
745
+ }
746
+ },
747
+ "node_modules/guid-typescript": {
748
+ "version": "1.0.9",
749
+ "resolved": "https://npm.registries.huggingface.tech/guid-typescript/-/guid-typescript-1.0.9.tgz",
750
+ "integrity": "sha512-Y8T4vYhEfwJOTbouREvG+3XDsjr8E3kIr7uf+JZ0BYloFsttiHU0WfvANVsR7TxNUJa/WpCnw/Ino/p+DeBhBQ==",
751
+ "license": "ISC"
752
+ },
753
+ "node_modules/has-property-descriptors": {
754
+ "version": "1.0.2",
755
+ "resolved": "https://npm.registries.huggingface.tech/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
756
+ "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
757
+ "license": "MIT",
758
+ "dependencies": {
759
+ "es-define-property": "^1.0.0"
760
+ },
761
+ "funding": {
762
+ "url": "https://github.com/sponsors/ljharb"
763
+ }
764
+ },
765
+ "node_modules/long": {
766
+ "version": "5.3.2",
767
+ "resolved": "https://npm.registries.huggingface.tech/long/-/long-5.3.2.tgz",
768
+ "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",
769
+ "license": "Apache-2.0"
770
+ },
771
+ "node_modules/matcher": {
772
+ "version": "4.0.0",
773
+ "resolved": "https://npm.registries.huggingface.tech/matcher/-/matcher-4.0.0.tgz",
774
+ "integrity": "sha512-S6x5wmcDmsDRRU/c2dkccDwQPXoFczc5+HpQ2lON8pnvHlnvHAHj5WlLVvw6n6vNyHuVugYrFohYxbS+pvFpKQ==",
775
+ "license": "MIT",
776
+ "dependencies": {
777
+ "escape-string-regexp": "^4.0.0"
778
+ },
779
+ "engines": {
780
+ "node": ">=10"
781
+ },
782
+ "funding": {
783
+ "url": "https://github.com/sponsors/sindresorhus"
784
+ }
785
+ },
786
+ "node_modules/object-keys": {
787
+ "version": "1.1.1",
788
+ "resolved": "https://npm.registries.huggingface.tech/object-keys/-/object-keys-1.1.1.tgz",
789
+ "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
790
+ "license": "MIT",
791
+ "engines": {
792
+ "node": ">= 0.4"
793
+ }
794
+ },
795
+ "node_modules/onnxruntime-common": {
796
+ "version": "1.30.0",
797
+ "resolved": "https://npm.registries.huggingface.tech/onnxruntime-common/-/onnxruntime-common-1.30.0.tgz",
798
+ "integrity": "sha512-7fdVWjAID1dVhH/G8qK3APARunV4VkBFoCQAP7qp4Wkab0mrorvmc+sqiT+mKXOzDqdjN5j+/Z9nb4gzNPWcyA==",
799
+ "license": "MIT"
800
+ },
801
+ "node_modules/onnxruntime-node": {
802
+ "version": "1.30.0",
803
+ "resolved": "https://npm.registries.huggingface.tech/onnxruntime-node/-/onnxruntime-node-1.30.0.tgz",
804
+ "integrity": "sha512-twhs1C2C/BFkz1yc5OY0KIU2GUq6DURO7hD4bx5Q2Qy3nAMJwRXW8xU3NVczE29VA9lolLOYepoD8fjTGOfIqw==",
805
+ "hasInstallScript": true,
806
+ "license": "MIT",
807
+ "os": [
808
+ "win32",
809
+ "darwin",
810
+ "linux"
811
+ ],
812
+ "dependencies": {
813
+ "adm-zip": "^0.6.0",
814
+ "global-agent": "^4.1.3",
815
+ "onnxruntime-common": "1.30.0"
816
+ }
817
+ },
818
+ "node_modules/onnxruntime-web": {
819
+ "version": "1.31.0-dev.20260914-8d85527a0",
820
+ "resolved": "https://npm.registries.huggingface.tech/onnxruntime-web/-/onnxruntime-web-1.31.0-dev.20260914-8d85527a0.tgz",
821
+ "integrity": "sha512-Iy7rtadoBgxS/LLvDr3QW38DB1PNXRnr0GJMcL0TAt7c9qjgVQl83UlGCVyeAnK2InpmW8Uc3PL8XIuqtDeF6g==",
822
+ "license": "MIT",
823
+ "dependencies": {
824
+ "flatbuffers": "^25.1.24",
825
+ "guid-typescript": "^1.0.9",
826
+ "long": "^5.2.3",
827
+ "onnxruntime-common": "1.31.0-dev.20260911-2a43ec07e",
828
+ "platform": "^1.3.6",
829
+ "protobufjs": "^7.2.4"
830
+ }
831
+ },
832
+ "node_modules/onnxruntime-web/node_modules/onnxruntime-common": {
833
+ "version": "1.31.0-dev.20260911-2a43ec07e",
834
+ "resolved": "https://npm.registries.huggingface.tech/onnxruntime-common/-/onnxruntime-common-1.31.0-dev.20260911-2a43ec07e.tgz",
835
+ "integrity": "sha512-gBuF6U32YErKIAt+yD7DeGBpjRxhJ1uJwako6ygjokSZULDU6Pd+KWComX8Tumk1hYVHRxjPj7mdMnD0ryAPOw==",
836
+ "license": "MIT"
837
+ },
838
+ "node_modules/platform": {
839
+ "version": "1.3.6",
840
+ "resolved": "https://npm.registries.huggingface.tech/platform/-/platform-1.3.6.tgz",
841
+ "integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==",
842
+ "license": "MIT"
843
+ },
844
+ "node_modules/protobufjs": {
845
+ "version": "7.6.6",
846
+ "resolved": "https://npm.registries.huggingface.tech/protobufjs/-/protobufjs-7.6.6.tgz",
847
+ "integrity": "sha512-dYDWdjSl5RNb7SgPxGQcRU+GtvP7s2fpkrY0r432PcOIaZ0/rBcxEZnQN67iJhFuQiVw754JDoPruPCNdGsbjg==",
848
+ "hasInstallScript": true,
849
+ "license": "BSD-3-Clause",
850
+ "dependencies": {
851
+ "@protobufjs/aspromise": "^1.1.2",
852
+ "@protobufjs/base64": "^1.1.2",
853
+ "@protobufjs/codegen": "^2.0.5",
854
+ "@protobufjs/eventemitter": "^1.1.1",
855
+ "@protobufjs/fetch": "^1.1.1",
856
+ "@protobufjs/float": "^1.0.2",
857
+ "@protobufjs/path": "^1.1.2",
858
+ "@protobufjs/pool": "^1.1.0",
859
+ "@protobufjs/utf8": "^1.1.1",
860
+ "@types/node": ">=13.7.0",
861
+ "long": "^5.3.2"
862
+ },
863
+ "engines": {
864
+ "node": ">=12.0.0"
865
+ }
866
+ },
867
+ "node_modules/semver": {
868
+ "version": "7.8.5",
869
+ "resolved": "https://npm.registries.huggingface.tech/semver/-/semver-7.8.5.tgz",
870
+ "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
871
+ "license": "ISC",
872
+ "bin": {
873
+ "semver": "bin/semver.js"
874
+ },
875
+ "engines": {
876
+ "node": ">=10"
877
+ }
878
+ },
879
+ "node_modules/serialize-error": {
880
+ "version": "8.1.0",
881
+ "resolved": "https://npm.registries.huggingface.tech/serialize-error/-/serialize-error-8.1.0.tgz",
882
+ "integrity": "sha512-3NnuWfM6vBYoy5gZFvHiYsVbafvI9vZv/+jlIigFn4oP4zjNPK3LhcY0xSCgeb1a5L8jO71Mit9LlNoi2UfDDQ==",
883
+ "license": "MIT",
884
+ "dependencies": {
885
+ "type-fest": "^0.20.2"
886
+ },
887
+ "engines": {
888
+ "node": ">=10"
889
+ },
890
+ "funding": {
891
+ "url": "https://github.com/sponsors/sindresorhus"
892
+ }
893
+ },
894
+ "node_modules/sharp": {
895
+ "version": "0.35.5",
896
+ "resolved": "https://npm.registries.huggingface.tech/sharp/-/sharp-0.35.5.tgz",
897
+ "integrity": "sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==",
898
+ "license": "Apache-2.0",
899
+ "dependencies": {
900
+ "@img/colour": "^1.1.0",
901
+ "detect-libc": "^2.1.2",
902
+ "semver": "^7.8.5"
903
+ },
904
+ "engines": {
905
+ "node": ">=20.9.0"
906
+ },
907
+ "funding": {
908
+ "url": "https://opencollective.com/libvips"
909
+ },
910
+ "optionalDependencies": {
911
+ "@img/sharp-darwin-arm64": "0.35.5",
912
+ "@img/sharp-darwin-x64": "0.35.5",
913
+ "@img/sharp-freebsd-wasm32": "0.35.5",
914
+ "@img/sharp-libvips-darwin-arm64": "1.3.4",
915
+ "@img/sharp-libvips-darwin-x64": "1.3.4",
916
+ "@img/sharp-libvips-linux-arm": "1.3.4",
917
+ "@img/sharp-libvips-linux-arm64": "1.3.4",
918
+ "@img/sharp-libvips-linux-ppc64": "1.3.4",
919
+ "@img/sharp-libvips-linux-riscv64": "1.3.4",
920
+ "@img/sharp-libvips-linux-s390x": "1.3.4",
921
+ "@img/sharp-libvips-linux-x64": "1.3.4",
922
+ "@img/sharp-libvips-linuxmusl-arm64": "1.3.4",
923
+ "@img/sharp-libvips-linuxmusl-x64": "1.3.4",
924
+ "@img/sharp-linux-arm": "0.35.5",
925
+ "@img/sharp-linux-arm64": "0.35.5",
926
+ "@img/sharp-linux-ppc64": "0.35.5",
927
+ "@img/sharp-linux-riscv64": "0.35.5",
928
+ "@img/sharp-linux-s390x": "0.35.5",
929
+ "@img/sharp-linux-x64": "0.35.5",
930
+ "@img/sharp-linuxmusl-arm64": "0.35.5",
931
+ "@img/sharp-linuxmusl-x64": "0.35.5",
932
+ "@img/sharp-webcontainers-wasm32": "0.35.5",
933
+ "@img/sharp-win32-arm64": "0.35.5",
934
+ "@img/sharp-win32-ia32": "0.35.5",
935
+ "@img/sharp-win32-x64": "0.35.5"
936
+ },
937
+ "peerDependenciesMeta": {
938
+ "@types/node": {
939
+ "optional": true
940
+ }
941
+ }
942
+ },
943
+ "node_modules/tslib": {
944
+ "version": "2.8.1",
945
+ "resolved": "https://npm.registries.huggingface.tech/tslib/-/tslib-2.8.1.tgz",
946
+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
947
+ "license": "0BSD",
948
+ "optional": true
949
+ },
950
+ "node_modules/type-fest": {
951
+ "version": "0.20.2",
952
+ "resolved": "https://npm.registries.huggingface.tech/type-fest/-/type-fest-0.20.2.tgz",
953
+ "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
954
+ "license": "(MIT OR CC0-1.0)",
955
+ "engines": {
956
+ "node": ">=10"
957
+ },
958
+ "funding": {
959
+ "url": "https://github.com/sponsors/sindresorhus"
960
+ }
961
+ },
962
+ "node_modules/undici-types": {
963
+ "version": "8.9.0",
964
+ "resolved": "https://npm.registries.huggingface.tech/undici-types/-/undici-types-8.9.0.tgz",
965
+ "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==",
966
+ "license": "MIT"
967
+ }
968
+ }
969
+ }
integrations/transformers.js/package.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "smollm-mic-transformers-js",
3
+ "private": true,
4
+ "type": "module",
5
+ "dependencies": {
6
+ "@huggingface/transformers": "4.3.0"
7
+ }
8
+ }
integrations/transformers/usage.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SmolLM: batched text generation with Transformers
2
+
3
+ This page is the Transformers contract of the SmolLM MIC and also a usage example. [doc-builder](https://github.com/huggingface/doc-builder/blob/main/docs/runnable-code-blocks.md) renders the `runnable` blocks below as documentation, and its pytest plugin runs them as written against `HuggingFaceTB/SmolLM-135M`. The MIC runner runs the same blocks against each slim fixture and each checkpoint in [`integration.json`](../../integration.json). Lines marked `# doc-builder: hide` only matter there: they swap in the pinned checkpoint or variant and print the result record. They do not appear in rendered docs.
4
+
5
+ This example's results apply to the target and runtime recorded with its reviewed baseline. Fixture outputs differ from real-checkpoint outputs, and agreement on these prompts does not establish correctness on arbitrary prompts. To reproduce a tested run, use its pinned framework build and environment rather than infer compatibility from the model's serialization metadata. The enclosing [example](../../../../README.md) records the current local setup and remaining publication work.
6
+
7
+ ## Generate
8
+
9
+ ```py runnable:generate
10
+ import torch
11
+ from transformers import AutoModelForCausalLM, AutoTokenizer
12
+ import json # doc-builder: hide
13
+ import os # doc-builder: hide
14
+
15
+ model_id = "HuggingFaceTB/SmolLM-135M"
16
+ model_id = os.environ.get("MIC_MODEL", model_id) # doc-builder: hide
17
+ variant = json.loads(os.environ.get("MIC_MODEL_KWARGS", "{}")) # doc-builder: hide
18
+ device = "cuda" if torch.cuda.is_available() else "cpu"
19
+
20
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
21
+ tokenizer.pad_token = tokenizer.eos_token
22
+ tokenizer.padding_side = "left"
23
+ model = AutoModelForCausalLM.from_pretrained(model_id).to(device)
24
+
25
+ prompts = [
26
+ "The capital of France is",
27
+ "The capital of Germany is",
28
+ "The capital of Italy is",
29
+ "The capital of the United Kingdom is",
30
+ ]
31
+ if variant: # doc-builder: hide
32
+ model = AutoModelForCausalLM.from_pretrained(model_id, **variant).to(device)
33
+ inputs = tokenizer(prompts, return_tensors="pt", padding=True).to(device)
34
+ outputs = model.generate(**inputs, max_new_tokens=4, do_sample=False, pad_token_id=tokenizer.eos_token_id)
35
+ new_tokens = outputs[:, inputs["input_ids"].shape[1] :]
36
+ print(tokenizer.batch_decode(new_tokens, skip_special_tokens=True))
37
+
38
+ with torch.inference_mode(): # doc-builder: hide
39
+ logits = model(**inputs).logits
40
+ answer_ids = [tokenizer.encode(a, add_special_tokens=False)[0] for a in (" Paris", " Berlin", " Rome", " London")]
41
+ next_token_logits = logits[:, -1, answer_ids].float()
42
+ ```
43
+
44
+ ## One training step
45
+
46
+ ```py runnable:generate:2
47
+ answers = [" Paris", " Berlin", " Rome", " London"]
48
+ tokenizer.padding_side = "right" # pad after the text for training, so every label has real context
49
+ batch = tokenizer([p + a for p, a in zip(prompts, answers)], return_tensors="pt", padding=True).to(device)
50
+ labels = batch["input_ids"].masked_fill(batch["attention_mask"] == 0, -100)
51
+
52
+ model.train()
53
+ optimizer = torch.optim.SGD(model.parameters(), lr=0.01)
54
+ loss = model(**batch, labels=labels).loss
55
+ loss.backward()
56
+ before = {name: p.detach().clone() for name, p in model.named_parameters()} # doc-builder: hide
57
+ optimizer.step()
58
+ print(f"loss: {loss.item():.4f}")
59
+
60
+ if os.environ.get("MIC_RUNNER"): # doc-builder: hide
61
+ named = dict(model.named_parameters())
62
+ checked = ("model.layers.0.self_attn.q_proj.weight", "model.layers.0.mlp.down_proj.weight")
63
+ result = {
64
+ "runtime": {
65
+ "device": model.device.type,
66
+ "dtype": str(model.dtype).removeprefix("torch."),
67
+ "attn_implementation": model.config._attn_implementation,
68
+ },
69
+ "generated_tokens": new_tokens.tolist(),
70
+ "generated_text": tokenizer.batch_decode(new_tokens, skip_special_tokens=True),
71
+ "next_token_logits": next_token_logits.tolist(),
72
+ "training": {
73
+ "loss": loss.item(),
74
+ "gradients": {n: bool(named[n].grad is not None and torch.count_nonzero(named[n].grad) > 0 and torch.isfinite(named[n].grad).all()) for n in checked},
75
+ "updated": any(not torch.equal(p, before[n]) for n, p in named.items()),
76
+ },
77
+ }
78
+ print(json.dumps(result))
79
+ ```