isorite 0.3.0 → 0.3.1
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 +1 -1
- package/dist/embed-worker.js +9 -4
- package/dist/main.js +4205 -3670
- package/docs/setup-for-agents.md +25 -1
- package/docs/setup.md +23 -1
- package/docs/terminal.md +7 -3
- package/package.json +1 -1
- package/web/_app/immutable/chunks/{BN1DRYj2.js → 8IM6BNk6.js} +1 -1
- package/web/_app/immutable/chunks/{BNCmWi9e.js → BHPhFydX.js} +1 -1
- package/web/_app/immutable/chunks/{BqrPWk6N.js → CFA70_0c.js} +1 -1
- package/web/_app/immutable/chunks/CGgq5NWd.js +1 -0
- package/web/_app/immutable/chunks/{BcrJkegU.js → CHlFgDNB.js} +1 -1
- package/web/_app/immutable/chunks/CMp5T_-1.js +1 -0
- package/web/_app/immutable/chunks/{-XH9wLvF.js → D89YN-Dr.js} +1 -1
- package/web/_app/immutable/chunks/DF3lgcLW.js +1 -0
- package/web/_app/immutable/chunks/DGVcYHaJ.js +43 -0
- package/web/_app/immutable/chunks/{Cr4-_2Vw.js → DmgpLvxp.js} +1 -1
- package/web/_app/immutable/chunks/{D8jeeZa0.js → DrsVvzvg.js} +1 -1
- package/web/_app/immutable/entry/{app.B9MdwZzs.js → app.hlk6OrE8.js} +2 -2
- package/web/_app/immutable/entry/start.BE1F0HZV.js +1 -0
- package/web/_app/immutable/nodes/0.DMGdYhkH.js +15 -0
- package/web/_app/immutable/nodes/{1.hmQ_l8t-.js → 1.Dn_0fgt7.js} +1 -1
- package/web/_app/immutable/nodes/2.Y1Dd5PBI.js +1 -0
- package/web/_app/immutable/nodes/3.BlxuRbLf.js +1 -0
- package/web/_app/immutable/nodes/{4.QUhLgH4i.js → 4.Bt_H0MbN.js} +1 -1
- package/web/_app/immutable/nodes/{5.D3JSWVyR.js → 5.BJ-EVWbz.js} +1 -1
- package/web/_app/immutable/nodes/6.DDIiJnwi.js +1 -0
- package/web/_app/version.json +1 -1
- package/web/index.html +15 -15
- package/web/_app/immutable/chunks/BZeALCyJ.js +0 -1
- package/web/_app/immutable/chunks/BavLcJN1.js +0 -1
- package/web/_app/immutable/chunks/D25FgEb3.js +0 -43
- package/web/_app/immutable/chunks/DsnHcTIO.js +0 -1
- package/web/_app/immutable/entry/start.gtQcHKDR.js +0 -1
- package/web/_app/immutable/nodes/0.DSajjyn5.js +0 -15
- package/web/_app/immutable/nodes/2.Bu6Zvx8F.js +0 -1
- package/web/_app/immutable/nodes/3.DcSG1nNk.js +0 -1
- package/web/_app/immutable/nodes/6.CWfUNDww.js +0 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ npm install -g isorite
|
|
|
9
9
|
isorite --tutorial # the tutorial: the terminal's tour, and the browser's beside it, on an example base
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
On your own notes, a folder of Markdown files (
|
|
12
|
+
On your own notes, a folder of Markdown files (`isorite new <notes>` starts one):
|
|
13
13
|
|
|
14
14
|
```sh
|
|
15
15
|
isorite serve <notes> # the browser, at http://localhost:4767/; set Iso's provider key behind the logo
|
package/dist/embed-worker.js
CHANGED
|
@@ -3212,14 +3212,15 @@ var init_ort_wasm_bundle_min = __esmMin((() => {
|
|
|
3212
3212
|
//#endregion
|
|
3213
3213
|
//#region packages/server/src/embed-worker.ts
|
|
3214
3214
|
const MAX_TOKENS = 512;
|
|
3215
|
-
const { dir, dim } = workerData;
|
|
3215
|
+
const { dir, dim, pooling } = workerData;
|
|
3216
3216
|
const ort = await Promise.resolve().then(() => (init_ort_wasm_bundle_min(), ort_wasm_bundle_min_exports));
|
|
3217
3217
|
const { Tokenizer } = await import("@huggingface/tokenizers");
|
|
3218
3218
|
ort.env.wasm.numThreads = 1;
|
|
3219
3219
|
const WASM = "ort-wasm-simd-threaded.wasm";
|
|
3220
3220
|
const beside = join(dirname(fileURLToPath(import.meta.url)), WASM);
|
|
3221
3221
|
ort.env.wasm.wasmBinary = readFileSync(existsSync(beside) ? beside : join(dirname(createRequire(import.meta.url).resolve("onnxruntime-web")), WASM));
|
|
3222
|
-
const
|
|
3222
|
+
const config = join(dir, "tokenizer_config.json");
|
|
3223
|
+
const tok = new Tokenizer(JSON.parse(readFileSync(join(dir, "tokenizer.json"), "utf8")), existsSync(config) ? JSON.parse(readFileSync(config, "utf8")) : {});
|
|
3223
3224
|
const externalData = readdirSync(dir).filter((f) => f.endsWith(".onnx_data")).map((path) => ({
|
|
3224
3225
|
path,
|
|
3225
3226
|
data: readFileSync(join(dir, path))
|
|
@@ -3238,8 +3239,12 @@ async function embed(text) {
|
|
|
3238
3239
|
attention_mask: big(ids.map(() => 1)),
|
|
3239
3240
|
...typed ? { token_type_ids: big(ids.map(() => 0)) } : {}
|
|
3240
3241
|
});
|
|
3241
|
-
const state = out.last_hidden_state ?? Object.values(out)[0];
|
|
3242
|
-
|
|
3242
|
+
const state = out.last_hidden_state ?? Object.values(out)[0], width = state.dims.at(-1), data = state.data;
|
|
3243
|
+
if (width !== dim) throw new Error(`its vectors have ${width} numbers, not ${dim}`);
|
|
3244
|
+
if (pooling === "cls" || state.dims.length < 3) return Float32Array.from(data.subarray(0, dim));
|
|
3245
|
+
const n = data.length / dim, mean = new Float32Array(dim);
|
|
3246
|
+
for (let t = 0; t < n; t++) for (let k = 0; k < dim; k++) mean[k] += data[t * dim + k] / n;
|
|
3247
|
+
return mean;
|
|
3243
3248
|
}
|
|
3244
3249
|
parentPort.on("message", (m) => {
|
|
3245
3250
|
embed(m.text).then((vector) => parentPort.postMessage({
|