This commit is contained in:
Archer
2023-10-24 17:32:36 +08:00
committed by GitHub
parent 1942cb0d67
commit 1dca5edcc6
18 changed files with 142 additions and 73 deletions

View File

@@ -52,7 +52,7 @@ export async function dispatchKBSearch(props: Record<string, any>): Promise<KBSe
// search kb
const results: any = await PgClient.query(
`BEGIN;
SET LOCAL hnsw.ef_search = ${global.systemEnv.pgHNSWEfSearch || 60};
SET LOCAL hnsw.ef_search = ${global.systemEnv.pgHNSWEfSearch || 100};
select id, q, a, dataset_id, collection_id, (vector <#> '[${
vectors[0]
}]') * -1 AS score from ${PgDatasetTableName} where user_id='${

View File

@@ -195,7 +195,7 @@ export async function initPg() {
q TEXT NOT NULL,
a TEXT
);
CREATE INDEX IF NOT EXISTS vector_index ON ${PgDatasetTableName} USING hnsw (vector vector_ip_ops) WITH (m = 16, ef_construction = 64);
CREATE INDEX IF NOT EXISTS vector_index ON ${PgDatasetTableName} USING hnsw (vector vector_ip_ops) WITH (m = 24, ef_construction = 48);
`);
console.log('init pg successful');