mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-21 11:43:56 +00:00
perf: hnsw query (#4596)
* perf: hnsw query * check response embedding recall result
This commit is contained in:
@@ -12,7 +12,8 @@ weight: 793
|
|||||||
|
|
||||||
## ⚙️ 优化
|
## ⚙️ 优化
|
||||||
|
|
||||||
1. Doc2x 文档解析,增加报错信息捕获,增加超时时长
|
1. Doc2x 文档解析,增加报错信息捕获,增加超时时长。
|
||||||
|
2. 调整 PG vector 查询语句,强制使用向量索引。
|
||||||
|
|
||||||
## 🐛 修复
|
## 🐛 修复
|
||||||
|
|
||||||
|
@@ -192,8 +192,7 @@ export class PgVectorCtrl {
|
|||||||
WITH relaxed_results AS MATERIALIZED (
|
WITH relaxed_results AS MATERIALIZED (
|
||||||
select id, collection_id, vector <#> '[${vector}]' AS score
|
select id, collection_id, vector <#> '[${vector}]' AS score
|
||||||
from ${DatasetVectorTableName}
|
from ${DatasetVectorTableName}
|
||||||
where team_id='${teamId}'
|
where dataset_id IN (${datasetIds.map((id) => `'${String(id)}'`).join(',')})
|
||||||
AND dataset_id IN (${datasetIds.map((id) => `'${String(id)}'`).join(',')})
|
|
||||||
${filterCollectionIdSql}
|
${filterCollectionIdSql}
|
||||||
${forbidCollectionSql}
|
${forbidCollectionSql}
|
||||||
order by score limit ${limit}
|
order by score limit ${limit}
|
||||||
@@ -202,6 +201,12 @@ export class PgVectorCtrl {
|
|||||||
);
|
);
|
||||||
const rows = results?.[3]?.rows as PgSearchRawType[];
|
const rows = results?.[3]?.rows as PgSearchRawType[];
|
||||||
|
|
||||||
|
if (!Array.isArray(rows)) {
|
||||||
|
return {
|
||||||
|
results: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
results: rows.map((item) => ({
|
results: rows.map((item) => ({
|
||||||
id: String(item.id),
|
id: String(item.id),
|
||||||
|
Reference in New Issue
Block a user