webslm 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/models.js +2 -0
- package/dist/protocol.d.ts +4 -0
- package/dist/simple.d.ts +6 -0
- package/dist/simple.js +1 -0
- package/dist/types.d.ts +16 -0
- package/native-manifest.json +29 -29
- package/package.json +1 -1
- package/wasm/relaxed/webslm_wasm.d.ts +4 -2
- package/wasm/relaxed/webslm_wasm.js +16 -8
- package/wasm/relaxed/webslm_wasm_bg.wasm +0 -0
- package/wasm/simd/webslm_wasm.d.ts +4 -2
- package/wasm/simd/webslm_wasm.js +16 -8
- package/wasm/simd/webslm_wasm_bg.wasm +0 -0
- package/wasm/threads/webslm_wasm.d.ts +4 -2
- package/wasm/threads/webslm_wasm.js +18 -10
- package/wasm/threads/webslm_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ Options, all optional:
|
|
|
51
51
|
| `thinkingBudget` | | Most reasoning tokens before the model must answer |
|
|
52
52
|
| `loopDetection` | `false` | Stop when the answer starts repeating itself |
|
|
53
53
|
| `contextShift` | `false` | When the context is full, drop the oldest turns (the system prompt stays) |
|
|
54
|
+
| `speculative` | `"off"` | `"auto"` or a number of tokens to guess per forward pass: same answer, faster when it repeats the prompt (see [Generation controls](#generation-controls)) |
|
|
54
55
|
| `templateKwargs` | | Extra chat template variables |
|
|
55
56
|
| `signal` | | `AbortSignal`; `ask` then rejects with code `"ABORTED"` |
|
|
56
57
|
| `onToken` | | Called with each piece of the answer |
|
|
@@ -391,6 +392,7 @@ const stream = model.chat(messages, {
|
|
|
391
392
|
|
|
392
393
|
- **JSON**: `json: true` constrains the output to a JSON object; `schema` to a JSON Schema subset: `type` (or a list), `properties`, `required`, `additionalProperties`, `items`, `minItems`, `maxItems`, `enum`, `const`. Properties come in any order; an object with `properties` only accepts those unless `additionalProperties` says otherwise. Keywords that cannot be enforced (`pattern`, `format`, `minimum`, `minLength`, `anyOf`, `$ref`...) are rejected with `INVALID_ARGUMENT`. Whitespace runs are capped at 24 characters. Generation ends when the document closes; `maxTokens` can still cut it. A reasoning block before the JSON stays free.
|
|
393
394
|
- **Log-probabilities** are the model's own (before temperature, penalties and constraints). Without them, and without other controls that need every logit (penalties, JSON), greedy and top-k sampling read back only the best candidates (the fast path on WebGPU).
|
|
395
|
+
- **Speculative decoding**: `speculative: "auto"` (or a number of tokens from 1 to 15; `true` is `"auto"`) guesses the next tokens from the text so far (an n-gram model over the prompt, earlier turns and the answer; no draft model) and checks them all in one forward pass. Each token is sampled as plain decoding samples it, so greedy answers, and seeded answers on the same backend, are the same tokens as with `"off"`. It pays off when the answer copies its context (code edits, extraction, summaries that reuse the wording) and mostly on WebGPU, where a pass over a few positions costs little more than one. `"auto"` measures the device and the acceptance, and stops guessing when it does not pay. The result reports `speculativePasses`, `draftedTokens` and `acceptedTokens`. It is not combined with `logprobs`, `json` / `schema` or logits processors. See [speculative decoding](../../README.md#speculative-decoding) for measurements.
|
|
394
396
|
- **`onToken`** returning `false` stops the generation at that token: the result ends there, even if the worker had computed more.
|
|
395
397
|
|
|
396
398
|
Sessions can reuse one computed prefix for several continuations:
|
|
@@ -610,7 +612,7 @@ export default defineConfig({
|
|
|
610
612
|
});
|
|
611
613
|
```
|
|
612
614
|
|
|
613
|
-
Server code that imports webslm must not be bundled: webslm runs from its own files in `node_modules` (Next.js: `serverExternalPackages: ["webslm"]`). Without a bundler, a page can import it from jsDelivr (`https://cdn.jsdelivr.net/npm/webslm@0.
|
|
615
|
+
Server code that imports webslm must not be bundled: webslm runs from its own files in `node_modules` (Next.js: `serverExternalPackages: ["webslm"]`). Without a bundler, a page can import it from jsDelivr (`https://cdn.jsdelivr.net/npm/webslm@0.13.0/dist/index.js`); webslm starts its workers through same-origin `blob:` workers when its files come from another origin. Guides for Next.js, Vite, webpack, Node servers, Bun, Deno and CDNs, each with a tested example: <https://github.com/maxgfr/webslm#frameworks-bundlers-and-runtimes>.
|
|
614
616
|
|
|
615
617
|
## Errors
|
|
616
618
|
|
package/dist/models.js
CHANGED
|
@@ -413,6 +413,8 @@ function wireOptions(options) {
|
|
|
413
413
|
out.loopDetection = options.loopDetection;
|
|
414
414
|
if (options.contextShift !== undefined)
|
|
415
415
|
out.contextShift = options.contextShift;
|
|
416
|
+
if (options.speculative !== undefined)
|
|
417
|
+
out.speculative = options.speculative;
|
|
416
418
|
if (options.media !== undefined) {
|
|
417
419
|
const { maxFrames, fps, longestEdge, processor } = options.media;
|
|
418
420
|
out.media = {
|
package/dist/protocol.d.ts
CHANGED
|
@@ -108,6 +108,7 @@ export interface WireGenerateOptions {
|
|
|
108
108
|
readonly contextShift?: boolean | {
|
|
109
109
|
readonly keep?: number;
|
|
110
110
|
};
|
|
111
|
+
readonly speculative?: "off" | "auto" | number | boolean;
|
|
111
112
|
readonly media?: {
|
|
112
113
|
readonly maxFrames?: number;
|
|
113
114
|
readonly fps?: number;
|
|
@@ -393,6 +394,9 @@ export interface WireGenerationResult {
|
|
|
393
394
|
readonly reusedTokens: number;
|
|
394
395
|
readonly generatedTokens: number;
|
|
395
396
|
readonly droppedTokens: number;
|
|
397
|
+
readonly speculativePasses: number;
|
|
398
|
+
readonly draftedTokens: number;
|
|
399
|
+
readonly acceptedTokens: number;
|
|
396
400
|
readonly length: number;
|
|
397
401
|
readonly timeToFirstTokenMs: number;
|
|
398
402
|
readonly tokensPerSecond: number;
|
package/dist/simple.d.ts
CHANGED
|
@@ -72,6 +72,12 @@ export interface PromptOptions {
|
|
|
72
72
|
* prompt) instead of stopping: long chats keep going.
|
|
73
73
|
*/
|
|
74
74
|
readonly contextShift?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Draft-free speculative decoding: `"off"` (the default), `"auto"` or a
|
|
77
|
+
* number of drafted tokens per pass. Same answer, faster when it repeats
|
|
78
|
+
* its context (see `GenerateOptions.speculative`).
|
|
79
|
+
*/
|
|
80
|
+
readonly speculative?: "off" | "auto" | number | boolean;
|
|
75
81
|
/** Extra chat template variables, passed as is (`think` sets `enable_thinking`). */
|
|
76
82
|
readonly templateKwargs?: Readonly<Record<string, unknown>>;
|
|
77
83
|
/** Aborts the generation: `ask` then rejects with a `WebslmError` whose code is `"ABORTED"`. */
|
package/dist/simple.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -437,6 +437,16 @@ export interface GenerateOptions {
|
|
|
437
437
|
readonly contextShift?: boolean | {
|
|
438
438
|
readonly keep?: number;
|
|
439
439
|
};
|
|
440
|
+
/**
|
|
441
|
+
* Draft-free speculative decoding: the same tokens, several per forward
|
|
442
|
+
* pass when the text repeats its context (code edits, extraction,
|
|
443
|
+
* summaries). `"off"` (the default), `"auto"` (as many drafted tokens per
|
|
444
|
+
* pass as pay off on this device, none when nothing does), or the number
|
|
445
|
+
* of tokens to draft per pass (1 to 15); `true` is `"auto"`. Steps that
|
|
446
|
+
* need every logit (`logprobs`, `json`, `schema`) run one token at a time.
|
|
447
|
+
* See `acceptedTokens` and `draftedTokens` in the result.
|
|
448
|
+
*/
|
|
449
|
+
readonly speculative?: "off" | "auto" | number | boolean;
|
|
440
450
|
/** How the images and videos of the messages are read (vision-language models). */
|
|
441
451
|
readonly media?: MediaOptions;
|
|
442
452
|
/**
|
|
@@ -493,6 +503,12 @@ export interface GenerationResult {
|
|
|
493
503
|
readonly generatedTokens: number;
|
|
494
504
|
/** Tokens dropped from the context by `contextShift`. */
|
|
495
505
|
readonly droppedTokens: number;
|
|
506
|
+
/** Forward passes that verified drafted tokens (`speculative`). */
|
|
507
|
+
readonly speculativePasses: number;
|
|
508
|
+
/** Tokens drafted and verified by those passes. */
|
|
509
|
+
readonly draftedTokens: number;
|
|
510
|
+
/** Drafted tokens the model confirmed: `acceptedTokens / draftedTokens` is the acceptance rate. */
|
|
511
|
+
readonly acceptedTokens: number;
|
|
496
512
|
/** Milliseconds from the call to the first token. */
|
|
497
513
|
readonly timeToFirstTokenMs: number;
|
|
498
514
|
/** Decode speed after the first token. */
|
package/native-manifest.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.13.0",
|
|
3
3
|
"assets": {
|
|
4
4
|
"darwin-arm64": {
|
|
5
|
-
"file": "webslm-node-0.
|
|
6
|
-
"size":
|
|
7
|
-
"sha256": "
|
|
8
|
-
"nodeSha256": "
|
|
5
|
+
"file": "webslm-node-0.13.0-darwin-arm64.node.gz",
|
|
6
|
+
"size": 6174686,
|
|
7
|
+
"sha256": "59e5ce9d8d187ec3218eff5dded63300bed54f3218f2df7769ca98f892a29619",
|
|
8
|
+
"nodeSha256": "8b0e2c84df6e181b93907bb8606b71f57baffdc5de41bc3222c8d0e71ad2e56c"
|
|
9
9
|
},
|
|
10
10
|
"darwin-x64": {
|
|
11
|
-
"file": "webslm-node-0.
|
|
12
|
-
"size":
|
|
13
|
-
"sha256": "
|
|
14
|
-
"nodeSha256": "
|
|
11
|
+
"file": "webslm-node-0.13.0-darwin-x64.node.gz",
|
|
12
|
+
"size": 6543903,
|
|
13
|
+
"sha256": "a6c5e01c3c7c5675048dcf91c7489e8276531e1ddf9681e85e0b28cafd8a5d32",
|
|
14
|
+
"nodeSha256": "6e6756f8f4951690937047f225b15c11c6ab18ea62815d335fb1c3c7c19e7627"
|
|
15
15
|
},
|
|
16
16
|
"linux-x64-gnu": {
|
|
17
|
-
"file": "webslm-node-0.
|
|
18
|
-
"size":
|
|
19
|
-
"sha256": "
|
|
20
|
-
"nodeSha256": "
|
|
17
|
+
"file": "webslm-node-0.13.0-linux-x64-gnu.node.gz",
|
|
18
|
+
"size": 6552525,
|
|
19
|
+
"sha256": "2ebe10dc26f054f47f9bf4b6934343a4b9dbcfd255bb4299227b638f0b1733a8",
|
|
20
|
+
"nodeSha256": "9e15e8aa2f9b01da9406cbffb213f1876e4a6f8381fb0392dfa26a66712a5349"
|
|
21
21
|
},
|
|
22
22
|
"linux-arm64-gnu": {
|
|
23
|
-
"file": "webslm-node-0.
|
|
24
|
-
"size":
|
|
25
|
-
"sha256": "
|
|
26
|
-
"nodeSha256": "
|
|
23
|
+
"file": "webslm-node-0.13.0-linux-arm64-gnu.node.gz",
|
|
24
|
+
"size": 6135447,
|
|
25
|
+
"sha256": "9e9588f060c2bf188a685bc6da75435242c1b7c7ff726fc9facd1661e79acf55",
|
|
26
|
+
"nodeSha256": "5dd119e199da21a45a2391c147f3a602bdbafb817afdae068abc3e7c43fe2161"
|
|
27
27
|
},
|
|
28
28
|
"linux-x64-musl": {
|
|
29
|
-
"file": "webslm-node-0.
|
|
30
|
-
"size":
|
|
31
|
-
"sha256": "
|
|
32
|
-
"nodeSha256": "
|
|
29
|
+
"file": "webslm-node-0.13.0-linux-x64-musl.node.gz",
|
|
30
|
+
"size": 6981551,
|
|
31
|
+
"sha256": "3194b951bccb63a0475b3887200927f09cfd0410a088a126dfc8543975f7edfb",
|
|
32
|
+
"nodeSha256": "5a83e0e04d2d165e7df7ee609b2086adae10c1102274eb4908daeec53dc267b9"
|
|
33
33
|
},
|
|
34
34
|
"linux-arm64-musl": {
|
|
35
|
-
"file": "webslm-node-0.
|
|
36
|
-
"size":
|
|
37
|
-
"sha256": "
|
|
38
|
-
"nodeSha256": "
|
|
35
|
+
"file": "webslm-node-0.13.0-linux-arm64-musl.node.gz",
|
|
36
|
+
"size": 6696599,
|
|
37
|
+
"sha256": "de9d925624883bea7e323641caa0a88a430f318bc4338b20d11828e15d19cdf5",
|
|
38
|
+
"nodeSha256": "07c5cef40eb4496433486f1a09cb29d5f006be0c07f872932643aa7cf85cebbd"
|
|
39
39
|
},
|
|
40
40
|
"win32-x64-msvc": {
|
|
41
|
-
"file": "webslm-node-0.
|
|
42
|
-
"size":
|
|
43
|
-
"sha256": "
|
|
44
|
-
"nodeSha256": "
|
|
41
|
+
"file": "webslm-node-0.13.0-win32-x64-msvc.node.gz",
|
|
42
|
+
"size": 7111944,
|
|
43
|
+
"sha256": "846dc95f0b9f47a259fa773f06a053cde884729e3fc9b200b94ac68aaaca3f7e",
|
|
44
|
+
"nodeSha256": "ecdd04240db1b825d0cb571c8751730a947a7a39a9ddc2df66c5f8c1291c05e0"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webslm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Run small language models in the browser and in Node, straight from their original Hugging Face checkpoints: a Rust engine compiled to WebAssembly, in a worker, with an offline cache.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Maxime Golfier",
|
|
@@ -247,7 +247,8 @@ export class WasmSession {
|
|
|
247
247
|
*
|
|
248
248
|
* Generation controls: `presencePenalty`, `frequencyPenalty`,
|
|
249
249
|
* `stopTokenIds`, `logprobs` (number of alternatives), `json`, `schema`,
|
|
250
|
-
* `thinkingBudget`, `loopDetection`, `contextShift
|
|
250
|
+
* `thinkingBudget`, `loopDetection`, `contextShift`, `speculative`
|
|
251
|
+
* (`"off"`, `"auto"` or a number of drafted tokens per pass).
|
|
251
252
|
*
|
|
252
253
|
* `on_delta(text, tokenId, info)` runs after every token; `info` is
|
|
253
254
|
* `undefined` or `{ logprob, topLogprobs: [id, logprob][], forced }`.
|
|
@@ -255,7 +256,8 @@ export class WasmSession {
|
|
|
255
256
|
* generation before the next token. `on_prefill(done, total)`, when
|
|
256
257
|
* given, runs after every piece of the prompt (128 tokens) and may stop
|
|
257
258
|
* it the same way. Resolves to `{ text, tokens, finishReason,
|
|
258
|
-
* promptTokens, reusedTokens, generatedTokens, droppedTokens,
|
|
259
|
+
* promptTokens, reusedTokens, generatedTokens, droppedTokens,
|
|
260
|
+
* speculativePasses, draftedTokens, acceptedTokens, length }`;
|
|
259
261
|
* `finishReason` is `"stop"`, `"stop_string"`, `"length"`,
|
|
260
262
|
* `"context_full"`, `"loop"` or `"aborted"`.
|
|
261
263
|
*/
|
|
@@ -602,7 +602,8 @@ export class WasmSession {
|
|
|
602
602
|
*
|
|
603
603
|
* Generation controls: `presencePenalty`, `frequencyPenalty`,
|
|
604
604
|
* `stopTokenIds`, `logprobs` (number of alternatives), `json`, `schema`,
|
|
605
|
-
* `thinkingBudget`, `loopDetection`, `contextShift
|
|
605
|
+
* `thinkingBudget`, `loopDetection`, `contextShift`, `speculative`
|
|
606
|
+
* (`"off"`, `"auto"` or a number of drafted tokens per pass).
|
|
606
607
|
*
|
|
607
608
|
* `on_delta(text, tokenId, info)` runs after every token; `info` is
|
|
608
609
|
* `undefined` or `{ logprob, topLogprobs: [id, logprob][], forced }`.
|
|
@@ -610,7 +611,8 @@ export class WasmSession {
|
|
|
610
611
|
* generation before the next token. `on_prefill(done, total)`, when
|
|
611
612
|
* given, runs after every piece of the prompt (128 tokens) and may stop
|
|
612
613
|
* it the same way. Resolves to `{ text, tokens, finishReason,
|
|
613
|
-
* promptTokens, reusedTokens, generatedTokens, droppedTokens,
|
|
614
|
+
* promptTokens, reusedTokens, generatedTokens, droppedTokens,
|
|
615
|
+
* speculativePasses, draftedTokens, acceptedTokens, length }`;
|
|
614
616
|
* `finishReason` is `"stop"`, `"stop_string"`, `"length"`,
|
|
615
617
|
* `"context_full"`, `"loop"` or `"aborted"`.
|
|
616
618
|
* @param {string} messages_json
|
|
@@ -1054,6 +1056,12 @@ function __wbg_get_imports() {
|
|
|
1054
1056
|
const ret = arg0 === arg1;
|
|
1055
1057
|
return ret;
|
|
1056
1058
|
},
|
|
1059
|
+
__wbg___wbindgen_number_get_1dc732b810cb937c: function(arg0, arg1) {
|
|
1060
|
+
const obj = arg1;
|
|
1061
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
1062
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
1063
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
1064
|
+
},
|
|
1057
1065
|
__wbg___wbindgen_string_get_92ab86bb19cbc12f: function(arg0, arg1) {
|
|
1058
1066
|
const obj = arg1;
|
|
1059
1067
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
@@ -1824,32 +1832,32 @@ function __wbg_get_imports() {
|
|
|
1824
1832
|
arg0.writeBuffer(arg1, arg2, getArrayU8FromWasm0(arg3, arg4), arg5, arg6);
|
|
1825
1833
|
}, arguments); },
|
|
1826
1834
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
1827
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1835
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 396, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1828
1836
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1829
1837
|
return ret;
|
|
1830
1838
|
},
|
|
1831
1839
|
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1832
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx:
|
|
1840
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 322, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1833
1841
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1834
1842
|
return ret;
|
|
1835
1843
|
},
|
|
1836
1844
|
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
1837
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx:
|
|
1845
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 326, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1838
1846
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_);
|
|
1839
1847
|
return ret;
|
|
1840
1848
|
},
|
|
1841
1849
|
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
|
|
1842
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx:
|
|
1850
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 326, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1843
1851
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__55);
|
|
1844
1852
|
return ret;
|
|
1845
1853
|
},
|
|
1846
1854
|
__wbindgen_generic_0000000000000005: function(arg0, arg1) {
|
|
1847
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx:
|
|
1855
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 322, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1848
1856
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__56);
|
|
1849
1857
|
return ret;
|
|
1850
1858
|
},
|
|
1851
1859
|
__wbindgen_generic_0000000000000006: function(arg0, arg1) {
|
|
1852
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx:
|
|
1860
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 322, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1853
1861
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__57);
|
|
1854
1862
|
return ret;
|
|
1855
1863
|
},
|
|
Binary file
|
|
@@ -247,7 +247,8 @@ export class WasmSession {
|
|
|
247
247
|
*
|
|
248
248
|
* Generation controls: `presencePenalty`, `frequencyPenalty`,
|
|
249
249
|
* `stopTokenIds`, `logprobs` (number of alternatives), `json`, `schema`,
|
|
250
|
-
* `thinkingBudget`, `loopDetection`, `contextShift
|
|
250
|
+
* `thinkingBudget`, `loopDetection`, `contextShift`, `speculative`
|
|
251
|
+
* (`"off"`, `"auto"` or a number of drafted tokens per pass).
|
|
251
252
|
*
|
|
252
253
|
* `on_delta(text, tokenId, info)` runs after every token; `info` is
|
|
253
254
|
* `undefined` or `{ logprob, topLogprobs: [id, logprob][], forced }`.
|
|
@@ -255,7 +256,8 @@ export class WasmSession {
|
|
|
255
256
|
* generation before the next token. `on_prefill(done, total)`, when
|
|
256
257
|
* given, runs after every piece of the prompt (128 tokens) and may stop
|
|
257
258
|
* it the same way. Resolves to `{ text, tokens, finishReason,
|
|
258
|
-
* promptTokens, reusedTokens, generatedTokens, droppedTokens,
|
|
259
|
+
* promptTokens, reusedTokens, generatedTokens, droppedTokens,
|
|
260
|
+
* speculativePasses, draftedTokens, acceptedTokens, length }`;
|
|
259
261
|
* `finishReason` is `"stop"`, `"stop_string"`, `"length"`,
|
|
260
262
|
* `"context_full"`, `"loop"` or `"aborted"`.
|
|
261
263
|
*/
|
package/wasm/simd/webslm_wasm.js
CHANGED
|
@@ -602,7 +602,8 @@ export class WasmSession {
|
|
|
602
602
|
*
|
|
603
603
|
* Generation controls: `presencePenalty`, `frequencyPenalty`,
|
|
604
604
|
* `stopTokenIds`, `logprobs` (number of alternatives), `json`, `schema`,
|
|
605
|
-
* `thinkingBudget`, `loopDetection`, `contextShift
|
|
605
|
+
* `thinkingBudget`, `loopDetection`, `contextShift`, `speculative`
|
|
606
|
+
* (`"off"`, `"auto"` or a number of drafted tokens per pass).
|
|
606
607
|
*
|
|
607
608
|
* `on_delta(text, tokenId, info)` runs after every token; `info` is
|
|
608
609
|
* `undefined` or `{ logprob, topLogprobs: [id, logprob][], forced }`.
|
|
@@ -610,7 +611,8 @@ export class WasmSession {
|
|
|
610
611
|
* generation before the next token. `on_prefill(done, total)`, when
|
|
611
612
|
* given, runs after every piece of the prompt (128 tokens) and may stop
|
|
612
613
|
* it the same way. Resolves to `{ text, tokens, finishReason,
|
|
613
|
-
* promptTokens, reusedTokens, generatedTokens, droppedTokens,
|
|
614
|
+
* promptTokens, reusedTokens, generatedTokens, droppedTokens,
|
|
615
|
+
* speculativePasses, draftedTokens, acceptedTokens, length }`;
|
|
614
616
|
* `finishReason` is `"stop"`, `"stop_string"`, `"length"`,
|
|
615
617
|
* `"context_full"`, `"loop"` or `"aborted"`.
|
|
616
618
|
* @param {string} messages_json
|
|
@@ -1054,6 +1056,12 @@ function __wbg_get_imports() {
|
|
|
1054
1056
|
const ret = arg0 === arg1;
|
|
1055
1057
|
return ret;
|
|
1056
1058
|
},
|
|
1059
|
+
__wbg___wbindgen_number_get_1dc732b810cb937c: function(arg0, arg1) {
|
|
1060
|
+
const obj = arg1;
|
|
1061
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
1062
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
1063
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
1064
|
+
},
|
|
1057
1065
|
__wbg___wbindgen_string_get_92ab86bb19cbc12f: function(arg0, arg1) {
|
|
1058
1066
|
const obj = arg1;
|
|
1059
1067
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
@@ -1824,32 +1832,32 @@ function __wbg_get_imports() {
|
|
|
1824
1832
|
arg0.writeBuffer(arg1, arg2, getArrayU8FromWasm0(arg3, arg4), arg5, arg6);
|
|
1825
1833
|
}, arguments); },
|
|
1826
1834
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
1827
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1835
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 386, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1828
1836
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1829
1837
|
return ret;
|
|
1830
1838
|
},
|
|
1831
1839
|
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1832
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx:
|
|
1840
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 312, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1833
1841
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1834
1842
|
return ret;
|
|
1835
1843
|
},
|
|
1836
1844
|
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
1837
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx:
|
|
1845
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 316, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1838
1846
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_);
|
|
1839
1847
|
return ret;
|
|
1840
1848
|
},
|
|
1841
1849
|
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
|
|
1842
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx:
|
|
1850
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 316, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1843
1851
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__55);
|
|
1844
1852
|
return ret;
|
|
1845
1853
|
},
|
|
1846
1854
|
__wbindgen_generic_0000000000000005: function(arg0, arg1) {
|
|
1847
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx:
|
|
1855
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 312, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1848
1856
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__56);
|
|
1849
1857
|
return ret;
|
|
1850
1858
|
},
|
|
1851
1859
|
__wbindgen_generic_0000000000000006: function(arg0, arg1) {
|
|
1852
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx:
|
|
1860
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 312, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1853
1861
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__57);
|
|
1854
1862
|
return ret;
|
|
1855
1863
|
},
|
|
Binary file
|
|
@@ -247,7 +247,8 @@ export class WasmSession {
|
|
|
247
247
|
*
|
|
248
248
|
* Generation controls: `presencePenalty`, `frequencyPenalty`,
|
|
249
249
|
* `stopTokenIds`, `logprobs` (number of alternatives), `json`, `schema`,
|
|
250
|
-
* `thinkingBudget`, `loopDetection`, `contextShift
|
|
250
|
+
* `thinkingBudget`, `loopDetection`, `contextShift`, `speculative`
|
|
251
|
+
* (`"off"`, `"auto"` or a number of drafted tokens per pass).
|
|
251
252
|
*
|
|
252
253
|
* `on_delta(text, tokenId, info)` runs after every token; `info` is
|
|
253
254
|
* `undefined` or `{ logprob, topLogprobs: [id, logprob][], forced }`.
|
|
@@ -255,7 +256,8 @@ export class WasmSession {
|
|
|
255
256
|
* generation before the next token. `on_prefill(done, total)`, when
|
|
256
257
|
* given, runs after every piece of the prompt (128 tokens) and may stop
|
|
257
258
|
* it the same way. Resolves to `{ text, tokens, finishReason,
|
|
258
|
-
* promptTokens, reusedTokens, generatedTokens, droppedTokens,
|
|
259
|
+
* promptTokens, reusedTokens, generatedTokens, droppedTokens,
|
|
260
|
+
* speculativePasses, draftedTokens, acceptedTokens, length }`;
|
|
259
261
|
* `finishReason` is `"stop"`, `"stop_string"`, `"length"`,
|
|
260
262
|
* `"context_full"`, `"loop"` or `"aborted"`.
|
|
261
263
|
*/
|
|
@@ -604,7 +604,8 @@ export class WasmSession {
|
|
|
604
604
|
*
|
|
605
605
|
* Generation controls: `presencePenalty`, `frequencyPenalty`,
|
|
606
606
|
* `stopTokenIds`, `logprobs` (number of alternatives), `json`, `schema`,
|
|
607
|
-
* `thinkingBudget`, `loopDetection`, `contextShift
|
|
607
|
+
* `thinkingBudget`, `loopDetection`, `contextShift`, `speculative`
|
|
608
|
+
* (`"off"`, `"auto"` or a number of drafted tokens per pass).
|
|
608
609
|
*
|
|
609
610
|
* `on_delta(text, tokenId, info)` runs after every token; `info` is
|
|
610
611
|
* `undefined` or `{ logprob, topLogprobs: [id, logprob][], forced }`.
|
|
@@ -612,7 +613,8 @@ export class WasmSession {
|
|
|
612
613
|
* generation before the next token. `on_prefill(done, total)`, when
|
|
613
614
|
* given, runs after every piece of the prompt (128 tokens) and may stop
|
|
614
615
|
* it the same way. Resolves to `{ text, tokens, finishReason,
|
|
615
|
-
* promptTokens, reusedTokens, generatedTokens, droppedTokens,
|
|
616
|
+
* promptTokens, reusedTokens, generatedTokens, droppedTokens,
|
|
617
|
+
* speculativePasses, draftedTokens, acceptedTokens, length }`;
|
|
616
618
|
* `finishReason` is `"stop"`, `"stop_string"`, `"length"`,
|
|
617
619
|
* `"context_full"`, `"loop"` or `"aborted"`.
|
|
618
620
|
* @param {string} messages_json
|
|
@@ -1129,6 +1131,12 @@ function __wbg_get_imports(memory) {
|
|
|
1129
1131
|
const ret = wasmModule;
|
|
1130
1132
|
return ret;
|
|
1131
1133
|
},
|
|
1134
|
+
__wbg___wbindgen_number_get_1dc732b810cb937c: function(arg0, arg1) {
|
|
1135
|
+
const obj = arg1;
|
|
1136
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
1137
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
1138
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
1139
|
+
},
|
|
1132
1140
|
__wbg___wbindgen_rethrow_dba7bb2caa14ba21: function(arg0) {
|
|
1133
1141
|
throw arg0;
|
|
1134
1142
|
},
|
|
@@ -1984,42 +1992,42 @@ function __wbg_get_imports(memory) {
|
|
|
1984
1992
|
arg0.writeBuffer(arg1, arg2, getArrayU8FromWasm0(arg3, arg4), arg5, arg6);
|
|
1985
1993
|
}, arguments); },
|
|
1986
1994
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
1987
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1995
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1063, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1988
1996
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue__core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true_);
|
|
1989
1997
|
return ret;
|
|
1990
1998
|
},
|
|
1991
1999
|
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1992
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
2000
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1065, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1993
2001
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___js_sys_b608be85a12bc1d0___futures__task__wait_async_polyfill__MessageEvent______true_);
|
|
1994
2002
|
return ret;
|
|
1995
2003
|
},
|
|
1996
2004
|
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
1997
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
2005
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 509, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1998
2006
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true_);
|
|
1999
2007
|
return ret;
|
|
2000
2008
|
},
|
|
2001
2009
|
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
|
|
2002
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx:
|
|
2010
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 507, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
2003
2011
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true_);
|
|
2004
2012
|
return ret;
|
|
2005
2013
|
},
|
|
2006
2014
|
__wbindgen_generic_0000000000000005: function(arg0, arg1) {
|
|
2007
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx:
|
|
2015
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 509, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2008
2016
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__62);
|
|
2009
2017
|
return ret;
|
|
2010
2018
|
},
|
|
2011
2019
|
__wbindgen_generic_0000000000000006: function(arg0, arg1) {
|
|
2012
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx:
|
|
2020
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 509, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2013
2021
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__63);
|
|
2014
2022
|
return ret;
|
|
2015
2023
|
},
|
|
2016
2024
|
__wbindgen_generic_0000000000000007: function(arg0, arg1) {
|
|
2017
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx:
|
|
2025
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 507, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
2018
2026
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__64);
|
|
2019
2027
|
return ret;
|
|
2020
2028
|
},
|
|
2021
2029
|
__wbindgen_generic_0000000000000008: function(arg0, arg1) {
|
|
2022
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx:
|
|
2030
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 507, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
2023
2031
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__65);
|
|
2024
2032
|
return ret;
|
|
2025
2033
|
},
|
|
Binary file
|