decidekit 0.2.1 → 0.2.2
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/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +14 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.2 (2026-11-02)
|
|
4
|
+
|
|
5
|
+
### Browser
|
|
6
|
+
|
|
7
|
+
- New option `wasmHost` serves onnxruntime's wasm from your own host instead of jsDelivr. It applies to the whole page or process.
|
|
8
|
+
- The docs now say the wasm comes from jsDelivr. The FAQ on network requests left that out before.
|
|
9
|
+
|
|
3
10
|
## 0.2.1 (2026-11-02)
|
|
4
11
|
|
|
5
12
|
### Browser
|
package/README.md
CHANGED
|
@@ -155,7 +155,7 @@ decidekit runs the Decide models, each a sentence encoder plus a calibrated head
|
|
|
155
155
|
| Decide Multilingual | [`debuffjp/decide-multilingual`](https://huggingface.co/debuffjp/decide-multilingual) | about 118 MB | 76% on Japanese and Chinese intents | intfloat's [multilingual-e5-small](https://huggingface.co/intfloat/multilingual-e5-small), identical to `Xenova/multilingual-e5-small` |
|
|
156
156
|
|
|
157
157
|
Pass the id as `model` to `createDecider()`. The files download from Hugging Face on first use, pinned to a revision, and
|
|
158
|
-
are then cached. To serve them yourself, pass `modelHost`: see [self-hosting](docs/guide-browser.md#host-the-model-files-yourself).
|
|
158
|
+
are then cached. To serve them yourself, pass `modelHost`: see [self-hosting](docs/guide-browser.md#host-the-model-files-yourself). onnxruntime's wasm comes from jsDelivr unless you pass [`wasmHost`](docs/guide-browser.md#host-the-wasm-yourself).
|
|
159
159
|
|
|
160
160
|
Before 0.1.1 the default id was `Xenova/bge-small-en-v1.5`. The old ids and heads recording them keep working: they
|
|
161
161
|
resolve to the new ids, so `d.model` returns the new id.
|
package/dist/index.d.ts
CHANGED
|
@@ -90,6 +90,12 @@ export interface DeciderOptions {
|
|
|
90
90
|
* `https://cdn.example.com/models/debuffjp/decide-small/onnx/model_quantized.onnx`. Applies to the whole page or process.
|
|
91
91
|
*/
|
|
92
92
|
modelHost?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Serve onnxruntime's wasm from your own host instead of jsDelivr, as `<wasmHost>/ort-wasm-simd-threaded.wasm` and
|
|
95
|
+
* `.mjs` (`ort-wasm-simd-threaded.asyncify.*` with `device: "webgpu"`). Copy them from `onnxruntime-web/dist`.
|
|
96
|
+
* Applies to the whole page or process.
|
|
97
|
+
*/
|
|
98
|
+
wasmHost?: string;
|
|
93
99
|
/** Weight precision. Default `q8`. */
|
|
94
100
|
dtype?: "q8" | "fp16" | "fp32";
|
|
95
101
|
/** Called as model files download (first load only; later loads come from cache). */
|
|
@@ -109,7 +115,7 @@ export interface DeciderOptions {
|
|
|
109
115
|
* `train()`. In a browser, prefer `createWorkerDecider()` from `decidekit/browser`: the encoder blocks the thread
|
|
110
116
|
* it runs on.
|
|
111
117
|
*/
|
|
112
|
-
export declare function createDecider({ model: requested, device, dtype, temperature, onProgress, modelHost }?: DeciderOptions): Promise<{
|
|
118
|
+
export declare function createDecider({ model: requested, device, dtype, temperature, onProgress, modelHost, wasmHost }?: DeciderOptions): Promise<{
|
|
113
119
|
model: string;
|
|
114
120
|
decide: {
|
|
115
121
|
<const L extends string>(text: string, using: Choices<L>, options?: {
|
package/dist/index.js
CHANGED
|
@@ -40,10 +40,20 @@ function toDecision(labels, p) {
|
|
|
40
40
|
const probabilities = Object.fromEntries(labels.map((l, i) => [l, p[i]]));
|
|
41
41
|
return { choice: labels[best], confidence: p[best], probabilities };
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function chooseWasm(webgpu, wasmHost) {
|
|
44
|
+
const wasm = env.backends.onnx.wasm;
|
|
45
|
+
if (!wasm)
|
|
46
|
+
return;
|
|
47
|
+
if (wasmHost) {
|
|
48
|
+
const file = (wasmHost.endsWith("/") ? wasmHost : wasmHost + "/") + (webgpu ? "ort-wasm-simd-threaded.asyncify" : "ort-wasm-simd-threaded");
|
|
49
|
+
wasm.wasmPaths = { wasm: file + ".wasm", mjs: file + ".mjs" };
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (webgpu)
|
|
53
|
+
return;
|
|
44
54
|
// transformers.js points browsers other than Safari at the 23.6 MB WebGPU-capable build whatever JS is bundled.
|
|
45
55
|
// Leaves paths the app set itself alone.
|
|
46
|
-
const paths =
|
|
56
|
+
const paths = wasm.wasmPaths;
|
|
47
57
|
if (!paths || typeof paths === "string" || !paths.wasm?.startsWith("https://cdn.jsdelivr.net/npm/onnxruntime-web@"))
|
|
48
58
|
return;
|
|
49
59
|
paths.wasm = paths.wasm.replace(".asyncify.", ".");
|
|
@@ -54,14 +64,13 @@ function usePlainWasm() {
|
|
|
54
64
|
* `train()`. In a browser, prefer `createWorkerDecider()` from `decidekit/browser`: the encoder blocks the thread
|
|
55
65
|
* it runs on.
|
|
56
66
|
*/
|
|
57
|
-
export async function createDecider({ model: requested = SMALL, device, dtype = "q8", temperature, onProgress, modelHost } = {}) {
|
|
67
|
+
export async function createDecider({ model: requested = SMALL, device, dtype = "q8", temperature, onProgress, modelHost, wasmHost } = {}) {
|
|
58
68
|
const model = canonical(requested);
|
|
59
69
|
if (modelHost) {
|
|
60
70
|
env.remoteHost = modelHost.endsWith("/") ? modelHost : modelHost + "/";
|
|
61
71
|
env.remotePathTemplate = "{model}/";
|
|
62
72
|
}
|
|
63
|
-
|
|
64
|
-
usePlainWasm();
|
|
73
|
+
chooseWasm(device === "webgpu", wasmHost);
|
|
65
74
|
const embed = await pipeline("feature-extraction", model, {
|
|
66
75
|
device, dtype, revision: REVISIONS[model],
|
|
67
76
|
progress_callback: onProgress && ((p) => p.status === "progress" && onProgress({ file: p.file, loaded: p.loaded, total: p.total })),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "decidekit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A System One model in the browser: typed, calibrated text decisions on the user's device. Learns from an LLM when it isn't sure.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "github:debuffjp/decidekit",
|