ruvector 0.2.21 → 0.2.23
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 +2 -2
- package/bin/cli.js +160 -0
- package/package.json +9 -5
- package/src/decompiler/api-prober.js +302 -0
- package/src/decompiler/model-decompiler.js +423 -0
- package/dist/analysis/complexity.d.ts +0 -52
- package/dist/analysis/complexity.d.ts.map +0 -1
- package/dist/analysis/complexity.js +0 -146
- package/dist/analysis/index.d.ts +0 -15
- package/dist/analysis/index.d.ts.map +0 -1
- package/dist/analysis/index.js +0 -38
- package/dist/analysis/patterns.d.ts +0 -71
- package/dist/analysis/patterns.d.ts.map +0 -1
- package/dist/analysis/patterns.js +0 -243
- package/dist/analysis/security.d.ts +0 -51
- package/dist/analysis/security.d.ts.map +0 -1
- package/dist/analysis/security.js +0 -139
- package/dist/core/adaptive-embedder.d.ts +0 -156
- package/dist/core/adaptive-embedder.d.ts.map +0 -1
- package/dist/core/adaptive-embedder.js +0 -838
- package/dist/core/agentdb-fast.d.ts +0 -149
- package/dist/core/agentdb-fast.d.ts.map +0 -1
- package/dist/core/agentdb-fast.js +0 -301
- package/dist/core/ast-parser.d.ts +0 -108
- package/dist/core/ast-parser.d.ts.map +0 -1
- package/dist/core/ast-parser.js +0 -602
- package/dist/core/attention-fallbacks.d.ts +0 -321
- package/dist/core/attention-fallbacks.d.ts.map +0 -1
- package/dist/core/attention-fallbacks.js +0 -552
- package/dist/core/cluster-wrapper.d.ts +0 -148
- package/dist/core/cluster-wrapper.d.ts.map +0 -1
- package/dist/core/cluster-wrapper.js +0 -271
- package/dist/core/coverage-router.d.ts +0 -88
- package/dist/core/coverage-router.d.ts.map +0 -1
- package/dist/core/coverage-router.js +0 -315
- package/dist/core/diff-embeddings.d.ts +0 -93
- package/dist/core/diff-embeddings.d.ts.map +0 -1
- package/dist/core/diff-embeddings.js +0 -334
- package/dist/core/gnn-wrapper.d.ts +0 -143
- package/dist/core/gnn-wrapper.d.ts.map +0 -1
- package/dist/core/gnn-wrapper.js +0 -213
- package/dist/core/graph-algorithms.d.ts +0 -83
- package/dist/core/graph-algorithms.d.ts.map +0 -1
- package/dist/core/graph-algorithms.js +0 -514
- package/dist/core/graph-wrapper.d.ts +0 -147
- package/dist/core/graph-wrapper.d.ts.map +0 -1
- package/dist/core/graph-wrapper.js +0 -299
- package/dist/core/index.d.ts +0 -48
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -89
- package/dist/core/intelligence-engine.d.ts +0 -258
- package/dist/core/intelligence-engine.d.ts.map +0 -1
- package/dist/core/intelligence-engine.js +0 -1030
- package/dist/core/learning-engine.d.ts +0 -160
- package/dist/core/learning-engine.d.ts.map +0 -1
- package/dist/core/learning-engine.js +0 -589
- package/dist/core/neural-embeddings.d.ts +0 -393
- package/dist/core/neural-embeddings.d.ts.map +0 -1
- package/dist/core/neural-embeddings.js +0 -1091
- package/dist/core/neural-perf.d.ts +0 -331
- package/dist/core/neural-perf.d.ts.map +0 -1
- package/dist/core/neural-perf.js +0 -704
- package/dist/core/onnx/loader.js +0 -348
- package/dist/core/onnx/pkg/LICENSE +0 -21
- package/dist/core/onnx/pkg/loader.js +0 -348
- package/dist/core/onnx/pkg/package.json +0 -3
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm.d.ts +0 -112
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm.js +0 -5
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_bg.js +0 -638
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_bg.wasm +0 -0
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_bg.wasm.d.ts +0 -29
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_cjs.js +0 -127
- package/dist/core/onnx-embedder.d.ts +0 -105
- package/dist/core/onnx-embedder.d.ts.map +0 -1
- package/dist/core/onnx-embedder.js +0 -410
- package/dist/core/onnx-llm.d.ts +0 -206
- package/dist/core/onnx-llm.d.ts.map +0 -1
- package/dist/core/onnx-llm.js +0 -430
- package/dist/core/onnx-optimized.d.ts +0 -109
- package/dist/core/onnx-optimized.d.ts.map +0 -1
- package/dist/core/onnx-optimized.js +0 -419
- package/dist/core/parallel-intelligence.d.ts +0 -109
- package/dist/core/parallel-intelligence.d.ts.map +0 -1
- package/dist/core/parallel-intelligence.js +0 -340
- package/dist/core/parallel-workers.d.ts +0 -177
- package/dist/core/parallel-workers.d.ts.map +0 -1
- package/dist/core/parallel-workers.js +0 -671
- package/dist/core/router-wrapper.d.ts +0 -62
- package/dist/core/router-wrapper.d.ts.map +0 -1
- package/dist/core/router-wrapper.js +0 -209
- package/dist/core/rvf-wrapper.d.ts +0 -86
- package/dist/core/rvf-wrapper.d.ts.map +0 -1
- package/dist/core/rvf-wrapper.js +0 -102
- package/dist/core/sona-wrapper.d.ts +0 -226
- package/dist/core/sona-wrapper.d.ts.map +0 -1
- package/dist/core/sona-wrapper.js +0 -282
- package/dist/core/tensor-compress.d.ts +0 -134
- package/dist/core/tensor-compress.d.ts.map +0 -1
- package/dist/core/tensor-compress.js +0 -432
- package/dist/index.d.ts +0 -105
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -221
- package/dist/services/embedding-service.d.ts +0 -136
- package/dist/services/embedding-service.d.ts.map +0 -1
- package/dist/services/embedding-service.js +0 -294
- package/dist/services/index.d.ts +0 -6
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/index.js +0 -26
- package/dist/types.d.ts +0 -145
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/workers/benchmark.d.ts +0 -44
- package/dist/workers/benchmark.d.ts.map +0 -1
- package/dist/workers/benchmark.js +0 -230
- package/dist/workers/index.d.ts +0 -10
- package/dist/workers/index.d.ts.map +0 -1
- package/dist/workers/index.js +0 -25
- package/dist/workers/native-worker.d.ts +0 -76
- package/dist/workers/native-worker.d.ts.map +0 -1
- package/dist/workers/native-worker.js +0 -490
- package/dist/workers/types.d.ts +0 -69
- package/dist/workers/types.d.ts.map +0 -1
- package/dist/workers/types.js +0 -7
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* SONA Wrapper - Self-Optimizing Neural Architecture
|
|
4
|
-
*
|
|
5
|
-
* Provides a safe, flexible interface to @ruvector/sona with:
|
|
6
|
-
* - Automatic array type conversion (Array <-> Float64Array)
|
|
7
|
-
* - Graceful handling when sona is not installed
|
|
8
|
-
* - TypeScript types for all APIs
|
|
9
|
-
*
|
|
10
|
-
* SONA Features:
|
|
11
|
-
* - Micro-LoRA: Ultra-fast rank-1/2 adaptations (~0.1ms)
|
|
12
|
-
* - Base-LoRA: Deeper adaptations for complex patterns
|
|
13
|
-
* - EWC++: Elastic Weight Consolidation to prevent catastrophic forgetting
|
|
14
|
-
* - ReasoningBank: Pattern storage and retrieval
|
|
15
|
-
* - Trajectory tracking: Record and learn from execution paths
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.Sona = exports.SonaEngine = void 0;
|
|
19
|
-
exports.isSonaAvailable = isSonaAvailable;
|
|
20
|
-
// ============================================================================
|
|
21
|
-
// Helper Functions
|
|
22
|
-
// ============================================================================
|
|
23
|
-
/** Convert any array-like to regular Array (SONA expects number[]) */
|
|
24
|
-
function toArray(input) {
|
|
25
|
-
if (Array.isArray(input))
|
|
26
|
-
return input;
|
|
27
|
-
return Array.from(input);
|
|
28
|
-
}
|
|
29
|
-
// ============================================================================
|
|
30
|
-
// Lazy Loading
|
|
31
|
-
// ============================================================================
|
|
32
|
-
let sonaModule = null;
|
|
33
|
-
let sonaLoadError = null;
|
|
34
|
-
function getSonaModule() {
|
|
35
|
-
if (sonaModule)
|
|
36
|
-
return sonaModule;
|
|
37
|
-
if (sonaLoadError)
|
|
38
|
-
throw sonaLoadError;
|
|
39
|
-
try {
|
|
40
|
-
sonaModule = require('@ruvector/sona');
|
|
41
|
-
return sonaModule;
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
sonaLoadError = new Error(`@ruvector/sona is not installed. Install it with:\n` +
|
|
45
|
-
` npm install @ruvector/sona\n\n` +
|
|
46
|
-
`Original error: ${e.message}`);
|
|
47
|
-
throw sonaLoadError;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/** Check if sona is available */
|
|
51
|
-
function isSonaAvailable() {
|
|
52
|
-
try {
|
|
53
|
-
getSonaModule();
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// ============================================================================
|
|
61
|
-
// SONA Engine Wrapper
|
|
62
|
-
// ============================================================================
|
|
63
|
-
/**
|
|
64
|
-
* SONA Engine - Self-Optimizing Neural Architecture
|
|
65
|
-
*
|
|
66
|
-
* Provides runtime-adaptive learning with:
|
|
67
|
-
* - Micro-LoRA for instant adaptations
|
|
68
|
-
* - Base-LoRA for deeper learning
|
|
69
|
-
* - EWC++ for preventing forgetting
|
|
70
|
-
* - ReasoningBank for pattern storage
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* import { Sona } from 'ruvector';
|
|
75
|
-
*
|
|
76
|
-
* // Create engine with hidden dimension
|
|
77
|
-
* const engine = new Sona.Engine(256);
|
|
78
|
-
*
|
|
79
|
-
* // Or with custom config
|
|
80
|
-
* const engine = Sona.Engine.withConfig({
|
|
81
|
-
* hiddenDim: 256,
|
|
82
|
-
* microLoraRank: 2,
|
|
83
|
-
* patternClusters: 100
|
|
84
|
-
* });
|
|
85
|
-
*
|
|
86
|
-
* // Record a trajectory
|
|
87
|
-
* const trajId = engine.beginTrajectory([0.1, 0.2, ...]);
|
|
88
|
-
* engine.addStep(trajId, activations, attentionWeights, 0.8);
|
|
89
|
-
* engine.endTrajectory(trajId, 0.9);
|
|
90
|
-
*
|
|
91
|
-
* // Apply learned adaptations
|
|
92
|
-
* const adapted = engine.applyMicroLora(input);
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
class SonaEngine {
|
|
96
|
-
/**
|
|
97
|
-
* Create a new SONA engine
|
|
98
|
-
* @param hiddenDim Hidden dimension size (e.g., 256, 512, 768)
|
|
99
|
-
*/
|
|
100
|
-
constructor(hiddenDim) {
|
|
101
|
-
const mod = getSonaModule();
|
|
102
|
-
this._native = new mod.SonaEngine(hiddenDim);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Create engine with custom configuration
|
|
106
|
-
* @param config SONA configuration options
|
|
107
|
-
*/
|
|
108
|
-
static withConfig(config) {
|
|
109
|
-
const mod = getSonaModule();
|
|
110
|
-
const engine = new SonaEngine(config.hiddenDim);
|
|
111
|
-
// Replace native with configured version
|
|
112
|
-
engine._native = mod.SonaEngine.withConfig(config);
|
|
113
|
-
return engine;
|
|
114
|
-
}
|
|
115
|
-
// -------------------------------------------------------------------------
|
|
116
|
-
// Trajectory Recording
|
|
117
|
-
// -------------------------------------------------------------------------
|
|
118
|
-
/**
|
|
119
|
-
* Begin recording a new trajectory
|
|
120
|
-
* @param queryEmbedding Initial query embedding
|
|
121
|
-
* @returns Trajectory ID for subsequent operations
|
|
122
|
-
*/
|
|
123
|
-
beginTrajectory(queryEmbedding) {
|
|
124
|
-
return this._native.beginTrajectory(toArray(queryEmbedding));
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Add a step to an active trajectory
|
|
128
|
-
* @param trajectoryId Trajectory ID from beginTrajectory
|
|
129
|
-
* @param activations Layer activations
|
|
130
|
-
* @param attentionWeights Attention weights
|
|
131
|
-
* @param reward Reward signal for this step (0.0 - 1.0)
|
|
132
|
-
*/
|
|
133
|
-
addStep(trajectoryId, activations, attentionWeights, reward) {
|
|
134
|
-
this._native.addTrajectoryStep(trajectoryId, toArray(activations), toArray(attentionWeights), reward);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Alias for addStep for API compatibility
|
|
138
|
-
*/
|
|
139
|
-
addTrajectoryStep(trajectoryId, activations, attentionWeights, reward) {
|
|
140
|
-
this.addStep(trajectoryId, activations, attentionWeights, reward);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Set the model route for a trajectory
|
|
144
|
-
* @param trajectoryId Trajectory ID
|
|
145
|
-
* @param route Model route identifier (e.g., "gpt-4", "claude-3")
|
|
146
|
-
*/
|
|
147
|
-
setRoute(trajectoryId, route) {
|
|
148
|
-
this._native.setTrajectoryRoute(trajectoryId, route);
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Add context to a trajectory
|
|
152
|
-
* @param trajectoryId Trajectory ID
|
|
153
|
-
* @param contextId Context identifier
|
|
154
|
-
*/
|
|
155
|
-
addContext(trajectoryId, contextId) {
|
|
156
|
-
this._native.addTrajectoryContext(trajectoryId, contextId);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Complete a trajectory and submit for learning
|
|
160
|
-
* @param trajectoryId Trajectory ID
|
|
161
|
-
* @param quality Final quality score (0.0 - 1.0)
|
|
162
|
-
*/
|
|
163
|
-
endTrajectory(trajectoryId, quality) {
|
|
164
|
-
this._native.endTrajectory(trajectoryId, quality);
|
|
165
|
-
}
|
|
166
|
-
// -------------------------------------------------------------------------
|
|
167
|
-
// LoRA Transformations
|
|
168
|
-
// -------------------------------------------------------------------------
|
|
169
|
-
/**
|
|
170
|
-
* Apply micro-LoRA transformation (ultra-fast, ~0.1ms)
|
|
171
|
-
* @param input Input vector
|
|
172
|
-
* @returns Transformed output vector
|
|
173
|
-
*/
|
|
174
|
-
applyMicroLora(input) {
|
|
175
|
-
return this._native.applyMicroLora(toArray(input));
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Apply base-LoRA transformation to a specific layer
|
|
179
|
-
* @param layerIdx Layer index
|
|
180
|
-
* @param input Input vector
|
|
181
|
-
* @returns Transformed output vector
|
|
182
|
-
*/
|
|
183
|
-
applyBaseLora(layerIdx, input) {
|
|
184
|
-
return this._native.applyBaseLora(layerIdx, toArray(input));
|
|
185
|
-
}
|
|
186
|
-
// -------------------------------------------------------------------------
|
|
187
|
-
// Learning Control
|
|
188
|
-
// -------------------------------------------------------------------------
|
|
189
|
-
/**
|
|
190
|
-
* Run background learning cycle if due
|
|
191
|
-
* Call this periodically (e.g., every few seconds)
|
|
192
|
-
* @returns Status message if learning occurred, null otherwise
|
|
193
|
-
*/
|
|
194
|
-
tick() {
|
|
195
|
-
return this._native.tick();
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Force immediate background learning cycle
|
|
199
|
-
* @returns Status message with learning results
|
|
200
|
-
*/
|
|
201
|
-
forceLearn() {
|
|
202
|
-
return this._native.forceLearn();
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Flush pending instant loop updates
|
|
206
|
-
*/
|
|
207
|
-
flush() {
|
|
208
|
-
this._native.flush();
|
|
209
|
-
}
|
|
210
|
-
// -------------------------------------------------------------------------
|
|
211
|
-
// Pattern Retrieval
|
|
212
|
-
// -------------------------------------------------------------------------
|
|
213
|
-
/**
|
|
214
|
-
* Find similar learned patterns to a query
|
|
215
|
-
* @param queryEmbedding Query embedding
|
|
216
|
-
* @param k Number of patterns to return
|
|
217
|
-
* @returns Array of similar patterns
|
|
218
|
-
*/
|
|
219
|
-
findPatterns(queryEmbedding, k) {
|
|
220
|
-
return this._native.findPatterns(toArray(queryEmbedding), k);
|
|
221
|
-
}
|
|
222
|
-
// -------------------------------------------------------------------------
|
|
223
|
-
// Engine Control
|
|
224
|
-
// -------------------------------------------------------------------------
|
|
225
|
-
/**
|
|
226
|
-
* Get engine statistics
|
|
227
|
-
* @returns Statistics object
|
|
228
|
-
*/
|
|
229
|
-
getStats() {
|
|
230
|
-
const statsJson = this._native.getStats();
|
|
231
|
-
const raw = JSON.parse(statsJson);
|
|
232
|
-
// Map snake_case Rust fields to camelCase TypeScript (fixes #273)
|
|
233
|
-
return {
|
|
234
|
-
trajectoriesRecorded: raw.trajectories_recorded ?? raw.trajectoriesRecorded ?? (raw.trajectories_buffered ?? 0) + (raw.trajectories_dropped ?? 0),
|
|
235
|
-
patternsLearned: raw.patterns_learned ?? raw.patternsLearned ?? raw.patterns_stored ?? 0,
|
|
236
|
-
microLoraUpdates: raw.micro_lora_updates ?? raw.microLoraUpdates ?? 0,
|
|
237
|
-
baseLoraUpdates: raw.base_lora_updates ?? raw.baseLoraUpdates ?? 0,
|
|
238
|
-
ewcConsolidations: raw.ewc_tasks ?? raw.ewcConsolidations ?? 0,
|
|
239
|
-
avgLearningTimeMs: raw.avg_learning_time_ms ?? raw.avgLearningTimeMs ?? 0,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Save engine state to JSON string for persistence across restarts (fixes #274)
|
|
244
|
-
* @returns State JSON that can be stored to disk/database
|
|
245
|
-
*/
|
|
246
|
-
saveState() {
|
|
247
|
-
return this._native.saveState();
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Restore engine state from JSON saved by saveState() (fixes #274)
|
|
251
|
-
* @param stateJson - JSON string from a previous saveState() call
|
|
252
|
-
* @returns Number of patterns restored
|
|
253
|
-
*/
|
|
254
|
-
loadState(stateJson) {
|
|
255
|
-
return this._native.loadState(stateJson);
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Enable or disable the engine
|
|
259
|
-
* @param enabled Whether to enable
|
|
260
|
-
*/
|
|
261
|
-
setEnabled(enabled) {
|
|
262
|
-
this._native.setEnabled(enabled);
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Check if engine is enabled
|
|
266
|
-
*/
|
|
267
|
-
isEnabled() {
|
|
268
|
-
return this._native.isEnabled();
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
exports.SonaEngine = SonaEngine;
|
|
272
|
-
// ============================================================================
|
|
273
|
-
// Convenience Exports
|
|
274
|
-
// ============================================================================
|
|
275
|
-
/**
|
|
276
|
-
* SONA namespace with all exports
|
|
277
|
-
*/
|
|
278
|
-
exports.Sona = {
|
|
279
|
-
Engine: SonaEngine,
|
|
280
|
-
isAvailable: isSonaAvailable,
|
|
281
|
-
};
|
|
282
|
-
exports.default = exports.Sona;
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TensorCompress - Adaptive tensor compression for intelligence storage
|
|
3
|
-
* Provides 10x memory savings with access-frequency based compression
|
|
4
|
-
*/
|
|
5
|
-
export type CompressionLevel = 'none' | 'half' | 'pq8' | 'pq4' | 'binary';
|
|
6
|
-
export interface CompressedTensor {
|
|
7
|
-
data: number[] | Uint8Array | Uint16Array | Float32Array;
|
|
8
|
-
level: CompressionLevel;
|
|
9
|
-
originalDim: number;
|
|
10
|
-
accessCount: number;
|
|
11
|
-
lastAccess: number;
|
|
12
|
-
created: number;
|
|
13
|
-
}
|
|
14
|
-
export interface CompressionStats {
|
|
15
|
-
totalTensors: number;
|
|
16
|
-
byLevel: Record<CompressionLevel, number>;
|
|
17
|
-
originalBytes: number;
|
|
18
|
-
compressedBytes: number;
|
|
19
|
-
savingsPercent: number;
|
|
20
|
-
}
|
|
21
|
-
export interface CompressionConfig {
|
|
22
|
-
hotThreshold: number;
|
|
23
|
-
warmThreshold: number;
|
|
24
|
-
coolThreshold: number;
|
|
25
|
-
coldThreshold: number;
|
|
26
|
-
autoCompress: boolean;
|
|
27
|
-
compressIntervalMs: number;
|
|
28
|
-
}
|
|
29
|
-
export declare class TensorCompress {
|
|
30
|
-
private config;
|
|
31
|
-
private tensors;
|
|
32
|
-
private totalAccesses;
|
|
33
|
-
private compressTimer;
|
|
34
|
-
constructor(config?: Partial<CompressionConfig>);
|
|
35
|
-
/**
|
|
36
|
-
* Store a tensor with automatic compression based on access patterns
|
|
37
|
-
*/
|
|
38
|
-
store(id: string, tensor: Float32Array | number[], level?: CompressionLevel): void;
|
|
39
|
-
/**
|
|
40
|
-
* Retrieve and decompress a tensor
|
|
41
|
-
*/
|
|
42
|
-
get(id: string): Float32Array | null;
|
|
43
|
-
/**
|
|
44
|
-
* Check if tensor exists
|
|
45
|
-
*/
|
|
46
|
-
has(id: string): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Delete a tensor
|
|
49
|
-
*/
|
|
50
|
-
delete(id: string): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Get all tensor IDs
|
|
53
|
-
*/
|
|
54
|
-
keys(): string[];
|
|
55
|
-
/**
|
|
56
|
-
* Compress tensor to specified level
|
|
57
|
-
*/
|
|
58
|
-
private compress;
|
|
59
|
-
/**
|
|
60
|
-
* Decompress tensor back to Float32Array
|
|
61
|
-
*/
|
|
62
|
-
private decompress;
|
|
63
|
-
/**
|
|
64
|
-
* Float16 conversion (approximate)
|
|
65
|
-
*/
|
|
66
|
-
private toFloat16;
|
|
67
|
-
private fromFloat16;
|
|
68
|
-
private floatToHalf;
|
|
69
|
-
private halfToFloat;
|
|
70
|
-
/**
|
|
71
|
-
* Product Quantization 8-bit
|
|
72
|
-
*/
|
|
73
|
-
private toPQ8;
|
|
74
|
-
private fromPQ8;
|
|
75
|
-
/**
|
|
76
|
-
* Product Quantization 4-bit (packed)
|
|
77
|
-
*/
|
|
78
|
-
private toPQ4;
|
|
79
|
-
private fromPQ4;
|
|
80
|
-
/**
|
|
81
|
-
* Binary quantization (1-bit per value)
|
|
82
|
-
*/
|
|
83
|
-
private toBinary;
|
|
84
|
-
private fromBinary;
|
|
85
|
-
/**
|
|
86
|
-
* Calculate access frequency for a tensor
|
|
87
|
-
*/
|
|
88
|
-
private getAccessFrequency;
|
|
89
|
-
/**
|
|
90
|
-
* Determine optimal compression level based on access frequency
|
|
91
|
-
*/
|
|
92
|
-
getOptimalLevel(id: string): CompressionLevel;
|
|
93
|
-
/**
|
|
94
|
-
* Recompress all tensors based on current access patterns
|
|
95
|
-
*/
|
|
96
|
-
recompressAll(): CompressionStats;
|
|
97
|
-
/**
|
|
98
|
-
* Get compressed size in bytes
|
|
99
|
-
*/
|
|
100
|
-
private getCompressedSize;
|
|
101
|
-
/**
|
|
102
|
-
* Get compression statistics
|
|
103
|
-
*/
|
|
104
|
-
getStats(): CompressionStats;
|
|
105
|
-
/**
|
|
106
|
-
* Start auto-compression timer
|
|
107
|
-
*/
|
|
108
|
-
private startAutoCompress;
|
|
109
|
-
/**
|
|
110
|
-
* Stop auto-compression
|
|
111
|
-
*/
|
|
112
|
-
stopAutoCompress(): void;
|
|
113
|
-
/**
|
|
114
|
-
* Export all tensors for persistence
|
|
115
|
-
*/
|
|
116
|
-
export(): {
|
|
117
|
-
tensors: Record<string, any>;
|
|
118
|
-
totalAccesses: number;
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Import tensors from persistence
|
|
122
|
-
*/
|
|
123
|
-
import(data: {
|
|
124
|
-
tensors: Record<string, any>;
|
|
125
|
-
totalAccesses: number;
|
|
126
|
-
}): void;
|
|
127
|
-
private restoreTypedArray;
|
|
128
|
-
/**
|
|
129
|
-
* Clear all tensors
|
|
130
|
-
*/
|
|
131
|
-
clear(): void;
|
|
132
|
-
}
|
|
133
|
-
export default TensorCompress;
|
|
134
|
-
//# sourceMappingURL=tensor-compress.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tensor-compress.d.ts","sourceRoot":"","sources":["../../src/core/tensor-compress.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE1E,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC;IACzD,KAAK,EAAE,gBAAgB,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,O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