@soulcraft/brainy 0.24.0 → 0.26.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.
Files changed (107) hide show
  1. package/README.md +22 -16
  2. package/dist/brainy.js +4553 -2264
  3. package/dist/brainy.min.js +750 -750
  4. package/dist/brainyData.d.ts +141 -0
  5. package/dist/coreTypes.d.ts +31 -0
  6. package/dist/errors/brainyError.d.ts +45 -0
  7. package/dist/hnsw/hnswIndexOptimized.d.ts +13 -1
  8. package/dist/hnsw/hnswIndexOptimized.d.ts.map +1 -1
  9. package/dist/statistics/statisticsManager.d.ts +121 -0
  10. package/dist/storage/adapters/fileSystemStorage.d.ts +99 -30
  11. package/dist/storage/adapters/fileSystemStorage.d.ts.map +1 -1
  12. package/dist/storage/adapters/memoryStorage.d.ts.map +1 -1
  13. package/dist/storage/adapters/opfsStorage.d.ts +21 -1
  14. package/dist/storage/adapters/opfsStorage.d.ts.map +1 -1
  15. package/dist/storage/adapters/s3CompatibleStorage.d.ts +58 -1
  16. package/dist/storage/adapters/s3CompatibleStorage.d.ts.map +1 -1
  17. package/dist/storage/fileSystemStorage.d.ts +2 -15
  18. package/dist/storage/fileSystemStorage.d.ts.map +1 -1
  19. package/dist/storage/opfsStorage.d.ts +3 -66
  20. package/dist/storage/opfsStorage.d.ts.map +1 -1
  21. package/dist/storage/s3CompatibleStorage.d.ts +2 -14
  22. package/dist/storage/s3CompatibleStorage.d.ts.map +1 -1
  23. package/dist/storage/storageFactory.d.ts +6 -1
  24. package/dist/storage/storageFactory.d.ts.map +1 -1
  25. package/dist/testing/prettyReporter.d.ts +23 -0
  26. package/dist/testing/prettySummaryReporter.d.ts +22 -0
  27. package/dist/types/tensorflowTypes.d.ts +0 -8
  28. package/dist/types/tensorflowTypes.d.ts.map +1 -1
  29. package/dist/unified.d.ts +4 -0
  30. package/dist/unified.js +3170 -1464
  31. package/dist/unified.min.js +750 -750
  32. package/dist/utils/embedding.d.ts +7 -0
  33. package/dist/utils/embedding.d.ts.map +1 -1
  34. package/dist/utils/environmentDetection.d.ts +47 -0
  35. package/dist/utils/environmentDetection.d.ts.map +1 -0
  36. package/dist/utils/logger.d.ts +99 -0
  37. package/dist/utils/logger.d.ts.map +1 -0
  38. package/dist/utils/operationUtils.d.ts +58 -0
  39. package/dist/utils/operationUtils.d.ts.map +1 -0
  40. package/dist/utils/textEncoding.d.ts +0 -7
  41. package/dist/utils/textEncoding.d.ts.map +1 -1
  42. package/dist/utils/version.d.ts +1 -1
  43. package/package.json +14 -3
  44. package/dist/augmentations/conduitAugmentations.js +0 -1158
  45. package/dist/augmentations/conduitAugmentations.js.map +0 -1
  46. package/dist/augmentations/memoryAugmentations.js +0 -255
  47. package/dist/augmentations/memoryAugmentations.js.map +0 -1
  48. package/dist/augmentations/serverSearchAugmentations.js +0 -531
  49. package/dist/augmentations/serverSearchAugmentations.js.map +0 -1
  50. package/dist/examples/basicUsage.js +0 -128
  51. package/dist/examples/basicUsage.js.map +0 -1
  52. package/dist/hnsw/hnswIndex.js +0 -550
  53. package/dist/hnsw/hnswIndex.js.map +0 -1
  54. package/dist/hnsw/hnswIndexOptimized.js +0 -441
  55. package/dist/hnsw/hnswIndexOptimized.js.map +0 -1
  56. package/dist/mcp/brainyMCPAdapter.js +0 -142
  57. package/dist/mcp/brainyMCPAdapter.js.map +0 -1
  58. package/dist/mcp/brainyMCPService.js +0 -248
  59. package/dist/mcp/brainyMCPService.js.map +0 -1
  60. package/dist/mcp/index.js +0 -17
  61. package/dist/mcp/index.js.map +0 -1
  62. package/dist/mcp/mcpAugmentationToolset.js +0 -180
  63. package/dist/mcp/mcpAugmentationToolset.js.map +0 -1
  64. package/dist/storage/adapters/baseStorageAdapter.js +0 -233
  65. package/dist/storage/adapters/baseStorageAdapter.js.map +0 -1
  66. package/dist/storage/adapters/fileSystemStorage.js +0 -568
  67. package/dist/storage/adapters/fileSystemStorage.js.map +0 -1
  68. package/dist/storage/adapters/memoryStorage.js +0 -300
  69. package/dist/storage/adapters/memoryStorage.js.map +0 -1
  70. package/dist/storage/adapters/opfsStorage.js +0 -778
  71. package/dist/storage/adapters/opfsStorage.js.map +0 -1
  72. package/dist/storage/adapters/s3CompatibleStorage.js +0 -1021
  73. package/dist/storage/adapters/s3CompatibleStorage.js.map +0 -1
  74. package/dist/storage/baseStorage.js +0 -126
  75. package/dist/storage/baseStorage.js.map +0 -1
  76. package/dist/storage/storageFactory.js +0 -183
  77. package/dist/storage/storageFactory.js.map +0 -1
  78. package/dist/types/augmentations.js +0 -16
  79. package/dist/types/augmentations.js.map +0 -1
  80. package/dist/types/brainyDataInterface.js +0 -8
  81. package/dist/types/brainyDataInterface.js.map +0 -1
  82. package/dist/types/fileSystemTypes.js +0 -8
  83. package/dist/types/fileSystemTypes.js.map +0 -1
  84. package/dist/types/graphTypes.js +0 -36
  85. package/dist/types/graphTypes.js.map +0 -1
  86. package/dist/types/mcpTypes.js +0 -22
  87. package/dist/types/mcpTypes.js.map +0 -1
  88. package/dist/types/pipelineTypes.js +0 -7
  89. package/dist/types/pipelineTypes.js.map +0 -1
  90. package/dist/types/tensorflowTypes.js +0 -6
  91. package/dist/types/tensorflowTypes.js.map +0 -1
  92. package/dist/utils/distance.js +0 -239
  93. package/dist/utils/distance.js.map +0 -1
  94. package/dist/utils/embedding.js +0 -622
  95. package/dist/utils/embedding.js.map +0 -1
  96. package/dist/utils/environment.js +0 -75
  97. package/dist/utils/environment.js.map +0 -1
  98. package/dist/utils/index.js +0 -5
  99. package/dist/utils/index.js.map +0 -1
  100. package/dist/utils/statistics.js +0 -25
  101. package/dist/utils/statistics.js.map +0 -1
  102. package/dist/utils/tensorflowUtils.js +0 -25
  103. package/dist/utils/tensorflowUtils.js.map +0 -1
  104. package/dist/utils/textEncoding.js +0 -281
  105. package/dist/utils/textEncoding.js.map +0 -1
  106. package/dist/utils/workerUtils.js +0 -458
  107. package/dist/utils/workerUtils.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"bas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GAAG,CAAC,GAAG,IAAI,CAAA;YACvB,CAAC,CAAA;YAED,IAAI,CAAC;gBACH,MAAM,UAAU,EAAE,CAAA;YACpB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAA;YAChD,CAAC;YAED,sBAAsB;YACtB,OAAO,CAAC,GAAG,GAAG,WAAW,CAAA;QAC3B,CAAC,CAAC,CAAA;QAEF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACnC,CAAC,CAAC,CAAA;AACJ,CAAC;KAAM,CAAC;IACN,sBAAsB;IACtB,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,550 +0,0 @@
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
- };
104
- // Initialize empty connection sets for each level
105
- for (let level = 0; level <= nounLevel; level++) {
106
- noun.connections.set(level, new Set());
107
- }
108
- // If this is the first noun, make it the entry point
109
- if (this.nouns.size === 0) {
110
- this.entryPointId = id;
111
- this.maxLevel = nounLevel;
112
- this.nouns.set(id, noun);
113
- return id;
114
- }
115
- // Find entry point
116
- if (!this.entryPointId) {
117
- console.error('Entry point ID is null');
118
- // If there's no entry point, this is the first noun, so we should have returned earlier
119
- // This is a safety check
120
- this.entryPointId = id;
121
- this.maxLevel = nounLevel;
122
- this.nouns.set(id, noun);
123
- return id;
124
- }
125
- const entryPoint = this.nouns.get(this.entryPointId);
126
- if (!entryPoint) {
127
- console.error(`Entry point with ID ${this.entryPointId} not found`);
128
- // If the entry point doesn't exist, treat this as the first noun
129
- this.entryPointId = id;
130
- this.maxLevel = nounLevel;
131
- this.nouns.set(id, noun);
132
- return id;
133
- }
134
- let currObj = entryPoint;
135
- let currDist = this.distanceFunction(vector, entryPoint.vector);
136
- // Traverse the graph from top to bottom to find the closest noun
137
- for (let level = this.maxLevel; level > nounLevel; level--) {
138
- let changed = true;
139
- while (changed) {
140
- changed = false;
141
- // Check all neighbors at current level
142
- const connections = currObj.connections.get(level) || new Set();
143
- for (const neighborId of connections) {
144
- const neighbor = this.nouns.get(neighborId);
145
- if (!neighbor) {
146
- // Skip neighbors that don't exist (expected during rapid additions/deletions)
147
- continue;
148
- }
149
- const distToNeighbor = this.distanceFunction(vector, neighbor.vector);
150
- if (distToNeighbor < currDist) {
151
- currDist = distToNeighbor;
152
- currObj = neighbor;
153
- changed = true;
154
- }
155
- }
156
- }
157
- }
158
- // For each level from nounLevel down to 0
159
- for (let level = Math.min(nounLevel, this.maxLevel); level >= 0; level--) {
160
- // Find ef nearest elements using greedy search
161
- const nearestNouns = await this.searchLayer(vector, currObj, this.config.efConstruction, level);
162
- // Select M nearest neighbors
163
- const neighbors = this.selectNeighbors(vector, nearestNouns, this.config.M);
164
- // Add bidirectional connections
165
- for (const [neighborId, _] of neighbors) {
166
- const neighbor = this.nouns.get(neighborId);
167
- if (!neighbor) {
168
- // Skip neighbors that don't exist (expected during rapid additions/deletions)
169
- continue;
170
- }
171
- noun.connections.get(level).add(neighborId);
172
- // Add reverse connection
173
- if (!neighbor.connections.has(level)) {
174
- neighbor.connections.set(level, new Set());
175
- }
176
- neighbor.connections.get(level).add(id);
177
- // Ensure neighbor doesn't have too many connections
178
- if (neighbor.connections.get(level).size > this.config.M) {
179
- this.pruneConnections(neighbor, level);
180
- }
181
- }
182
- // Update entry point for the next level
183
- if (nearestNouns.size > 0) {
184
- const [nearestId, nearestDist] = [...nearestNouns][0];
185
- if (nearestDist < currDist) {
186
- currDist = nearestDist;
187
- const nearestNoun = this.nouns.get(nearestId);
188
- if (!nearestNoun) {
189
- console.error(`Nearest noun with ID ${nearestId} not found in addItem`);
190
- // Keep the current object as is
191
- }
192
- else {
193
- currObj = nearestNoun;
194
- }
195
- }
196
- }
197
- }
198
- // Update max level and entry point if needed
199
- if (nounLevel > this.maxLevel) {
200
- this.maxLevel = nounLevel;
201
- this.entryPointId = id;
202
- }
203
- // Add noun to the index
204
- this.nouns.set(id, noun);
205
- return id;
206
- }
207
- /**
208
- * Search for nearest neighbors
209
- */
210
- async search(queryVector, k = 10) {
211
- if (this.nouns.size === 0) {
212
- return [];
213
- }
214
- // Check if query vector is defined
215
- if (!queryVector) {
216
- throw new Error('Query vector is undefined or null');
217
- }
218
- if (this.dimension !== null && queryVector.length !== this.dimension) {
219
- throw new Error(`Query vector dimension mismatch: expected ${this.dimension}, got ${queryVector.length}`);
220
- }
221
- // Start from the entry point
222
- if (!this.entryPointId) {
223
- console.error('Entry point ID is null');
224
- return [];
225
- }
226
- const entryPoint = this.nouns.get(this.entryPointId);
227
- if (!entryPoint) {
228
- console.error(`Entry point with ID ${this.entryPointId} not found`);
229
- return [];
230
- }
231
- let currObj = entryPoint;
232
- let currDist = this.distanceFunction(queryVector, currObj.vector);
233
- // Traverse the graph from top to bottom to find the closest noun
234
- for (let level = this.maxLevel; level > 0; level--) {
235
- let changed = true;
236
- while (changed) {
237
- changed = false;
238
- // Check all neighbors at current level
239
- const connections = currObj.connections.get(level) || new Set();
240
- // If we have enough connections, use parallel distance calculation
241
- if (this.useParallelization && connections.size >= 10) {
242
- // Prepare vectors for parallel calculation
243
- const vectors = [];
244
- for (const neighborId of connections) {
245
- const neighbor = this.nouns.get(neighborId);
246
- if (!neighbor)
247
- continue;
248
- vectors.push({ id: neighborId, vector: neighbor.vector });
249
- }
250
- // Calculate distances in parallel
251
- const distances = await this.calculateDistancesInParallel(queryVector, vectors);
252
- // Find the closest neighbor
253
- for (const { id, distance } of distances) {
254
- if (distance < currDist) {
255
- currDist = distance;
256
- const neighbor = this.nouns.get(id);
257
- if (neighbor) {
258
- currObj = neighbor;
259
- changed = true;
260
- }
261
- }
262
- }
263
- }
264
- else {
265
- // Use sequential processing for small number of connections
266
- for (const neighborId of connections) {
267
- const neighbor = this.nouns.get(neighborId);
268
- if (!neighbor) {
269
- // Skip neighbors that don't exist (expected during rapid additions/deletions)
270
- continue;
271
- }
272
- const distToNeighbor = this.distanceFunction(queryVector, neighbor.vector);
273
- if (distToNeighbor < currDist) {
274
- currDist = distToNeighbor;
275
- currObj = neighbor;
276
- changed = true;
277
- }
278
- }
279
- }
280
- }
281
- }
282
- // Search at level 0 with ef = k
283
- const nearestNouns = await this.searchLayer(queryVector, currObj, Math.max(this.config.efSearch, k), 0);
284
- // Convert to array and sort by distance
285
- return [...nearestNouns].slice(0, k);
286
- }
287
- /**
288
- * Remove an item from the index
289
- */
290
- removeItem(id) {
291
- if (!this.nouns.has(id)) {
292
- return false;
293
- }
294
- const noun = this.nouns.get(id);
295
- // Remove connections to this noun from all neighbors
296
- for (const [level, connections] of noun.connections.entries()) {
297
- for (const neighborId of connections) {
298
- const neighbor = this.nouns.get(neighborId);
299
- if (!neighbor) {
300
- // Skip neighbors that don't exist (expected during rapid additions/deletions)
301
- continue;
302
- }
303
- if (neighbor.connections.has(level)) {
304
- neighbor.connections.get(level).delete(id);
305
- // Prune connections after removing this noun to ensure consistency
306
- this.pruneConnections(neighbor, level);
307
- }
308
- }
309
- }
310
- // Also check all other nouns for references to this noun and remove them
311
- for (const [nounId, otherNoun] of this.nouns.entries()) {
312
- if (nounId === id)
313
- continue; // Skip the noun being removed
314
- for (const [level, connections] of otherNoun.connections.entries()) {
315
- if (connections.has(id)) {
316
- connections.delete(id);
317
- // Prune connections after removing this reference
318
- this.pruneConnections(otherNoun, level);
319
- }
320
- }
321
- }
322
- // Remove the noun
323
- this.nouns.delete(id);
324
- // If we removed the entry point, find a new one
325
- if (this.entryPointId === id) {
326
- if (this.nouns.size === 0) {
327
- this.entryPointId = null;
328
- this.maxLevel = 0;
329
- }
330
- else {
331
- // Find the noun with the highest level
332
- let maxLevel = 0;
333
- let newEntryPointId = null;
334
- for (const [nounId, noun] of this.nouns.entries()) {
335
- if (noun.connections.size === 0)
336
- continue; // Skip nouns with no connections
337
- const nounLevel = Math.max(...noun.connections.keys());
338
- if (nounLevel >= maxLevel) {
339
- maxLevel = nounLevel;
340
- newEntryPointId = nounId;
341
- }
342
- }
343
- this.entryPointId = newEntryPointId;
344
- this.maxLevel = maxLevel;
345
- }
346
- }
347
- return true;
348
- }
349
- /**
350
- * Get all nouns in the index
351
- */
352
- getNouns() {
353
- return new Map(this.nouns);
354
- }
355
- /**
356
- * Clear the index
357
- */
358
- clear() {
359
- this.nouns.clear();
360
- this.entryPointId = null;
361
- this.maxLevel = 0;
362
- }
363
- /**
364
- * Get the size of the index
365
- */
366
- size() {
367
- return this.nouns.size;
368
- }
369
- /**
370
- * Get the distance function used by the index
371
- */
372
- getDistanceFunction() {
373
- return this.distanceFunction;
374
- }
375
- /**
376
- * Get the entry point ID
377
- */
378
- getEntryPointId() {
379
- return this.entryPointId;
380
- }
381
- /**
382
- * Get the maximum level
383
- */
384
- getMaxLevel() {
385
- return this.maxLevel;
386
- }
387
- /**
388
- * Get the dimension
389
- */
390
- getDimension() {
391
- return this.dimension;
392
- }
393
- /**
394
- * Get the configuration
395
- */
396
- getConfig() {
397
- return { ...this.config };
398
- }
399
- /**
400
- * Search within a specific layer
401
- * Returns a map of noun IDs to distances, sorted by distance
402
- */
403
- async searchLayer(queryVector, entryPoint, ef, level) {
404
- // Set of visited nouns
405
- const visited = new Set([entryPoint.id]);
406
- // Priority queue of candidates (closest first)
407
- const candidates = new Map();
408
- candidates.set(entryPoint.id, this.distanceFunction(queryVector, entryPoint.vector));
409
- // Priority queue of nearest neighbors found so far (closest first)
410
- const nearest = new Map();
411
- nearest.set(entryPoint.id, this.distanceFunction(queryVector, entryPoint.vector));
412
- // While there are candidates to explore
413
- while (candidates.size > 0) {
414
- // Get closest candidate
415
- const [closestId, closestDist] = [...candidates][0];
416
- candidates.delete(closestId);
417
- // If this candidate is farther than the farthest in our result set, we're done
418
- const farthestInNearest = [...nearest][nearest.size - 1];
419
- if (nearest.size >= ef && closestDist > farthestInNearest[1]) {
420
- break;
421
- }
422
- // Explore neighbors of the closest candidate
423
- const noun = this.nouns.get(closestId);
424
- if (!noun) {
425
- console.error(`Noun with ID ${closestId} not found in searchLayer`);
426
- continue;
427
- }
428
- const connections = noun.connections.get(level) || new Set();
429
- // If we have enough connections and parallelization is enabled, use parallel distance calculation
430
- if (this.useParallelization && connections.size >= 10) {
431
- // Collect unvisited neighbors
432
- const unvisitedNeighbors = [];
433
- for (const neighborId of connections) {
434
- if (!visited.has(neighborId)) {
435
- visited.add(neighborId);
436
- const neighbor = this.nouns.get(neighborId);
437
- if (!neighbor)
438
- continue;
439
- unvisitedNeighbors.push({ id: neighborId, vector: neighbor.vector });
440
- }
441
- }
442
- if (unvisitedNeighbors.length > 0) {
443
- // Calculate distances in parallel
444
- const distances = await this.calculateDistancesInParallel(queryVector, unvisitedNeighbors);
445
- // Process the results
446
- for (const { id, distance } of distances) {
447
- // If we haven't found ef nearest neighbors yet, or this neighbor is closer than the farthest one we've found
448
- if (nearest.size < ef || distance < farthestInNearest[1]) {
449
- candidates.set(id, distance);
450
- nearest.set(id, distance);
451
- // If we have more than ef neighbors, remove the farthest one
452
- if (nearest.size > ef) {
453
- const sortedNearest = [...nearest].sort((a, b) => a[1] - b[1]);
454
- nearest.clear();
455
- for (let i = 0; i < ef; i++) {
456
- nearest.set(sortedNearest[i][0], sortedNearest[i][1]);
457
- }
458
- }
459
- }
460
- }
461
- }
462
- }
463
- else {
464
- // Use sequential processing for small number of connections
465
- for (const neighborId of connections) {
466
- if (!visited.has(neighborId)) {
467
- visited.add(neighborId);
468
- const neighbor = this.nouns.get(neighborId);
469
- if (!neighbor) {
470
- // Skip neighbors that don't exist (expected during rapid additions/deletions)
471
- continue;
472
- }
473
- const distToNeighbor = this.distanceFunction(queryVector, neighbor.vector);
474
- // If we haven't found ef nearest neighbors yet, or this neighbor is closer than the farthest one we've found
475
- if (nearest.size < ef || distToNeighbor < farthestInNearest[1]) {
476
- candidates.set(neighborId, distToNeighbor);
477
- nearest.set(neighborId, distToNeighbor);
478
- // If we have more than ef neighbors, remove the farthest one
479
- if (nearest.size > ef) {
480
- const sortedNearest = [...nearest].sort((a, b) => a[1] - b[1]);
481
- nearest.clear();
482
- for (let i = 0; i < ef; i++) {
483
- nearest.set(sortedNearest[i][0], sortedNearest[i][1]);
484
- }
485
- }
486
- }
487
- }
488
- }
489
- }
490
- }
491
- // Sort nearest by distance
492
- return new Map([...nearest].sort((a, b) => a[1] - b[1]));
493
- }
494
- /**
495
- * Select M nearest neighbors from the candidate set
496
- */
497
- selectNeighbors(queryVector, candidates, M) {
498
- if (candidates.size <= M) {
499
- return candidates;
500
- }
501
- // Simple heuristic: just take the M closest
502
- const sortedCandidates = [...candidates].sort((a, b) => a[1] - b[1]);
503
- const result = new Map();
504
- for (let i = 0; i < Math.min(M, sortedCandidates.length); i++) {
505
- result.set(sortedCandidates[i][0], sortedCandidates[i][1]);
506
- }
507
- return result;
508
- }
509
- /**
510
- * Ensure a noun doesn't have too many connections at a given level
511
- */
512
- pruneConnections(noun, level) {
513
- const connections = noun.connections.get(level);
514
- if (connections.size <= this.config.M) {
515
- return;
516
- }
517
- // Calculate distances to all neighbors
518
- const distances = new Map();
519
- const validNeighborIds = new Set();
520
- for (const neighborId of connections) {
521
- const neighbor = this.nouns.get(neighborId);
522
- if (!neighbor) {
523
- // Skip neighbors that don't exist (expected during rapid additions/deletions)
524
- continue;
525
- }
526
- // Only add valid neighbors to the distances map
527
- distances.set(neighborId, this.distanceFunction(noun.vector, neighbor.vector));
528
- validNeighborIds.add(neighborId);
529
- }
530
- // Only proceed if we have valid neighbors
531
- if (distances.size === 0) {
532
- // If no valid neighbors, clear connections at this level
533
- noun.connections.set(level, new Set());
534
- return;
535
- }
536
- // Select M closest neighbors from valid ones
537
- const selectedNeighbors = this.selectNeighbors(noun.vector, distances, this.config.M);
538
- // Update connections with only valid neighbors
539
- noun.connections.set(level, new Set(selectedNeighbors.keys()));
540
- }
541
- /**
542
- * Generate a random level for a new noun
543
- * Uses the same distribution as in the original HNSW paper
544
- */
545
- getRandomLevel() {
546
- const r = Math.random();
547
- return Math.floor(-Math.log(r) * (1.0 / Math.log(this.config.M)));
548
- }
549
- }
550
- //# sourceMappingURL=hnswIndex.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hnswIndex.js","sourceRoot":"","sources":["../../src/hnsw/hnswIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAG9E,0BAA0B;AAC1B,MAAM,cAAc,GAAe;IACjC,CAAC,EAAE,EAAE,EAAE,qCAAqC;IAC5C,cAAc,EAAE,GAAG,EAAE,uDAAuD;IAC5E,QAAQ,EAAE,EAAE,EAAE,iDAAiD;IAC/D,EAAE,EAAE,EAAE,CAAC,YAAY;CACpB,CAAA;AAED,MAAM,OAAO,SAAS;IASpB,YACE,SAA8B,EAAE,EAChC,mBAAqC,iBAAiB,EACtD,U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