kjarni-wasm 0.2.5 → 0.2.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kjarni-wasm",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Local AI inference in the browser: embeddings, classification, reranking, semantic search and chat, running in a Web Worker.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -77,15 +77,18 @@ export class WasmChat {
77
77
 
78
78
  /**
79
79
  * Sequence classification: sentiment, emotion, toxicity.
80
- *
81
- * New to the browser. Classification was always in the engine but never had a
82
- * binding here, because this crate previously carried its own encoder and nobody
83
- * wrote a second classifier head for it.
84
80
  */
85
81
  export class WasmClassifier {
86
82
  private constructor();
87
83
  free(): void;
88
84
  [Symbol.dispose](): void;
85
+ /**
86
+ * Classify a batch, returning the single best label for each input.
87
+ *
88
+ * One result per input, in input order, so the caller can line them up with
89
+ * whatever it passed in.
90
+ */
91
+ classify_batch(texts: string[]): any;
89
92
  /**
90
93
  * Classify one text, returning every label with its score, highest first.
91
94
  *
@@ -94,13 +97,6 @@ export class WasmClassifier {
94
97
  * what makes the behaviour testable on the host.
95
98
  */
96
99
  classify(text: string): any;
97
- /**
98
- * Classify a batch, returning the single best label for each input.
99
- *
100
- * One result per input, in input order, so the caller can line them up with
101
- * whatever it passed in.
102
- */
103
- classify_batch(texts: string[]): any;
104
100
  /**
105
101
  * The labels this model predicts, in index order.
106
102
  */
@@ -171,8 +167,7 @@ export class WasmReranker {
171
167
  /**
172
168
  * Load a cross-encoder from a `.kjq` container.
173
169
  *
174
- * The classifier head used to be pulled out of the weights by hand here; the
175
- * engine's `CrossEncoder` loads it as part of the model.
170
+ * The engine's `CrossEncoder` loads the classifier head as part of the model.
176
171
  */
177
172
  static load(data: Uint8Array): WasmReranker;
178
173
  /**
@@ -255,8 +250,8 @@ export interface InitOutput {
255
250
  readonly wasmsearch_search_keywords: (a: number, b: number, c: number, d: number, e: number) => void;
256
251
  readonly wasmsearch_search_semantic: (a: number, b: number, c: number, d: number, e: number) => void;
257
252
  readonly wasmsearch_update_file: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
258
- readonly __wasm_bindgen_func_elem_5726: (a: number, b: number, c: number, d: number) => void;
259
- readonly __wasm_bindgen_func_elem_5744: (a: number, b: number, c: number, d: number) => void;
253
+ readonly __wasm_bindgen_func_elem_5706: (a: number, b: number, c: number, d: number) => void;
254
+ readonly __wasm_bindgen_func_elem_5724: (a: number, b: number, c: number, d: number) => void;
260
255
  readonly __wbindgen_export: (a: number, b: number) => number;
261
256
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
262
257
  readonly __wbindgen_export3: (a: number) => void;
@@ -229,10 +229,6 @@ if (Symbol.dispose) WasmChat.prototype[Symbol.dispose] = WasmChat.prototype.free
229
229
 
230
230
  /**
231
231
  * Sequence classification: sentiment, emotion, toxicity.
232
- *
233
- * New to the browser. Classification was always in the engine but never had a
234
- * binding here, because this crate previously carried its own encoder and nobody
235
- * wrote a second classifier head for it.
236
232
  */
237
233
  export class WasmClassifier {
238
234
  static __wrap(ptr) {
@@ -252,20 +248,19 @@ export class WasmClassifier {
252
248
  wasm.__wbg_wasmclassifier_free(ptr, 0);
253
249
  }
254
250
  /**
255
- * Classify one text, returning every label with its score, highest first.
251
+ * Classify a batch, returning the single best label for each input.
256
252
  *
257
- * Serializing to a `JsValue` panics outside wasm32, so the work lives in
258
- * [`WasmClassifier::classify_core`] and this is only the conversion. That is
259
- * what makes the behaviour testable on the host.
260
- * @param {string} text
253
+ * One result per input, in input order, so the caller can line them up with
254
+ * whatever it passed in.
255
+ * @param {string[]} texts
261
256
  * @returns {any}
262
257
  */
263
- classify(text) {
258
+ classify_batch(texts) {
264
259
  try {
265
260
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
266
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
261
+ const ptr0 = passArrayJsValueToWasm0(texts, wasm.__wbindgen_export);
267
262
  const len0 = WASM_VECTOR_LEN;
268
- wasm.wasmclassifier_classify(retptr, this.__wbg_ptr, ptr0, len0);
263
+ wasm.wasmclassifier_classify_batch(retptr, this.__wbg_ptr, ptr0, len0);
269
264
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
270
265
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
271
266
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -278,19 +273,20 @@ export class WasmClassifier {
278
273
  }
279
274
  }
280
275
  /**
281
- * Classify a batch, returning the single best label for each input.
276
+ * Classify one text, returning every label with its score, highest first.
282
277
  *
283
- * One result per input, in input order, so the caller can line them up with
284
- * whatever it passed in.
285
- * @param {string[]} texts
278
+ * Serializing to a `JsValue` panics outside wasm32, so the work lives in
279
+ * [`WasmClassifier::classify_core`] and this is only the conversion. That is
280
+ * what makes the behaviour testable on the host.
281
+ * @param {string} text
286
282
  * @returns {any}
287
283
  */
288
- classify_batch(texts) {
284
+ classify(text) {
289
285
  try {
290
286
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
291
- const ptr0 = passArrayJsValueToWasm0(texts, wasm.__wbindgen_export);
287
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
292
288
  const len0 = WASM_VECTOR_LEN;
293
- wasm.wasmclassifier_classify_batch(retptr, this.__wbg_ptr, ptr0, len0);
289
+ wasm.wasmclassifier_classify(retptr, this.__wbg_ptr, ptr0, len0);
294
290
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
295
291
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
296
292
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -673,8 +669,7 @@ export class WasmReranker {
673
669
  /**
674
670
  * Load a cross-encoder from a `.kjq` container.
675
671
  *
676
- * The classifier head used to be pulled out of the weights by hand here; the
677
- * engine's `CrossEncoder` loads it as part of the model.
672
+ * The engine's `CrossEncoder` loads the classifier head as part of the model.
678
673
  * @param {Uint8Array} data
679
674
  * @returns {WasmReranker}
680
675
  */
@@ -1114,7 +1109,7 @@ function __wbg_get_imports() {
1114
1109
  const a = state0.a;
1115
1110
  state0.a = 0;
1116
1111
  try {
1117
- return __wasm_bindgen_func_elem_5744(a, state0.b, arg0, arg1);
1112
+ return __wasm_bindgen_func_elem_5724(a, state0.b, arg0, arg1);
1118
1113
  } finally {
1119
1114
  state0.a = a;
1120
1115
  }
@@ -1228,8 +1223,8 @@ function __wbg_get_imports() {
1228
1223
  return addHeapObject(ret);
1229
1224
  },
1230
1225
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
1231
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2101, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1232
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_5726);
1226
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2079, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1227
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_5706);
1233
1228
  return addHeapObject(ret);
1234
1229
  },
1235
1230
  __wbindgen_generic_0000000000000002: function(arg0) {
@@ -1266,14 +1261,14 @@ function __wbg_get_imports() {
1266
1261
  };
1267
1262
  }
1268
1263
 
1269
- function __wasm_bindgen_func_elem_5744(arg0, arg1, arg2, arg3) {
1270
- wasm.__wasm_bindgen_func_elem_5744(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1264
+ function __wasm_bindgen_func_elem_5724(arg0, arg1, arg2, arg3) {
1265
+ wasm.__wasm_bindgen_func_elem_5724(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1271
1266
  }
1272
1267
 
1273
- function __wasm_bindgen_func_elem_5726(arg0, arg1, arg2) {
1268
+ function __wasm_bindgen_func_elem_5706(arg0, arg1, arg2) {
1274
1269
  try {
1275
1270
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1276
- wasm.__wasm_bindgen_func_elem_5726(retptr, arg0, arg1, addHeapObject(arg2));
1271
+ wasm.__wasm_bindgen_func_elem_5706(retptr, arg0, arg1, addHeapObject(arg2));
1277
1272
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1278
1273
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1279
1274
  if (r1) {
Binary file
@@ -47,8 +47,8 @@ export const wasmsearch_search: (a: number, b: number, c: number, d: number, e:
47
47
  export const wasmsearch_search_keywords: (a: number, b: number, c: number, d: number, e: number) => void;
48
48
  export const wasmsearch_search_semantic: (a: number, b: number, c: number, d: number, e: number) => void;
49
49
  export const wasmsearch_update_file: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
50
- export const __wasm_bindgen_func_elem_5726: (a: number, b: number, c: number, d: number) => void;
51
- export const __wasm_bindgen_func_elem_5744: (a: number, b: number, c: number, d: number) => void;
50
+ export const __wasm_bindgen_func_elem_5706: (a: number, b: number, c: number, d: number) => void;
51
+ export const __wasm_bindgen_func_elem_5724: (a: number, b: number, c: number, d: number) => void;
52
52
  export const __wbindgen_export: (a: number, b: number) => number;
53
53
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
54
54
  export const __wbindgen_export3: (a: number) => void;
package/pkg/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Ólafur Aron Jóhannsson <olafurjohannss@gmail.com>"
6
6
  ],
7
7
  "description": "Local AI inference in the browser: embeddings, classification, reranking, semantic search and chat, compiled to WebAssembly.",
8
- "version": "0.2.5",
8
+ "version": "0.2.6",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",