/** * INT8 Quantization + batched cosine similarity search * Extracted from memory-initializer.ts (ARCH-4) * * The HNSW ANN index itself now lives inside @monoes/memory's * SqlBackend.search() (size-gated, built from the real memory_embeddings * table, persisted to disk next to the SQLite file) — see * memory-bridge.ts's bridgeGetHNSWStatus()/bridgeForceBuildHNSW(). This file * used to also maintain a second, separate pure-JS HNSW index reaching * directly into a `.swarm/memory.db` that nothing writes to post-rename; * that layer queried the wrong database with the wrong schema and was * removed rather than fixed in place, since the real search path already * covers the same need at the correct layer. * * @module v1/cli/hnsw-operations */ /** * Quantize a Float32 embedding to Int8 (4x memory reduction) * Uses symmetric quantization with scale factor stored per-vector * * @param embedding - Float32 embedding array * @returns Quantized Int8 array with scale factor */ export declare function quantizeInt8(embedding: number[] | Float32Array): { quantized: Int8Array; scale: number; zeroPoint: number; }; /** * Dequantize Int8 back to Float32 * * @param quantized - Int8 quantized array * @param scale - Scale factor from quantization * @param zeroPoint - Zero point (usually 0 for symmetric) * @returns Float32Array */ export declare function dequantizeInt8(quantized: Int8Array, scale: number, zeroPoint?: number): Float32Array; /** * Compute cosine similarity between quantized vectors * Faster than dequantizing first */ export declare function quantizedCosineSim(a: Int8Array, _aScale: number, b: Int8Array, _bScale: number): number; /** * Get quantization statistics for an embedding */ export declare function getQuantizationStats(embedding: number[] | Float32Array): { originalBytes: number; quantizedBytes: number; compressionRatio: number; }; /** * Batch cosine similarity - compute query against multiple vectors * Optimized for V8 JIT with typed arrays * ~50μs per 1000 vectors (384-dim) */ export declare function batchCosineSim(query: Float32Array | number[], vectors: (Float32Array | number[])[]): Float32Array; /** * Softmax normalization for attention scores * Numerically stable implementation */ export declare function softmaxAttention(scores: Float32Array, temperature?: number): Float32Array; /** * Top-K selection with partial sort (O(n + k log k)) * More efficient than full sort for small k */ export declare function topKIndices(scores: Float32Array, k: number): number[]; /** * Batched cosine similarity search with softmax-weighted scoring. * Combines batch similarity, softmax, and top-k in one pass. * Returns indices and normalized weights (not a Flash Attention kernel — * see the module-level note above). */ export declare function flashAttentionSearch(query: Float32Array | number[], vectors: (Float32Array | number[])[], options?: { k?: number; temperature?: number; threshold?: number; }): { indices: number[]; scores: Float32Array; weights: Float32Array; }; //# sourceMappingURL=hnsw-operations.d.ts.map