Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
d4169bf0
authored
May 09, 2024
by
Archer
Committed by
GitHub
May 09, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: embedding recall drop-dead halt (#1415)
parent
afe5039c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
8 deletions
+15
-8
packages/service/common/vectorStore/controller.d.ts
+1
-0
packages/service/common/vectorStore/pg/controller.ts
+8
-3
packages/service/core/dataset/search/controller.ts
+6
-5
No files found.
packages/service/common/vectorStore/controller.d.ts
View file @
d4169bf0
...
...
@@ -13,6 +13,7 @@ export type InsertVectorProps = {
};
export
type
EmbeddingRecallProps
=
{
teamId
:
string
;
datasetIds
:
string
[];
similarity
?:
number
;
efSearch
?:
number
;
...
...
packages/service/common/vectorStore/pg/controller.ts
View file @
d4169bf0
...
...
@@ -129,7 +129,7 @@ export const embeddingRecall = async (
):
Promise
<
{
results
:
EmbeddingRecallItemType
[];
}
>
=>
{
const
{
datasetIds
,
vectors
,
limit
,
similarity
=
0
,
retry
=
2
,
efSearch
=
100
}
=
props
;
const
{
teamId
,
datasetIds
,
vectors
,
limit
,
similarity
=
0
,
retry
=
2
,
efSearch
=
100
}
=
props
;
try
{
const
results
:
any
=
await
PgClient
.
query
(
...
...
@@ -137,7 +137,8 @@ export const embeddingRecall = async (
SET LOCAL hnsw.ef_search =
${
efSearch
}
;
select id, collection_id, vector <#> '[
${
vectors
[
0
]}
]' AS score
from
${
PgDatasetTableName
}
where dataset_id IN (
${
datasetIds
.
map
((
id
)
=>
`'
${
String
(
id
)}
'`
).
join
(
','
)}
)
where team_id='
${
teamId
}
'
AND dataset_id IN (
${
datasetIds
.
map
((
id
)
=>
`'
${
String
(
id
)}
'`
).
join
(
','
)}
)
AND vector <#> '[
${
vectors
[
0
]}
]' < -
${
similarity
}
order by score limit
${
limit
}
;
COMMIT;`
...
...
@@ -153,10 +154,14 @@ export const embeddingRecall = async (
}))
};
}
catch
(
error
)
{
console
.
log
(
error
);
if
(
retry
<=
0
)
{
return
Promise
.
reject
(
error
);
}
return
embeddingRecall
(
props
);
return
embeddingRecall
({
...
props
,
retry
:
retry
-
1
});
}
};
...
...
packages/service/core/dataset/search/controller.ts
View file @
d4169bf0
...
...
@@ -59,19 +59,19 @@ export async function searchDatasetData(props: SearchDatasetDataProps) {
const
countRecallLimit
=
()
=>
{
if
(
searchMode
===
DatasetSearchModeEnum
.
embedding
)
{
return
{
embeddingLimit
:
1
5
0
,
embeddingLimit
:
1
0
0
,
fullTextLimit
:
0
};
}
if
(
searchMode
===
DatasetSearchModeEnum
.
fullTextRecall
)
{
return
{
embeddingLimit
:
0
,
fullTextLimit
:
1
5
0
fullTextLimit
:
1
0
0
};
}
return
{
embeddingLimit
:
10
0
,
fullTextLimit
:
8
0
embeddingLimit
:
8
0
,
fullTextLimit
:
6
0
};
};
const
embeddingRecall
=
async
({
query
,
limit
}:
{
query
:
string
;
limit
:
number
})
=>
{
...
...
@@ -82,9 +82,10 @@ export async function searchDatasetData(props: SearchDatasetDataProps) {
});
const
{
results
}
=
await
recallFromVectorStore
({
teamId
,
datasetIds
,
vectors
,
limit
,
datasetIds
,
efSearch
:
global
.
systemEnv
?.
pgHNSWEfSearch
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment