feat: expose hnsw indices (#1595)

PR closes #1522

---------

Co-authored-by: Will Jones <willjones127@gmail.com>
This commit is contained in:
Gagan Bhullar
2024-09-10 12:08:13 -06:00
committed by GitHub
parent 2bde5401eb
commit 205fc530cf
6 changed files with 291 additions and 3 deletions

View File

@@ -113,6 +113,25 @@ export interface IvfPqOptions {
sampleRate?: number;
}
export interface HnswPqOptions {
distanceType?: "l2" | "cosine" | "dot";
numPartitions?: number;
numSubVectors?: number;
maxIterations?: number;
sampleRate?: number;
m?: number;
efConstruction?: number;
}
export interface HnswSqOptions {
distanceType?: "l2" | "cosine" | "dot";
numPartitions?: number;
maxIterations?: number;
sampleRate?: number;
m?: number;
efConstruction?: number;
}
/**
* Options to create a full text search index
*/
@@ -227,6 +246,43 @@ export class Index {
static fts(options?: Partial<FtsOptions>) {
return new Index(LanceDbIndex.fts(options?.withPositions));
}
/**
*
* Create a hnswpq index
*
*/
static hnswPq(options?: Partial<HnswPqOptions>) {
return new Index(
LanceDbIndex.hnswPq(
options?.distanceType,
options?.numPartitions,
options?.numSubVectors,
options?.maxIterations,
options?.sampleRate,
options?.m,
options?.efConstruction,
),
);
}
/**
*
* Create a hnswsq index
*
*/
static hnswSq(options?: Partial<HnswSqOptions>) {
return new Index(
LanceDbIndex.hnswSq(
options?.distanceType,
options?.numPartitions,
options?.maxIterations,
options?.sampleRate,
options?.m,
options?.efConstruction,
),
);
}
}
export interface IndexOptions {