@kotoshu/wasm 0.2.0 → 0.3.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/kotoshu_wasm.d.ts CHANGED
@@ -65,3 +65,13 @@ export function loadModel(model_bytes: Uint8Array, vocab_bytes: Uint8Array): Kot
65
65
  * candidates as the gem's context boost does; see the module docs.
66
66
  */
67
67
  export function rerank(model: KotoshuModel, word: string, context: string): number;
68
+
69
+ /**
70
+ * The `k` nearest vocabulary words to `word` by cosine — semantic
71
+ * candidate GENERATION (see `Int8Model::semantic_neighbors`): one plain
72
+ * `{ word, score }` row per neighbor, score-descending, the query word
73
+ * itself excluded. Empty when `k` is 0 or the word embeds nowhere (out
74
+ * of vocabulary with no in-vocabulary character n-gram). `k` defaults
75
+ * to 5 when omitted.
76
+ */
77
+ export function semanticSuggest(model: KotoshuModel, word: string, k?: number | null): Array<any>;
package/kotoshu_wasm.js CHANGED
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./kotoshu_wasm_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
  wasm.__wbindgen_start();
7
7
  export {
8
- KotoshuModel, KotoshuWasm, loadModel, rerank
8
+ KotoshuModel, KotoshuWasm, loadModel, rerank, semanticSuggest
9
9
  } from "./kotoshu_wasm_bg.js";
@@ -151,6 +151,26 @@ export function rerank(model, word, context) {
151
151
  const ret = wasm.rerank(model.__wbg_ptr, ptr0, len0, ptr1, len1);
152
152
  return ret;
153
153
  }
154
+
155
+ /**
156
+ * The `k` nearest vocabulary words to `word` by cosine — semantic
157
+ * candidate GENERATION (see `Int8Model::semantic_neighbors`): one plain
158
+ * `{ word, score }` row per neighbor, score-descending, the query word
159
+ * itself excluded. Empty when `k` is 0 or the word embeds nowhere (out
160
+ * of vocabulary with no in-vocabulary character n-gram). `k` defaults
161
+ * to 5 when omitted.
162
+ * @param {KotoshuModel} model
163
+ * @param {string} word
164
+ * @param {number | null} [k]
165
+ * @returns {Array<any>}
166
+ */
167
+ export function semanticSuggest(model, word, k) {
168
+ _assertClass(model, KotoshuModel);
169
+ const ptr0 = passStringToWasm0(word, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
170
+ const len0 = WASM_VECTOR_LEN;
171
+ const ret = wasm.semanticSuggest(model.__wbg_ptr, ptr0, len0, isLikeNone(k) ? Number.MAX_SAFE_INTEGER : (k) >>> 0);
172
+ return ret;
173
+ }
154
174
  export function __wbg_Error_408e67f47ca7b58b(arg0, arg1) {
155
175
  const ret = Error(getStringFromWasm0(arg0, arg1));
156
176
  return ret;
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Ribose Inc. <open.source@ribose.com>"
6
6
  ],
7
7
  "description": "npm @kotoshu/wasm packaging shim: wasm-pack build of the kotoshu engine's wasm-bindgen surface",
8
- "version": "0.2.0",
8
+ "version": "0.3.0",
9
9
  "license": "BSD-2-Clause",
10
10
  "repository": {
11
11
  "type": "git",