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
e4756c76
authored
Aug 29, 2025
by
YeYuheng
Committed by
GitHub
Aug 29, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rrf_weight (#5551)
Co-authored-by: xxYyh <xxyyh@xxYyhdeMacBook-Pro.local>
parent
486d791b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
18 deletions
+17
-18
.gitignore
+4
-2
packages/global/core/dataset/search/utils.ts
+3
-4
packages/service/core/dataset/search/controller.ts
+9
-11
packages/service/core/workflow/dispatch/dataset/concat.ts
+1
-1
No files found.
.gitignore
View file @
e4756c76
...
...
@@ -37,4 +37,6 @@ files/helm/fastgpt/charts/*.tgz
tmp/
coverage
document/.source
\ No newline at end of file
document/.source
bun.lock
\ No newline at end of file
packages/global/core/dataset/search/utils.ts
View file @
e4756c76
...
...
@@ -3,7 +3,7 @@ import { type SearchDataResponseItemType } from '../type';
/* dataset search result concat */
export
const
datasetSearchResultConcat
=
(
arr
:
{
k
:
number
;
list
:
SearchDataResponseItemType
[]
}[]
arr
:
{
weight
:
number
;
list
:
SearchDataResponseItemType
[]
}[]
):
SearchDataResponseItemType
[]
=>
{
arr
=
arr
.
filter
((
item
)
=>
item
.
list
.
length
>
0
);
...
...
@@ -14,12 +14,11 @@ export const datasetSearchResultConcat = (
// rrf
arr
.
forEach
((
item
)
=>
{
const
k
=
item
.
k
;
const
weight
=
item
.
weight
;
item
.
list
.
forEach
((
data
,
index
)
=>
{
const
rank
=
index
+
1
;
const
score
=
1
/
(
k
+
rank
);
const
score
=
(
weight
*
1
)
/
(
60
+
rank
);
const
record
=
map
.
get
(
data
.
id
);
if
(
record
)
{
// 合并两个score,有相同type的score,取最大值
...
...
packages/service/core/dataset/search/controller.ts
View file @
e4756c76
...
...
@@ -784,10 +784,10 @@ export async function searchDatasetData(
// rrf concat
const
rrfEmbRecall
=
datasetSearchResultConcat
(
embeddingRecallResults
.
map
((
list
)
=>
({
k
:
60
,
list
}))
embeddingRecallResults
.
map
((
list
)
=>
({
weight
:
1
,
list
}))
).
slice
(
0
,
embeddingLimit
);
const
rrfFTRecall
=
datasetSearchResultConcat
(
fullTextRecallResults
.
map
((
list
)
=>
({
k
:
60
,
list
}))
fullTextRecallResults
.
map
((
list
)
=>
({
weight
:
1
,
list
}))
).
slice
(
0
,
fullTextLimit
);
return
{
...
...
@@ -850,24 +850,22 @@ export async function searchDatasetData(
})();
// embedding recall and fullText recall rrf concat
const
baseK
=
120
;
const
embK
=
Math
.
round
(
baseK
*
(
1
-
embeddingWeight
));
// 搜索结果的 k 值
const
fullTextK
=
Math
.
round
(
baseK
*
embeddingWeight
);
// rerank 结果的 k 值
const
embWeight
=
embeddingWeight
;
// 向量索引的 weight 大小
const
fullTextWeight
=
1
-
embeddingWeight
;
// 全文索引的 weight 大小
const
rrfSearchResult
=
datasetSearchResultConcat
([
{
k
:
embK
,
list
:
embeddingRecallResults
},
{
k
:
fullTextK
,
list
:
fullTextRecallResults
}
{
weight
:
embWeight
,
list
:
embeddingRecallResults
},
{
weight
:
fullTextWeight
,
list
:
fullTextRecallResults
}
]);
const
rrfConcatResults
=
(()
=>
{
if
(
reRankResults
.
length
===
0
)
return
rrfSearchResult
;
if
(
rerankWeight
===
1
)
return
reRankResults
;
const
searchK
=
Math
.
round
(
baseK
*
rerankWeight
);
// 搜索结果的 k 值
const
rerankK
=
Math
.
round
(
baseK
*
(
1
-
rerankWeight
));
// rerank 结果的 k 值
const
searchWeight
=
1
-
rerankWeight
;
// 搜索结果的 weight 大小
return
datasetSearchResultConcat
([
{
k
:
searchK
,
list
:
rrfSearchResult
},
{
k
:
rerankK
,
list
:
reRankResults
}
{
weight
:
searchWeight
,
list
:
rrfSearchResult
},
{
weight
:
rerankWeight
,
list
:
reRankResults
}
]);
})();
...
...
packages/service/core/workflow/dispatch/dataset/concat.ts
View file @
e4756c76
...
...
@@ -29,7 +29,7 @@ export async function dispatchDatasetConcat(
const
rrfConcatResults
=
datasetSearchResultConcat
(
quoteList
.
map
((
list
)
=>
({
k
:
60
,
weight
:
1
,
list
}))
);
...
...
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