@ruvector/edge-full 0.1.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/LICENSE +21 -0
- package/README.md +390 -0
- package/dag/ruvector_dag_wasm.d.ts +105 -0
- package/dag/ruvector_dag_wasm.js +466 -0
- package/dag/ruvector_dag_wasm_bg.wasm +0 -0
- package/dag/ruvector_dag_wasm_bg.wasm.d.ts +20 -0
- package/edge/ruvector_edge.d.ts +351 -0
- package/edge/ruvector_edge.js +1452 -0
- package/edge/ruvector_edge_bg.wasm +0 -0
- package/edge/ruvector_edge_bg.wasm.d.ts +71 -0
- package/generator.html +2009 -0
- package/graph/ruvector_graph_wasm.d.ts +380 -0
- package/graph/ruvector_graph_wasm.js +1787 -0
- package/graph/ruvector_graph_wasm_bg.wasm +0 -0
- package/graph/ruvector_graph_wasm_bg.wasm.d.ts +80 -0
- package/index.d.ts +64 -0
- package/index.js +182 -0
- package/onnx/ruvector_onnx_embeddings_wasm.d.ts +112 -0
- package/onnx/ruvector_onnx_embeddings_wasm.js +635 -0
- package/onnx/ruvector_onnx_embeddings_wasm_bg.js +629 -0
- package/onnx/ruvector_onnx_embeddings_wasm_bg.wasm +0 -0
- package/onnx/ruvector_onnx_embeddings_wasm_bg.wasm.d.ts +29 -0
- package/package.json +86 -0
- package/rvlite/rvlite.d.ts +556 -0
- package/rvlite/rvlite.js +2366 -0
- package/rvlite/rvlite_bg.wasm +0 -0
- package/rvlite/rvlite_bg.wasm.d.ts +128 -0
- package/sona/ruvector_sona.d.ts +513 -0
- package/sona/ruvector_sona.js +1290 -0
- package/sona/ruvector_sona_bg.wasm +0 -0
- package/sona/ruvector_sona_bg.wasm.d.ts +53 -0
|
Binary file
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_asyncqueryexecutor_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_asynctransaction_free: (a: number, b: number) => void;
|
|
6
|
+
export const __wbg_graphdb_free: (a: number, b: number) => void;
|
|
7
|
+
export const __wbg_jsedge_free: (a: number, b: number) => void;
|
|
8
|
+
export const __wbg_jshyperedge_free: (a: number, b: number) => void;
|
|
9
|
+
export const __wbg_jsnode_free: (a: number, b: number) => void;
|
|
10
|
+
export const __wbg_queryresult_free: (a: number, b: number) => void;
|
|
11
|
+
export const __wbg_resultstream_free: (a: number, b: number) => void;
|
|
12
|
+
export const asyncqueryexecutor_batchSize: (a: number) => number;
|
|
13
|
+
export const asyncqueryexecutor_executeInWorker: (a: number, b: number, c: number) => number;
|
|
14
|
+
export const asyncqueryexecutor_executeStreaming: (a: number, b: number, c: number) => number;
|
|
15
|
+
export const asyncqueryexecutor_new: (a: number) => number;
|
|
16
|
+
export const asyncqueryexecutor_set_batchSize: (a: number, b: number) => void;
|
|
17
|
+
export const asynctransaction_addOperation: (a: number, b: number, c: number) => void;
|
|
18
|
+
export const asynctransaction_commit: (a: number) => number;
|
|
19
|
+
export const asynctransaction_isCommitted: (a: number) => number;
|
|
20
|
+
export const asynctransaction_new: () => number;
|
|
21
|
+
export const asynctransaction_operationCount: (a: number) => number;
|
|
22
|
+
export const asynctransaction_rollback: (a: number) => void;
|
|
23
|
+
export const batchoperations_executeBatch: (a: number, b: number, c: number) => number;
|
|
24
|
+
export const batchoperations_new: (a: number) => number;
|
|
25
|
+
export const graphdb_createEdge: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
26
|
+
export const graphdb_createHyperedge: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
27
|
+
export const graphdb_createNode: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
28
|
+
export const graphdb_deleteEdge: (a: number, b: number, c: number) => number;
|
|
29
|
+
export const graphdb_deleteNode: (a: number, b: number, c: number) => number;
|
|
30
|
+
export const graphdb_exportCypher: (a: number, b: number) => void;
|
|
31
|
+
export const graphdb_getEdge: (a: number, b: number, c: number) => number;
|
|
32
|
+
export const graphdb_getHyperedge: (a: number, b: number, c: number) => number;
|
|
33
|
+
export const graphdb_getNode: (a: number, b: number, c: number) => number;
|
|
34
|
+
export const graphdb_importCypher: (a: number, b: number, c: number) => number;
|
|
35
|
+
export const graphdb_new: (a: number, b: number, c: number) => void;
|
|
36
|
+
export const graphdb_query: (a: number, b: number, c: number) => number;
|
|
37
|
+
export const graphdb_stats: (a: number) => number;
|
|
38
|
+
export const jsedge_from: (a: number, b: number) => void;
|
|
39
|
+
export const jsedge_getProperty: (a: number, b: number, c: number) => number;
|
|
40
|
+
export const jsedge_id: (a: number, b: number) => void;
|
|
41
|
+
export const jsedge_properties: (a: number) => number;
|
|
42
|
+
export const jsedge_to: (a: number, b: number) => void;
|
|
43
|
+
export const jsedge_type: (a: number, b: number) => void;
|
|
44
|
+
export const jshyperedge_confidence: (a: number) => number;
|
|
45
|
+
export const jshyperedge_description: (a: number, b: number) => void;
|
|
46
|
+
export const jshyperedge_embedding: (a: number, b: number) => void;
|
|
47
|
+
export const jshyperedge_id: (a: number, b: number) => void;
|
|
48
|
+
export const jshyperedge_nodes: (a: number, b: number) => void;
|
|
49
|
+
export const jshyperedge_order: (a: number) => number;
|
|
50
|
+
export const jshyperedge_properties: (a: number) => number;
|
|
51
|
+
export const jsnode_embedding: (a: number, b: number) => void;
|
|
52
|
+
export const jsnode_getProperty: (a: number, b: number, c: number) => number;
|
|
53
|
+
export const jsnode_hasLabel: (a: number, b: number, c: number) => number;
|
|
54
|
+
export const jsnode_id: (a: number, b: number) => void;
|
|
55
|
+
export const jsnode_labels: (a: number, b: number) => void;
|
|
56
|
+
export const jsnode_properties: (a: number) => number;
|
|
57
|
+
export const queryresult_count: (a: number) => number;
|
|
58
|
+
export const queryresult_data: (a: number) => number;
|
|
59
|
+
export const queryresult_edges: (a: number, b: number) => void;
|
|
60
|
+
export const queryresult_hyperedges: (a: number, b: number) => void;
|
|
61
|
+
export const queryresult_isEmpty: (a: number) => number;
|
|
62
|
+
export const queryresult_nodes: (a: number, b: number) => void;
|
|
63
|
+
export const resultstream_new: (a: number) => number;
|
|
64
|
+
export const resultstream_nextChunk: (a: number) => number;
|
|
65
|
+
export const resultstream_offset: (a: number) => number;
|
|
66
|
+
export const resultstream_reset: (a: number) => void;
|
|
67
|
+
export const version: (a: number) => void;
|
|
68
|
+
export const init: () => void;
|
|
69
|
+
export const batchoperations_maxBatchSize: (a: number) => number;
|
|
70
|
+
export const resultstream_chunkSize: (a: number) => number;
|
|
71
|
+
export const __wbg_batchoperations_free: (a: number, b: number) => void;
|
|
72
|
+
export const __wasm_bindgen_func_elem_446: (a: number, b: number, c: number) => void;
|
|
73
|
+
export const __wasm_bindgen_func_elem_445: (a: number, b: number) => void;
|
|
74
|
+
export const __wasm_bindgen_func_elem_774: (a: number, b: number, c: number, d: number) => void;
|
|
75
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
76
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
77
|
+
export const __wbindgen_export3: (a: number) => void;
|
|
78
|
+
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
79
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
80
|
+
export const __wbindgen_start: () => void;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ruvector/edge-full - Complete WASM toolkit for edge AI
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Module namespaces
|
|
6
|
+
export * as edge from './edge/ruvector_edge';
|
|
7
|
+
export * as graph from './graph/ruvector_graph_wasm';
|
|
8
|
+
export * as rvlite from './rvlite/rvlite';
|
|
9
|
+
export * as sona from './sona/ruvector_sona';
|
|
10
|
+
export * as dag from './dag/ruvector_dag_wasm';
|
|
11
|
+
|
|
12
|
+
// ONNX init function
|
|
13
|
+
export { default as onnxInit } from './onnx/ruvector_onnx_embeddings_wasm';
|
|
14
|
+
|
|
15
|
+
// Module info interface
|
|
16
|
+
export interface ModuleInfo {
|
|
17
|
+
name: string;
|
|
18
|
+
size: string;
|
|
19
|
+
features: string[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ModulesMap {
|
|
23
|
+
edge: ModuleInfo;
|
|
24
|
+
graph: ModuleInfo;
|
|
25
|
+
rvlite: ModuleInfo;
|
|
26
|
+
sona: ModuleInfo;
|
|
27
|
+
dag: ModuleInfo;
|
|
28
|
+
onnx: ModuleInfo;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const modules: ModulesMap;
|
|
32
|
+
|
|
33
|
+
export interface TotalSize {
|
|
34
|
+
core: string;
|
|
35
|
+
withOnnx: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const totalSize: TotalSize;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Initialize all core modules (excludes ONNX due to size)
|
|
42
|
+
*/
|
|
43
|
+
export function initAll(): Promise<{
|
|
44
|
+
edge: typeof import('./edge/ruvector_edge');
|
|
45
|
+
graph: typeof import('./graph/ruvector_graph_wasm');
|
|
46
|
+
rvlite: typeof import('./rvlite/rvlite');
|
|
47
|
+
sona: typeof import('./sona/ruvector_sona');
|
|
48
|
+
dag: typeof import('./dag/ruvector_dag_wasm');
|
|
49
|
+
}>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Initialize only specific modules
|
|
53
|
+
* @param moduleNames - Array of module names to init
|
|
54
|
+
*/
|
|
55
|
+
export function initModules(moduleNames: Array<'edge' | 'graph' | 'rvlite' | 'sona' | 'dag' | 'onnx'>): Promise<{
|
|
56
|
+
edge?: typeof import('./edge/ruvector_edge');
|
|
57
|
+
graph?: typeof import('./graph/ruvector_graph_wasm');
|
|
58
|
+
rvlite?: typeof import('./rvlite/rvlite');
|
|
59
|
+
sona?: typeof import('./sona/ruvector_sona');
|
|
60
|
+
dag?: typeof import('./dag/ruvector_dag_wasm');
|
|
61
|
+
onnx?: typeof import('./onnx/ruvector_onnx_embeddings_wasm');
|
|
62
|
+
}>;
|
|
63
|
+
|
|
64
|
+
export const quickStart: string;
|
package/index.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ruvector/edge-full - Complete WASM toolkit for edge AI
|
|
3
|
+
*
|
|
4
|
+
* This package bundles all RuVector WASM modules for comprehensive
|
|
5
|
+
* edge computing capabilities:
|
|
6
|
+
*
|
|
7
|
+
* - edge: Cryptographic identity, P2P, vector search, neural networks
|
|
8
|
+
* - graph: Neo4j-style graph database with Cypher queries
|
|
9
|
+
* - rvlite: SQL/SPARQL/Cypher vector database
|
|
10
|
+
* - sona: Self-optimizing neural architecture with LoRA
|
|
11
|
+
* - dag: Directed acyclic graph for workflow orchestration
|
|
12
|
+
* - onnx: ONNX inference with HuggingFace embedding models
|
|
13
|
+
*
|
|
14
|
+
* Each module can be imported separately:
|
|
15
|
+
*
|
|
16
|
+
* import { WasmIdentity, WasmHnswIndex } from '@ruvector/edge-full/edge';
|
|
17
|
+
* import { WasmGraphStore } from '@ruvector/edge-full/graph';
|
|
18
|
+
* import { Database } from '@ruvector/edge-full/rvlite';
|
|
19
|
+
* import { SonaEngine } from '@ruvector/edge-full/sona';
|
|
20
|
+
* import { Dag } from '@ruvector/edge-full/dag';
|
|
21
|
+
* import { OnnxEmbedder } from '@ruvector/edge-full/onnx';
|
|
22
|
+
*
|
|
23
|
+
* Or use the unified init for quick setup:
|
|
24
|
+
*
|
|
25
|
+
* import { initAll, edge, graph, rvlite, sona, dag } from '@ruvector/edge-full';
|
|
26
|
+
* await initAll();
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
// Re-export all modules for convenience
|
|
30
|
+
export * as edge from './edge/ruvector_edge.js';
|
|
31
|
+
export * as graph from './graph/ruvector_graph_wasm.js';
|
|
32
|
+
export * as rvlite from './rvlite/rvlite.js';
|
|
33
|
+
export * as sona from './sona/ruvector_sona.js';
|
|
34
|
+
export * as dag from './dag/ruvector_dag_wasm.js';
|
|
35
|
+
|
|
36
|
+
// ONNX is large (7MB), export separately
|
|
37
|
+
export { default as onnxInit } from './onnx/ruvector_onnx_embeddings_wasm.js';
|
|
38
|
+
|
|
39
|
+
// Module info
|
|
40
|
+
export const modules = {
|
|
41
|
+
edge: {
|
|
42
|
+
name: 'RuVector Edge',
|
|
43
|
+
size: '364KB',
|
|
44
|
+
features: ['Ed25519 identity', 'AES-256-GCM encryption', 'HNSW vector search',
|
|
45
|
+
'Raft consensus', 'Neural networks', 'Post-quantum crypto']
|
|
46
|
+
},
|
|
47
|
+
graph: {
|
|
48
|
+
name: 'Graph Database',
|
|
49
|
+
size: '288KB',
|
|
50
|
+
features: ['Neo4j-style API', 'Cypher queries', 'Hypergraph support',
|
|
51
|
+
'Worker threads', 'IndexedDB persistence']
|
|
52
|
+
},
|
|
53
|
+
rvlite: {
|
|
54
|
+
name: 'RVLite Vector DB',
|
|
55
|
+
size: '260KB',
|
|
56
|
+
features: ['SQL queries', 'SPARQL queries', 'Cypher queries',
|
|
57
|
+
'Multi-index', 'Browser/Node/Edge']
|
|
58
|
+
},
|
|
59
|
+
sona: {
|
|
60
|
+
name: 'SONA Neural',
|
|
61
|
+
size: '238KB',
|
|
62
|
+
features: ['Two-tier LoRA', 'EWC++', 'ReasoningBank',
|
|
63
|
+
'Adaptive learning', 'Router optimization']
|
|
64
|
+
},
|
|
65
|
+
dag: {
|
|
66
|
+
name: 'DAG Workflows',
|
|
67
|
+
size: '132KB',
|
|
68
|
+
features: ['Workflow orchestration', 'Dependency tracking',
|
|
69
|
+
'Topological sort', 'Minimal footprint']
|
|
70
|
+
},
|
|
71
|
+
onnx: {
|
|
72
|
+
name: 'ONNX Embeddings',
|
|
73
|
+
size: '7.1MB',
|
|
74
|
+
features: ['HuggingFace models', '6 pre-trained models',
|
|
75
|
+
'Parallel workers', 'SIMD acceleration']
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Calculate total size
|
|
80
|
+
export const totalSize = {
|
|
81
|
+
core: '1.28MB', // edge + graph + rvlite + sona + dag
|
|
82
|
+
withOnnx: '8.4MB' // including ONNX
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Initialize all core modules (excludes ONNX due to size)
|
|
87
|
+
* For ONNX, import and init separately:
|
|
88
|
+
* import onnxInit from '@ruvector/edge-full/onnx';
|
|
89
|
+
* await onnxInit();
|
|
90
|
+
*/
|
|
91
|
+
export async function initAll() {
|
|
92
|
+
const { default: edgeInit } = await import('./edge/ruvector_edge.js');
|
|
93
|
+
const { default: graphInit } = await import('./graph/ruvector_graph_wasm.js');
|
|
94
|
+
const { default: rvliteInit } = await import('./rvlite/rvlite.js');
|
|
95
|
+
const { default: sonaInit } = await import('./sona/ruvector_sona.js');
|
|
96
|
+
const { default: dagInit } = await import('./dag/ruvector_dag_wasm.js');
|
|
97
|
+
|
|
98
|
+
await Promise.all([
|
|
99
|
+
edgeInit(),
|
|
100
|
+
graphInit(),
|
|
101
|
+
rvliteInit(),
|
|
102
|
+
sonaInit(),
|
|
103
|
+
dagInit()
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
return { edge, graph, rvlite, sona, dag };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Initialize only specific modules
|
|
111
|
+
* @param {string[]} moduleNames - Array of module names to init
|
|
112
|
+
*/
|
|
113
|
+
export async function initModules(moduleNames) {
|
|
114
|
+
const results = {};
|
|
115
|
+
|
|
116
|
+
for (const name of moduleNames) {
|
|
117
|
+
switch (name) {
|
|
118
|
+
case 'edge':
|
|
119
|
+
const { default: edgeInit } = await import('./edge/ruvector_edge.js');
|
|
120
|
+
await edgeInit();
|
|
121
|
+
results.edge = await import('./edge/ruvector_edge.js');
|
|
122
|
+
break;
|
|
123
|
+
case 'graph':
|
|
124
|
+
const { default: graphInit } = await import('./graph/ruvector_graph_wasm.js');
|
|
125
|
+
await graphInit();
|
|
126
|
+
results.graph = await import('./graph/ruvector_graph_wasm.js');
|
|
127
|
+
break;
|
|
128
|
+
case 'rvlite':
|
|
129
|
+
const { default: rvliteInit } = await import('./rvlite/rvlite.js');
|
|
130
|
+
await rvliteInit();
|
|
131
|
+
results.rvlite = await import('./rvlite/rvlite.js');
|
|
132
|
+
break;
|
|
133
|
+
case 'sona':
|
|
134
|
+
const { default: sonaInit } = await import('./sona/ruvector_sona.js');
|
|
135
|
+
await sonaInit();
|
|
136
|
+
results.sona = await import('./sona/ruvector_sona.js');
|
|
137
|
+
break;
|
|
138
|
+
case 'dag':
|
|
139
|
+
const { default: dagInit } = await import('./dag/ruvector_dag_wasm.js');
|
|
140
|
+
await dagInit();
|
|
141
|
+
results.dag = await import('./dag/ruvector_dag_wasm.js');
|
|
142
|
+
break;
|
|
143
|
+
case 'onnx':
|
|
144
|
+
const { default: onnxInit } = await import('./onnx/ruvector_onnx_embeddings_wasm.js');
|
|
145
|
+
await onnxInit();
|
|
146
|
+
results.onnx = await import('./onnx/ruvector_onnx_embeddings_wasm.js');
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return results;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Quick start example
|
|
155
|
+
export const quickStart = `
|
|
156
|
+
// Initialize all core modules (1.28MB total)
|
|
157
|
+
import { initAll } from '@ruvector/edge-full';
|
|
158
|
+
|
|
159
|
+
const { edge, graph, rvlite, sona, dag } from await initAll();
|
|
160
|
+
|
|
161
|
+
// Create cryptographic identity
|
|
162
|
+
const identity = new edge.WasmIdentity.generate();
|
|
163
|
+
console.log('Agent:', identity.agent_id());
|
|
164
|
+
|
|
165
|
+
// Build a graph
|
|
166
|
+
const graphStore = new graph.WasmGraphStore();
|
|
167
|
+
graphStore.run_cypher("CREATE (a:Agent {id: 'agent-1'})");
|
|
168
|
+
|
|
169
|
+
// Vector search with SQL
|
|
170
|
+
const db = new rvlite.Database();
|
|
171
|
+
db.execute("INSERT INTO vectors (embedding) VALUES ([1,2,3])");
|
|
172
|
+
|
|
173
|
+
// Self-learning neural routing
|
|
174
|
+
const sonaEngine = new sona.SonaEngine();
|
|
175
|
+
sonaEngine.route_request({ task: "analyze" });
|
|
176
|
+
|
|
177
|
+
// Workflow orchestration
|
|
178
|
+
const workflow = new dag.Dag();
|
|
179
|
+
workflow.add_node("start");
|
|
180
|
+
workflow.add_node("process");
|
|
181
|
+
workflow.add_edge("start", "process");
|
|
182
|
+
`;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Strategy for pooling token embeddings into a single sentence embedding
|
|
6
|
+
*/
|
|
7
|
+
export enum PoolingStrategy {
|
|
8
|
+
/**
|
|
9
|
+
* Average all token embeddings (most common)
|
|
10
|
+
*/
|
|
11
|
+
Mean = 0,
|
|
12
|
+
/**
|
|
13
|
+
* Use only the [CLS] token embedding
|
|
14
|
+
*/
|
|
15
|
+
Cls = 1,
|
|
16
|
+
/**
|
|
17
|
+
* Take the maximum value across all tokens for each dimension
|
|
18
|
+
*/
|
|
19
|
+
Max = 2,
|
|
20
|
+
/**
|
|
21
|
+
* Mean pooling normalized by sqrt of sequence length
|
|
22
|
+
*/
|
|
23
|
+
MeanSqrtLen = 3,
|
|
24
|
+
/**
|
|
25
|
+
* Use the last token embedding (for decoder models)
|
|
26
|
+
*/
|
|
27
|
+
LastToken = 4,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class WasmEmbedder {
|
|
31
|
+
free(): void;
|
|
32
|
+
[Symbol.dispose](): void;
|
|
33
|
+
/**
|
|
34
|
+
* Get maximum sequence length
|
|
35
|
+
*/
|
|
36
|
+
maxLength(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Compute similarity between two texts
|
|
39
|
+
*/
|
|
40
|
+
similarity(text1: string, text2: string): number;
|
|
41
|
+
/**
|
|
42
|
+
* Generate embeddings for multiple texts
|
|
43
|
+
*/
|
|
44
|
+
embedBatch(texts: string[]): Float32Array;
|
|
45
|
+
/**
|
|
46
|
+
* Create embedder with custom configuration
|
|
47
|
+
*/
|
|
48
|
+
static withConfig(model_bytes: Uint8Array, tokenizer_json: string, config: WasmEmbedderConfig): WasmEmbedder;
|
|
49
|
+
/**
|
|
50
|
+
* Create a new embedder from model and tokenizer bytes
|
|
51
|
+
*
|
|
52
|
+
* # Arguments
|
|
53
|
+
* * `model_bytes` - ONNX model file bytes
|
|
54
|
+
* * `tokenizer_json` - Tokenizer JSON configuration
|
|
55
|
+
*/
|
|
56
|
+
constructor(model_bytes: Uint8Array, tokenizer_json: string);
|
|
57
|
+
/**
|
|
58
|
+
* Get the embedding dimension
|
|
59
|
+
*/
|
|
60
|
+
dimension(): number;
|
|
61
|
+
/**
|
|
62
|
+
* Generate embedding for a single text
|
|
63
|
+
*/
|
|
64
|
+
embedOne(text: string): Float32Array;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class WasmEmbedderConfig {
|
|
68
|
+
free(): void;
|
|
69
|
+
[Symbol.dispose](): void;
|
|
70
|
+
/**
|
|
71
|
+
* Set pooling strategy (0=Mean, 1=Cls, 2=Max, 3=MeanSqrtLen, 4=LastToken)
|
|
72
|
+
*/
|
|
73
|
+
setPooling(pooling: number): WasmEmbedderConfig;
|
|
74
|
+
/**
|
|
75
|
+
* Set whether to normalize embeddings
|
|
76
|
+
*/
|
|
77
|
+
setNormalize(normalize: boolean): WasmEmbedderConfig;
|
|
78
|
+
/**
|
|
79
|
+
* Set maximum sequence length
|
|
80
|
+
*/
|
|
81
|
+
setMaxLength(max_length: number): WasmEmbedderConfig;
|
|
82
|
+
/**
|
|
83
|
+
* Create a new configuration
|
|
84
|
+
*/
|
|
85
|
+
constructor();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Compute cosine similarity between two embedding vectors (JS-friendly)
|
|
90
|
+
*/
|
|
91
|
+
export function cosineSimilarity(a: Float32Array, b: Float32Array): number;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Initialize panic hook for better error messages in WASM
|
|
95
|
+
*/
|
|
96
|
+
export function init(): void;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* L2 normalize an embedding vector (JS-friendly)
|
|
100
|
+
*/
|
|
101
|
+
export function normalizeL2(embedding: Float32Array): Float32Array;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Check if SIMD is available (for performance info)
|
|
105
|
+
* Returns true if compiled with WASM SIMD128 support
|
|
106
|
+
*/
|
|
107
|
+
export function simd_available(): boolean;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Get the library version
|
|
111
|
+
*/
|
|
112
|
+
export function version(): string;
|