@soulcraft/brainy 0.41.0 → 0.44.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/README.md +605 -194
- package/dist/augmentationFactory.d.ts.map +1 -0
- package/dist/augmentationFactory.js +342 -0
- package/dist/augmentationFactory.js.map +1 -0
- package/dist/augmentationPipeline.d.ts.map +1 -0
- package/dist/augmentationPipeline.js +472 -0
- package/dist/augmentationPipeline.js.map +1 -0
- package/dist/augmentationRegistry.d.ts.map +1 -0
- package/dist/augmentationRegistry.js +105 -0
- package/dist/augmentationRegistry.js.map +1 -0
- package/dist/augmentationRegistryLoader.d.ts.map +1 -0
- package/dist/augmentationRegistryLoader.js +213 -0
- package/dist/augmentationRegistryLoader.js.map +1 -0
- package/dist/augmentations/conduitAugmentations.js +1158 -0
- package/dist/augmentations/conduitAugmentations.js.map +1 -0
- package/dist/augmentations/memoryAugmentations.d.ts +2 -0
- package/dist/augmentations/memoryAugmentations.d.ts.map +1 -1
- package/dist/augmentations/memoryAugmentations.js +270 -0
- package/dist/augmentations/memoryAugmentations.js.map +1 -0
- package/dist/augmentations/serverSearchAugmentations.js +531 -0
- package/dist/augmentations/serverSearchAugmentations.js.map +1 -0
- package/dist/brainyData.d.ts.map +1 -0
- package/dist/brainyData.js +3999 -0
- package/dist/brainyData.js.map +1 -0
- package/dist/browserFramework.d.ts +15 -0
- package/dist/browserFramework.d.ts.map +1 -0
- package/dist/browserFramework.js +31 -0
- package/dist/browserFramework.js.map +1 -0
- package/dist/coreTypes.d.ts.map +1 -0
- package/dist/coreTypes.js +5 -0
- package/dist/coreTypes.js.map +1 -0
- package/dist/demo.d.ts +106 -0
- package/dist/demo.d.ts.map +1 -0
- package/dist/demo.js +201 -0
- package/dist/demo.js.map +1 -0
- package/dist/distributed/configManager.d.ts.map +1 -0
- package/dist/distributed/configManager.js +322 -0
- package/dist/distributed/configManager.js.map +1 -0
- package/dist/distributed/domainDetector.d.ts.map +1 -0
- package/dist/distributed/domainDetector.js +307 -0
- package/dist/distributed/domainDetector.js.map +1 -0
- package/dist/distributed/hashPartitioner.d.ts.map +1 -0
- package/dist/distributed/hashPartitioner.js +146 -0
- package/dist/distributed/hashPartitioner.js.map +1 -0
- package/dist/distributed/healthMonitor.d.ts.map +1 -0
- package/dist/distributed/healthMonitor.js +244 -0
- package/dist/distributed/healthMonitor.js.map +1 -0
- package/dist/distributed/index.d.ts.map +1 -0
- package/dist/distributed/index.js +9 -0
- package/dist/distributed/index.js.map +1 -0
- package/dist/distributed/operationalModes.d.ts.map +1 -0
- package/dist/distributed/operationalModes.js +201 -0
- package/dist/distributed/operationalModes.js.map +1 -0
- package/dist/errors/brainyError.d.ts.map +1 -0
- package/dist/errors/brainyError.js +113 -0
- package/dist/errors/brainyError.js.map +1 -0
- package/dist/examples/basicUsage.js +118 -0
- package/dist/examples/basicUsage.js.map +1 -0
- package/dist/hnsw/distributedSearch.js +452 -0
- package/dist/hnsw/distributedSearch.js.map +1 -0
- package/dist/hnsw/hnswIndex.js +602 -0
- package/dist/hnsw/hnswIndex.js.map +1 -0
- package/dist/hnsw/hnswIndexOptimized.js +471 -0
- package/dist/hnsw/hnswIndexOptimized.js.map +1 -0
- package/dist/hnsw/optimizedHNSWIndex.js +313 -0
- package/dist/hnsw/optimizedHNSWIndex.js.map +1 -0
- package/dist/hnsw/partitionedHNSWIndex.js +304 -0
- package/dist/hnsw/partitionedHNSWIndex.js.map +1 -0
- package/dist/hnsw/scaledHNSWSystem.js +559 -0
- package/dist/hnsw/scaledHNSWSystem.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +81 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/brainyMCPAdapter.js +142 -0
- package/dist/mcp/brainyMCPAdapter.js.map +1 -0
- package/dist/mcp/brainyMCPService.js +248 -0
- package/dist/mcp/brainyMCPService.js.map +1 -0
- package/dist/mcp/index.js +17 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcpAugmentationToolset.js +180 -0
- package/dist/mcp/mcpAugmentationToolset.js.map +1 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +590 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/sequentialPipeline.d.ts.map +1 -0
- package/dist/sequentialPipeline.js +417 -0
- package/dist/sequentialPipeline.js.map +1 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +46 -0
- package/dist/setup.js.map +1 -0
- package/dist/storage/adapters/baseStorageAdapter.js +349 -0
- package/dist/storage/adapters/baseStorageAdapter.js.map +1 -0
- package/dist/storage/adapters/batchS3Operations.js +287 -0
- package/dist/storage/adapters/batchS3Operations.js.map +1 -0
- package/dist/storage/adapters/fileSystemStorage.js +846 -0
- package/dist/storage/adapters/fileSystemStorage.js.map +1 -0
- package/dist/storage/adapters/memoryStorage.js +532 -0
- package/dist/storage/adapters/memoryStorage.js.map +1 -0
- package/dist/storage/adapters/opfsStorage.d.ts.map +1 -1
- package/dist/storage/adapters/opfsStorage.js +1118 -0
- package/dist/storage/adapters/opfsStorage.js.map +1 -0
- package/dist/storage/adapters/optimizedS3Search.js +248 -0
- package/dist/storage/adapters/optimizedS3Search.js.map +1 -0
- package/dist/storage/adapters/s3CompatibleStorage.js +2026 -0
- package/dist/storage/adapters/s3CompatibleStorage.js.map +1 -0
- package/dist/storage/baseStorage.js +603 -0
- package/dist/storage/baseStorage.js.map +1 -0
- package/dist/storage/cacheManager.js +1306 -0
- package/dist/storage/cacheManager.js.map +1 -0
- package/dist/storage/enhancedCacheManager.js +520 -0
- package/dist/storage/enhancedCacheManager.js.map +1 -0
- package/dist/storage/readOnlyOptimizations.js +425 -0
- package/dist/storage/readOnlyOptimizations.js.map +1 -0
- package/dist/storage/storageFactory.d.ts +0 -1
- package/dist/storage/storageFactory.d.ts.map +1 -1
- package/dist/storage/storageFactory.js +227 -0
- package/dist/storage/storageFactory.js.map +1 -0
- package/dist/types/augmentations.js +16 -0
- package/dist/types/augmentations.js.map +1 -0
- package/dist/types/brainyDataInterface.js +8 -0
- package/dist/types/brainyDataInterface.js.map +1 -0
- package/dist/types/distributedTypes.js +6 -0
- package/dist/types/distributedTypes.js.map +1 -0
- package/dist/types/fileSystemTypes.js +8 -0
- package/dist/types/fileSystemTypes.js.map +1 -0
- package/dist/types/graphTypes.js +247 -0
- package/dist/types/graphTypes.js.map +1 -0
- package/dist/types/mcpTypes.js +22 -0
- package/dist/types/mcpTypes.js.map +1 -0
- package/dist/types/paginationTypes.js +5 -0
- package/dist/types/paginationTypes.js.map +1 -0
- package/dist/types/pipelineTypes.js +7 -0
- package/dist/types/pipelineTypes.js.map +1 -0
- package/dist/types/tensorflowTypes.js +6 -0
- package/dist/types/tensorflowTypes.js.map +1 -0
- package/dist/unified.d.ts.map +1 -0
- package/dist/unified.js +52 -128251
- package/dist/unified.js.map +1 -0
- package/dist/utils/autoConfiguration.js +341 -0
- package/dist/utils/autoConfiguration.js.map +1 -0
- package/dist/utils/cacheAutoConfig.js +261 -0
- package/dist/utils/cacheAutoConfig.js.map +1 -0
- package/dist/utils/crypto.js +45 -0
- package/dist/utils/crypto.js.map +1 -0
- package/dist/utils/distance.js +239 -0
- package/dist/utils/distance.js.map +1 -0
- package/dist/utils/embedding.d.ts.map +1 -1
- package/dist/utils/embedding.js +702 -0
- package/dist/utils/embedding.js.map +1 -0
- package/dist/utils/environment.js +75 -0
- package/dist/utils/environment.js.map +1 -0
- package/dist/utils/fieldNameTracking.js +90 -0
- package/dist/utils/fieldNameTracking.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/jsonProcessing.js +179 -0
- package/dist/utils/jsonProcessing.js.map +1 -0
- package/dist/utils/logger.js +129 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/operationUtils.js +126 -0
- package/dist/utils/operationUtils.js.map +1 -0
- package/dist/utils/robustModelLoader.d.ts +14 -0
- package/dist/utils/robustModelLoader.d.ts.map +1 -1
- package/dist/utils/robustModelLoader.js +537 -0
- package/dist/utils/robustModelLoader.js.map +1 -0
- package/dist/utils/searchCache.js +248 -0
- package/dist/utils/searchCache.js.map +1 -0
- package/dist/utils/statistics.js +25 -0
- package/dist/utils/statistics.js.map +1 -0
- package/dist/utils/statisticsCollector.js +224 -0
- package/dist/utils/statisticsCollector.js.map +1 -0
- package/dist/utils/textEncoding.js +309 -0
- package/dist/utils/textEncoding.js.map +1 -0
- package/dist/utils/typeUtils.js +40 -0
- package/dist/utils/typeUtils.js.map +1 -0
- package/dist/utils/version.d.ts +15 -3
- package/dist/utils/version.d.ts.map +1 -1
- package/dist/utils/version.js +24 -0
- package/dist/utils/version.js.map +1 -0
- package/dist/utils/workerUtils.js +458 -0
- package/dist/utils/workerUtils.js.map +1 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +54 -0
- package/dist/worker.js.map +1 -0
- package/package.json +30 -29
- package/dist/brainy.js +0 -90220
- package/dist/brainy.min.js +0 -12511
- package/dist/patched-platform-node.d.ts +0 -17
- package/dist/statistics/statisticsManager.d.ts +0 -121
- package/dist/storage/fileSystemStorage.d.ts +0 -73
- package/dist/storage/fileSystemStorage.d.ts.map +0 -1
- package/dist/storage/opfsStorage.d.ts +0 -236
- package/dist/storage/opfsStorage.d.ts.map +0 -1
- package/dist/storage/s3CompatibleStorage.d.ts +0 -157
- package/dist/storage/s3CompatibleStorage.d.ts.map +0 -1
- package/dist/testing/prettyReporter.d.ts +0 -23
- package/dist/testing/prettySummaryReporter.d.ts +0 -22
- package/dist/unified.min.js +0 -16153
- package/dist/utils/environmentDetection.d.ts +0 -47
- package/dist/utils/environmentDetection.d.ts.map +0 -1
- package/dist/utils/tensorflowUtils.d.ts +0 -17
- package/dist/utils/tensorflowUtils.d.ts.map +0 -1
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HNSW (Hierarchical Navigable Small World) Index implementation
|
|
3
|
+
* Based on the paper: "Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs"
|
|
4
|
+
*/
|
|
5
|
+
import { euclideanDistance, calculateDistancesBatch } from '../utils/index.js';
|
|
6
|
+
// Default HNSW parameters
|
|
7
|
+
const DEFAULT_CONFIG = {
|
|
8
|
+
M: 16, // Max number of connections per noun
|
|
9
|
+
efConstruction: 200, // Size of a dynamic candidate list during construction
|
|
10
|
+
efSearch: 50, // Size of a dynamic candidate list during search
|
|
11
|
+
ml: 16 // Max level
|
|
12
|
+
};
|
|
13
|
+
export class HNSWIndex {
|
|
14
|
+
constructor(config = {}, distanceFunction = euclideanDistance, options = {}) {
|
|
15
|
+
this.nouns = new Map();
|
|
16
|
+
this.entryPointId = null;
|
|
17
|
+
this.maxLevel = 0;
|
|
18
|
+
this.dimension = null;
|
|
19
|
+
this.useParallelization = true; // Whether to use parallelization for performance-critical operations
|
|
20
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
21
|
+
this.distanceFunction = distanceFunction;
|
|
22
|
+
this.useParallelization =
|
|
23
|
+
options.useParallelization !== undefined
|
|
24
|
+
? options.useParallelization
|
|
25
|
+
: true;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Set whether to use parallelization for performance-critical operations
|
|
29
|
+
*/
|
|
30
|
+
setUseParallelization(useParallelization) {
|
|
31
|
+
this.useParallelization = useParallelization;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get whether parallelization is enabled
|
|
35
|
+
*/
|
|
36
|
+
getUseParallelization() {
|
|
37
|
+
return this.useParallelization;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Calculate distances between a query vector and multiple vectors in parallel
|
|
41
|
+
* This is used to optimize performance for search operations
|
|
42
|
+
* Uses GPU acceleration when available for optimal performance
|
|
43
|
+
*
|
|
44
|
+
* @param queryVector The query vector
|
|
45
|
+
* @param vectors Array of vectors to compare against
|
|
46
|
+
* @returns Array of distances
|
|
47
|
+
*/
|
|
48
|
+
async calculateDistancesInParallel(queryVector, vectors) {
|
|
49
|
+
// If parallelization is disabled or there are very few vectors, use sequential processing
|
|
50
|
+
if (!this.useParallelization || vectors.length < 10) {
|
|
51
|
+
return vectors.map((item) => ({
|
|
52
|
+
id: item.id,
|
|
53
|
+
distance: this.distanceFunction(queryVector, item.vector)
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
// Extract just the vectors from the input array
|
|
58
|
+
const vectorsOnly = vectors.map((item) => item.vector);
|
|
59
|
+
// Use GPU-accelerated distance calculation when possible
|
|
60
|
+
const distances = await calculateDistancesBatch(queryVector, vectorsOnly, this.distanceFunction);
|
|
61
|
+
// Map the distances back to their IDs
|
|
62
|
+
return vectors.map((item, index) => ({
|
|
63
|
+
id: item.id,
|
|
64
|
+
distance: distances[index]
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error('Error in GPU-accelerated distance calculation, falling back to sequential processing:', error);
|
|
69
|
+
// Fall back to sequential processing if GPU acceleration fails
|
|
70
|
+
return vectors.map((item) => ({
|
|
71
|
+
id: item.id,
|
|
72
|
+
distance: this.distanceFunction(queryVector, item.vector)
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Add a vector to the index
|
|
78
|
+
*/
|
|
79
|
+
async addItem(item) {
|
|
80
|
+
// Check if item is defined
|
|
81
|
+
if (!item) {
|
|
82
|
+
throw new Error('Item is undefined or null');
|
|
83
|
+
}
|
|
84
|
+
const { id, vector } = item;
|
|
85
|
+
// Check if vector is defined
|
|
86
|
+
if (!vector) {
|
|
87
|
+
throw new Error('Vector is undefined or null');
|
|
88
|
+
}
|
|
89
|
+
// Set dimension on first insert
|
|
90
|
+
if (this.dimension === null) {
|
|
91
|
+
this.dimension = vector.length;
|
|
92
|
+
}
|
|
93
|
+
else if (vector.length !== this.dimension) {
|
|
94
|
+
throw new Error(`Vector dimension mismatch: expected ${this.dimension}, got ${vector.length}`);
|
|
95
|
+
}
|
|
96
|
+
// Generate random level for this noun
|
|
97
|
+
const nounLevel = this.getRandomLevel();
|
|
98
|
+
// Create new noun
|
|
99
|
+
const noun = {
|
|
100
|
+
id,
|
|
101
|
+
vector,
|
|
102
|
+
connections: new Map(),
|
|
103
|
+
level: nounLevel
|
|
104
|
+
};
|
|
105
|
+
// Initialize empty connection sets for each level
|
|
106
|
+
for (let level = 0; level <= nounLevel; level++) {
|
|
107
|
+
noun.connections.set(level, new Set());
|
|
108
|
+
}
|
|
109
|
+
// If this is the first noun, make it the entry point
|
|
110
|
+
if (this.nouns.size === 0) {
|
|
111
|
+
this.entryPointId = id;
|
|
112
|
+
this.maxLevel = nounLevel;
|
|
113
|
+
this.nouns.set(id, noun);
|
|
114
|
+
return id;
|
|
115
|
+
}
|
|
116
|
+
// Find entry point
|
|
117
|
+
if (!this.entryPointId) {
|
|
118
|
+
console.error('Entry point ID is null');
|
|
119
|
+
// If there's no entry point, this is the first noun, so we should have returned earlier
|
|
120
|
+
// This is a safety check
|
|
121
|
+
this.entryPointId = id;
|
|
122
|
+
this.maxLevel = nounLevel;
|
|
123
|
+
this.nouns.set(id, noun);
|
|
124
|
+
return id;
|
|
125
|
+
}
|
|
126
|
+
const entryPoint = this.nouns.get(this.entryPointId);
|
|
127
|
+
if (!entryPoint) {
|
|
128
|
+
console.error(`Entry point with ID ${this.entryPointId} not found`);
|
|
129
|
+
// If the entry point doesn't exist, treat this as the first noun
|
|
130
|
+
this.entryPointId = id;
|
|
131
|
+
this.maxLevel = nounLevel;
|
|
132
|
+
this.nouns.set(id, noun);
|
|
133
|
+
return id;
|
|
134
|
+
}
|
|
135
|
+
let currObj = entryPoint;
|
|
136
|
+
let currDist = this.distanceFunction(vector, entryPoint.vector);
|
|
137
|
+
// Traverse the graph from top to bottom to find the closest noun
|
|
138
|
+
for (let level = this.maxLevel; level > nounLevel; level--) {
|
|
139
|
+
let changed = true;
|
|
140
|
+
while (changed) {
|
|
141
|
+
changed = false;
|
|
142
|
+
// Check all neighbors at current level
|
|
143
|
+
const connections = currObj.connections.get(level) || new Set();
|
|
144
|
+
for (const neighborId of connections) {
|
|
145
|
+
const neighbor = this.nouns.get(neighborId);
|
|
146
|
+
if (!neighbor) {
|
|
147
|
+
// Skip neighbors that don't exist (expected during rapid additions/deletions)
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const distToNeighbor = this.distanceFunction(vector, neighbor.vector);
|
|
151
|
+
if (distToNeighbor < currDist) {
|
|
152
|
+
currDist = distToNeighbor;
|
|
153
|
+
currObj = neighbor;
|
|
154
|
+
changed = true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// For each level from nounLevel down to 0
|
|
160
|
+
for (let level = Math.min(nounLevel, this.maxLevel); level >= 0; level--) {
|
|
161
|
+
// Find ef nearest elements using greedy search
|
|
162
|
+
const nearestNouns = await this.searchLayer(vector, currObj, this.config.efConstruction, level);
|
|
163
|
+
// Select M nearest neighbors
|
|
164
|
+
const neighbors = this.selectNeighbors(vector, nearestNouns, this.config.M);
|
|
165
|
+
// Add bidirectional connections
|
|
166
|
+
for (const [neighborId, _] of neighbors) {
|
|
167
|
+
const neighbor = this.nouns.get(neighborId);
|
|
168
|
+
if (!neighbor) {
|
|
169
|
+
// Skip neighbors that don't exist (expected during rapid additions/deletions)
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
noun.connections.get(level).add(neighborId);
|
|
173
|
+
// Add reverse connection
|
|
174
|
+
if (!neighbor.connections.has(level)) {
|
|
175
|
+
neighbor.connections.set(level, new Set());
|
|
176
|
+
}
|
|
177
|
+
neighbor.connections.get(level).add(id);
|
|
178
|
+
// Ensure neighbor doesn't have too many connections
|
|
179
|
+
if (neighbor.connections.get(level).size > this.config.M) {
|
|
180
|
+
this.pruneConnections(neighbor, level);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Update entry point for the next level
|
|
184
|
+
if (nearestNouns.size > 0) {
|
|
185
|
+
const [nearestId, nearestDist] = [...nearestNouns][0];
|
|
186
|
+
if (nearestDist < currDist) {
|
|
187
|
+
currDist = nearestDist;
|
|
188
|
+
const nearestNoun = this.nouns.get(nearestId);
|
|
189
|
+
if (!nearestNoun) {
|
|
190
|
+
console.error(`Nearest noun with ID ${nearestId} not found in addItem`);
|
|
191
|
+
// Keep the current object as is
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
currObj = nearestNoun;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Update max level and entry point if needed
|
|
200
|
+
if (nounLevel > this.maxLevel) {
|
|
201
|
+
this.maxLevel = nounLevel;
|
|
202
|
+
this.entryPointId = id;
|
|
203
|
+
}
|
|
204
|
+
// Add noun to the index
|
|
205
|
+
this.nouns.set(id, noun);
|
|
206
|
+
return id;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Search for nearest neighbors
|
|
210
|
+
*/
|
|
211
|
+
async search(queryVector, k = 10) {
|
|
212
|
+
if (this.nouns.size === 0) {
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
// Check if query vector is defined
|
|
216
|
+
if (!queryVector) {
|
|
217
|
+
throw new Error('Query vector is undefined or null');
|
|
218
|
+
}
|
|
219
|
+
if (this.dimension !== null && queryVector.length !== this.dimension) {
|
|
220
|
+
throw new Error(`Query vector dimension mismatch: expected ${this.dimension}, got ${queryVector.length}`);
|
|
221
|
+
}
|
|
222
|
+
// Start from the entry point
|
|
223
|
+
if (!this.entryPointId) {
|
|
224
|
+
console.error('Entry point ID is null');
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
const entryPoint = this.nouns.get(this.entryPointId);
|
|
228
|
+
if (!entryPoint) {
|
|
229
|
+
console.error(`Entry point with ID ${this.entryPointId} not found`);
|
|
230
|
+
return [];
|
|
231
|
+
}
|
|
232
|
+
let currObj = entryPoint;
|
|
233
|
+
let currDist = this.distanceFunction(queryVector, currObj.vector);
|
|
234
|
+
// Traverse the graph from top to bottom to find the closest noun
|
|
235
|
+
for (let level = this.maxLevel; level > 0; level--) {
|
|
236
|
+
let changed = true;
|
|
237
|
+
while (changed) {
|
|
238
|
+
changed = false;
|
|
239
|
+
// Check all neighbors at current level
|
|
240
|
+
const connections = currObj.connections.get(level) || new Set();
|
|
241
|
+
// If we have enough connections, use parallel distance calculation
|
|
242
|
+
if (this.useParallelization && connections.size >= 10) {
|
|
243
|
+
// Prepare vectors for parallel calculation
|
|
244
|
+
const vectors = [];
|
|
245
|
+
for (const neighborId of connections) {
|
|
246
|
+
const neighbor = this.nouns.get(neighborId);
|
|
247
|
+
if (!neighbor)
|
|
248
|
+
continue;
|
|
249
|
+
vectors.push({ id: neighborId, vector: neighbor.vector });
|
|
250
|
+
}
|
|
251
|
+
// Calculate distances in parallel
|
|
252
|
+
const distances = await this.calculateDistancesInParallel(queryVector, vectors);
|
|
253
|
+
// Find the closest neighbor
|
|
254
|
+
for (const { id, distance } of distances) {
|
|
255
|
+
if (distance < currDist) {
|
|
256
|
+
currDist = distance;
|
|
257
|
+
const neighbor = this.nouns.get(id);
|
|
258
|
+
if (neighbor) {
|
|
259
|
+
currObj = neighbor;
|
|
260
|
+
changed = true;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
// Use sequential processing for small number of connections
|
|
267
|
+
for (const neighborId of connections) {
|
|
268
|
+
const neighbor = this.nouns.get(neighborId);
|
|
269
|
+
if (!neighbor) {
|
|
270
|
+
// Skip neighbors that don't exist (expected during rapid additions/deletions)
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
const distToNeighbor = this.distanceFunction(queryVector, neighbor.vector);
|
|
274
|
+
if (distToNeighbor < currDist) {
|
|
275
|
+
currDist = distToNeighbor;
|
|
276
|
+
currObj = neighbor;
|
|
277
|
+
changed = true;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
// Search at level 0 with ef = k
|
|
284
|
+
const nearestNouns = await this.searchLayer(queryVector, currObj, Math.max(this.config.efSearch, k), 0);
|
|
285
|
+
// Convert to array and sort by distance
|
|
286
|
+
return [...nearestNouns].slice(0, k);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Remove an item from the index
|
|
290
|
+
*/
|
|
291
|
+
removeItem(id) {
|
|
292
|
+
if (!this.nouns.has(id)) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
const noun = this.nouns.get(id);
|
|
296
|
+
// Remove connections to this noun from all neighbors
|
|
297
|
+
for (const [level, connections] of noun.connections.entries()) {
|
|
298
|
+
for (const neighborId of connections) {
|
|
299
|
+
const neighbor = this.nouns.get(neighborId);
|
|
300
|
+
if (!neighbor) {
|
|
301
|
+
// Skip neighbors that don't exist (expected during rapid additions/deletions)
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (neighbor.connections.has(level)) {
|
|
305
|
+
neighbor.connections.get(level).delete(id);
|
|
306
|
+
// Prune connections after removing this noun to ensure consistency
|
|
307
|
+
this.pruneConnections(neighbor, level);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// Also check all other nouns for references to this noun and remove them
|
|
312
|
+
for (const [nounId, otherNoun] of this.nouns.entries()) {
|
|
313
|
+
if (nounId === id)
|
|
314
|
+
continue; // Skip the noun being removed
|
|
315
|
+
for (const [level, connections] of otherNoun.connections.entries()) {
|
|
316
|
+
if (connections.has(id)) {
|
|
317
|
+
connections.delete(id);
|
|
318
|
+
// Prune connections after removing this reference
|
|
319
|
+
this.pruneConnections(otherNoun, level);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
// Remove the noun
|
|
324
|
+
this.nouns.delete(id);
|
|
325
|
+
// If we removed the entry point, find a new one
|
|
326
|
+
if (this.entryPointId === id) {
|
|
327
|
+
if (this.nouns.size === 0) {
|
|
328
|
+
this.entryPointId = null;
|
|
329
|
+
this.maxLevel = 0;
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
// Find the noun with the highest level
|
|
333
|
+
let maxLevel = 0;
|
|
334
|
+
let newEntryPointId = null;
|
|
335
|
+
for (const [nounId, noun] of this.nouns.entries()) {
|
|
336
|
+
if (noun.connections.size === 0)
|
|
337
|
+
continue; // Skip nouns with no connections
|
|
338
|
+
const nounLevel = Math.max(...noun.connections.keys());
|
|
339
|
+
if (nounLevel >= maxLevel) {
|
|
340
|
+
maxLevel = nounLevel;
|
|
341
|
+
newEntryPointId = nounId;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
this.entryPointId = newEntryPointId;
|
|
345
|
+
this.maxLevel = maxLevel;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Get all nouns in the index
|
|
352
|
+
* @deprecated Use getNounsPaginated() instead for better scalability
|
|
353
|
+
*/
|
|
354
|
+
getNouns() {
|
|
355
|
+
return new Map(this.nouns);
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Get nouns with pagination
|
|
359
|
+
* @param options Pagination options
|
|
360
|
+
* @returns Object containing paginated nouns and pagination info
|
|
361
|
+
*/
|
|
362
|
+
getNounsPaginated(options = {}) {
|
|
363
|
+
const offset = options.offset || 0;
|
|
364
|
+
const limit = options.limit || 100;
|
|
365
|
+
const filter = options.filter || (() => true);
|
|
366
|
+
// Get all noun entries
|
|
367
|
+
const entries = [...this.nouns.entries()];
|
|
368
|
+
// Apply filter if provided
|
|
369
|
+
const filteredEntries = entries.filter(([_, noun]) => filter(noun));
|
|
370
|
+
// Get total count after filtering
|
|
371
|
+
const totalCount = filteredEntries.length;
|
|
372
|
+
// Apply pagination
|
|
373
|
+
const paginatedEntries = filteredEntries.slice(offset, offset + limit);
|
|
374
|
+
// Check if there are more items
|
|
375
|
+
const hasMore = offset + limit < totalCount;
|
|
376
|
+
// Create a new map with the paginated entries
|
|
377
|
+
const items = new Map(paginatedEntries);
|
|
378
|
+
return {
|
|
379
|
+
items,
|
|
380
|
+
totalCount,
|
|
381
|
+
hasMore
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Clear the index
|
|
386
|
+
*/
|
|
387
|
+
clear() {
|
|
388
|
+
this.nouns.clear();
|
|
389
|
+
this.entryPointId = null;
|
|
390
|
+
this.maxLevel = 0;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Get the size of the index
|
|
394
|
+
*/
|
|
395
|
+
size() {
|
|
396
|
+
return this.nouns.size;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Get the distance function used by the index
|
|
400
|
+
*/
|
|
401
|
+
getDistanceFunction() {
|
|
402
|
+
return this.distanceFunction;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Get the entry point ID
|
|
406
|
+
*/
|
|
407
|
+
getEntryPointId() {
|
|
408
|
+
return this.entryPointId;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Get the maximum level
|
|
412
|
+
*/
|
|
413
|
+
getMaxLevel() {
|
|
414
|
+
return this.maxLevel;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Get the dimension
|
|
418
|
+
*/
|
|
419
|
+
getDimension() {
|
|
420
|
+
return this.dimension;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Get the configuration
|
|
424
|
+
*/
|
|
425
|
+
getConfig() {
|
|
426
|
+
return { ...this.config };
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Get index health metrics
|
|
430
|
+
*/
|
|
431
|
+
getIndexHealth() {
|
|
432
|
+
let totalConnections = 0;
|
|
433
|
+
const layerCounts = new Array(this.maxLevel + 1).fill(0);
|
|
434
|
+
// Count connections and layer distribution
|
|
435
|
+
this.nouns.forEach(noun => {
|
|
436
|
+
// Count connections at each layer
|
|
437
|
+
for (let level = 0; level <= noun.level; level++) {
|
|
438
|
+
totalConnections += noun.connections.get(level)?.size || 0;
|
|
439
|
+
layerCounts[level]++;
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
const totalNodes = this.nouns.size;
|
|
443
|
+
const averageConnections = totalNodes > 0 ? totalConnections / totalNodes : 0;
|
|
444
|
+
return {
|
|
445
|
+
averageConnections,
|
|
446
|
+
layerDistribution: layerCounts,
|
|
447
|
+
maxLayer: this.maxLevel,
|
|
448
|
+
totalNodes
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Search within a specific layer
|
|
453
|
+
* Returns a map of noun IDs to distances, sorted by distance
|
|
454
|
+
*/
|
|
455
|
+
async searchLayer(queryVector, entryPoint, ef, level) {
|
|
456
|
+
// Set of visited nouns
|
|
457
|
+
const visited = new Set([entryPoint.id]);
|
|
458
|
+
// Priority queue of candidates (closest first)
|
|
459
|
+
const candidates = new Map();
|
|
460
|
+
candidates.set(entryPoint.id, this.distanceFunction(queryVector, entryPoint.vector));
|
|
461
|
+
// Priority queue of nearest neighbors found so far (closest first)
|
|
462
|
+
const nearest = new Map();
|
|
463
|
+
nearest.set(entryPoint.id, this.distanceFunction(queryVector, entryPoint.vector));
|
|
464
|
+
// While there are candidates to explore
|
|
465
|
+
while (candidates.size > 0) {
|
|
466
|
+
// Get closest candidate
|
|
467
|
+
const [closestId, closestDist] = [...candidates][0];
|
|
468
|
+
candidates.delete(closestId);
|
|
469
|
+
// If this candidate is farther than the farthest in our result set, we're done
|
|
470
|
+
const farthestInNearest = [...nearest][nearest.size - 1];
|
|
471
|
+
if (nearest.size >= ef && closestDist > farthestInNearest[1]) {
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
// Explore neighbors of the closest candidate
|
|
475
|
+
const noun = this.nouns.get(closestId);
|
|
476
|
+
if (!noun) {
|
|
477
|
+
console.error(`Noun with ID ${closestId} not found in searchLayer`);
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
const connections = noun.connections.get(level) || new Set();
|
|
481
|
+
// If we have enough connections and parallelization is enabled, use parallel distance calculation
|
|
482
|
+
if (this.useParallelization && connections.size >= 10) {
|
|
483
|
+
// Collect unvisited neighbors
|
|
484
|
+
const unvisitedNeighbors = [];
|
|
485
|
+
for (const neighborId of connections) {
|
|
486
|
+
if (!visited.has(neighborId)) {
|
|
487
|
+
visited.add(neighborId);
|
|
488
|
+
const neighbor = this.nouns.get(neighborId);
|
|
489
|
+
if (!neighbor)
|
|
490
|
+
continue;
|
|
491
|
+
unvisitedNeighbors.push({ id: neighborId, vector: neighbor.vector });
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
if (unvisitedNeighbors.length > 0) {
|
|
495
|
+
// Calculate distances in parallel
|
|
496
|
+
const distances = await this.calculateDistancesInParallel(queryVector, unvisitedNeighbors);
|
|
497
|
+
// Process the results
|
|
498
|
+
for (const { id, distance } of distances) {
|
|
499
|
+
// If we haven't found ef nearest neighbors yet, or this neighbor is closer than the farthest one we've found
|
|
500
|
+
if (nearest.size < ef || distance < farthestInNearest[1]) {
|
|
501
|
+
candidates.set(id, distance);
|
|
502
|
+
nearest.set(id, distance);
|
|
503
|
+
// If we have more than ef neighbors, remove the farthest one
|
|
504
|
+
if (nearest.size > ef) {
|
|
505
|
+
const sortedNearest = [...nearest].sort((a, b) => a[1] - b[1]);
|
|
506
|
+
nearest.clear();
|
|
507
|
+
for (let i = 0; i < ef; i++) {
|
|
508
|
+
nearest.set(sortedNearest[i][0], sortedNearest[i][1]);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
// Use sequential processing for small number of connections
|
|
517
|
+
for (const neighborId of connections) {
|
|
518
|
+
if (!visited.has(neighborId)) {
|
|
519
|
+
visited.add(neighborId);
|
|
520
|
+
const neighbor = this.nouns.get(neighborId);
|
|
521
|
+
if (!neighbor) {
|
|
522
|
+
// Skip neighbors that don't exist (expected during rapid additions/deletions)
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
const distToNeighbor = this.distanceFunction(queryVector, neighbor.vector);
|
|
526
|
+
// If we haven't found ef nearest neighbors yet, or this neighbor is closer than the farthest one we've found
|
|
527
|
+
if (nearest.size < ef || distToNeighbor < farthestInNearest[1]) {
|
|
528
|
+
candidates.set(neighborId, distToNeighbor);
|
|
529
|
+
nearest.set(neighborId, distToNeighbor);
|
|
530
|
+
// If we have more than ef neighbors, remove the farthest one
|
|
531
|
+
if (nearest.size > ef) {
|
|
532
|
+
const sortedNearest = [...nearest].sort((a, b) => a[1] - b[1]);
|
|
533
|
+
nearest.clear();
|
|
534
|
+
for (let i = 0; i < ef; i++) {
|
|
535
|
+
nearest.set(sortedNearest[i][0], sortedNearest[i][1]);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
// Sort nearest by distance
|
|
544
|
+
return new Map([...nearest].sort((a, b) => a[1] - b[1]));
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Select M nearest neighbors from the candidate set
|
|
548
|
+
*/
|
|
549
|
+
selectNeighbors(queryVector, candidates, M) {
|
|
550
|
+
if (candidates.size <= M) {
|
|
551
|
+
return candidates;
|
|
552
|
+
}
|
|
553
|
+
// Simple heuristic: just take the M closest
|
|
554
|
+
const sortedCandidates = [...candidates].sort((a, b) => a[1] - b[1]);
|
|
555
|
+
const result = new Map();
|
|
556
|
+
for (let i = 0; i < Math.min(M, sortedCandidates.length); i++) {
|
|
557
|
+
result.set(sortedCandidates[i][0], sortedCandidates[i][1]);
|
|
558
|
+
}
|
|
559
|
+
return result;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Ensure a noun doesn't have too many connections at a given level
|
|
563
|
+
*/
|
|
564
|
+
pruneConnections(noun, level) {
|
|
565
|
+
const connections = noun.connections.get(level);
|
|
566
|
+
if (connections.size <= this.config.M) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
// Calculate distances to all neighbors
|
|
570
|
+
const distances = new Map();
|
|
571
|
+
const validNeighborIds = new Set();
|
|
572
|
+
for (const neighborId of connections) {
|
|
573
|
+
const neighbor = this.nouns.get(neighborId);
|
|
574
|
+
if (!neighbor) {
|
|
575
|
+
// Skip neighbors that don't exist (expected during rapid additions/deletions)
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
// Only add valid neighbors to the distances map
|
|
579
|
+
distances.set(neighborId, this.distanceFunction(noun.vector, neighbor.vector));
|
|
580
|
+
validNeighborIds.add(neighborId);
|
|
581
|
+
}
|
|
582
|
+
// Only proceed if we have valid neighbors
|
|
583
|
+
if (distances.size === 0) {
|
|
584
|
+
// If no valid neighbors, clear connections at this level
|
|
585
|
+
noun.connections.set(level, new Set());
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
// Select M closest neighbors from valid ones
|
|
589
|
+
const selectedNeighbors = this.selectNeighbors(noun.vector, distances, this.config.M);
|
|
590
|
+
// Update connections with only valid neighbors
|
|
591
|
+
noun.connections.set(level, new Set(selectedNeighbors.keys()));
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Generate a random level for a new noun
|
|
595
|
+
* Uses the same distribution as in the original HNSW paper
|
|
596
|
+
*/
|
|
597
|
+
getRandomLevel() {
|
|
598
|
+
const r = Math.random();
|
|
599
|
+
return Math.floor(-Math.log(r) * (1.0 / Math.log(this.config.M)));
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
//# sourceMappingURL=hnswIndex.js.map
|
|
@@ -0,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