23 lines
784 B
TypeScript
23 lines
784 B
TypeScript
export interface HnswSearchResult {
|
|
id: string;
|
|
score: number;
|
|
}
|
|
export declare class HnswLite {
|
|
private vectors;
|
|
private neighbors;
|
|
private readonly dimensions;
|
|
private readonly maxNeighbors;
|
|
private readonly efConstruction;
|
|
private readonly metric;
|
|
constructor(dimensions: number, m: number, efConstruction: number, metric: string);
|
|
get size(): number;
|
|
add(id: string, vector: Float32Array): void;
|
|
remove(id: string): void;
|
|
search(query: Float32Array, k: number, threshold?: number): HnswSearchResult[];
|
|
private bruteForce;
|
|
private findNearest;
|
|
private pruneNeighbors;
|
|
private similarity;
|
|
}
|
|
export declare function cosineSimilarity(a: Float32Array, b: Float32Array): number;
|
|
//# sourceMappingURL=hnsw-lite.d.ts.map
|