Commit a9525398 by Archer Committed by GitHub

perf: rrf code (#5558)

parent e4756c76
......@@ -37,6 +37,4 @@ files/helm/fastgpt/charts/*.tgz
tmp/
coverage
document/.source
bun.lock
\ No newline at end of file
document/.source
\ No newline at end of file
......@@ -101,6 +101,7 @@ description: FastGPT 文档目录
- [/docs/upgrading/4-12/4120](/docs/upgrading/4-12/4120)
- [/docs/upgrading/4-12/4121](/docs/upgrading/4-12/4121)
- [/docs/upgrading/4-12/4122](/docs/upgrading/4-12/4122)
- [/docs/upgrading/4-12/4123](/docs/upgrading/4-12/4123)
- [/docs/upgrading/4-8/40](/docs/upgrading/4-8/40)
- [/docs/upgrading/4-8/41](/docs/upgrading/4-8/41)
- [/docs/upgrading/4-8/42](/docs/upgrading/4-8/42)
......
---
title: 'V4.12.3(进行中)'
description: 'FastGPT V4.12.3 更新说明'
---
## 🚀 新增内容
## ⚙️ 优化
1. 纠正 RRF 权重合并算法,使用标准 RRF 权重公式。
## 🐛 修复
## 🔨 工具更新
{
"title": "4.12.x",
"description": "",
"pages": ["4122", "4121", "4120"]
"pages": ["4123", "4122", "4121", "4120"]
}
......@@ -41,7 +41,7 @@
"document/content/docs/introduction/guide/DialogBoxes/htmlRendering.mdx": "2025-07-23T21:35:03+08:00",
"document/content/docs/introduction/guide/DialogBoxes/quoteList.mdx": "2025-07-23T21:35:03+08:00",
"document/content/docs/introduction/guide/admin/sso.mdx": "2025-07-24T13:00:27+08:00",
"document/content/docs/introduction/guide/admin/teamMode.mdx": "2025-07-24T13:00:27+08:00",
"document/content/docs/introduction/guide/admin/teamMode.mdx": "2025-08-27T16:59:57+08:00",
"document/content/docs/introduction/guide/course/ai_settings.mdx": "2025-07-24T13:00:27+08:00",
"document/content/docs/introduction/guide/course/chat_input_guide.mdx": "2025-07-23T21:35:03+08:00",
"document/content/docs/introduction/guide/course/fileInput.mdx": "2025-07-23T21:35:03+08:00",
......@@ -104,7 +104,7 @@
"document/content/docs/upgrading/4-11/4111.mdx": "2025-08-07T22:49:09+08:00",
"document/content/docs/upgrading/4-12/4120.mdx": "2025-08-12T22:45:19+08:00",
"document/content/docs/upgrading/4-12/4121.mdx": "2025-08-15T22:53:06+08:00",
"document/content/docs/upgrading/4-12/4122.mdx": "2025-08-26T23:51:54+08:00",
"document/content/docs/upgrading/4-12/4122.mdx": "2025-08-27T00:31:33+08:00",
"document/content/docs/upgrading/4-8/40.mdx": "2025-08-02T19:38:37+08:00",
"document/content/docs/upgrading/4-8/41.mdx": "2025-08-02T19:38:37+08:00",
"document/content/docs/upgrading/4-8/42.mdx": "2025-08-02T19:38:37+08:00",
......
......@@ -18,7 +18,7 @@ export const datasetSearchResultConcat = (
item.list.forEach((data, index) => {
const rank = index + 1;
const score = (weight * 1) / (60 + rank);
const score = weight * (1 / (60 + rank));
const record = map.get(data.id);
if (record) {
// 合并两个score,有相同type的score,取最大值
......@@ -64,8 +64,9 @@ export const datasetSearchResultConcat = (
});
}
// @ts-ignore
delete item.rrfScore;
return item;
return {
...item,
rrfScore: undefined
};
});
};
......@@ -849,22 +849,16 @@ export async function searchDatasetData(
}
})();
// embedding recall and fullText recall rrf concat
const embWeight = embeddingWeight; // 向量索引的 weight 大小
const fullTextWeight = 1 - embeddingWeight; // 全文索引的 weight 大小
const rrfSearchResult = datasetSearchResultConcat([
{ weight: embWeight, list: embeddingRecallResults },
{ weight: fullTextWeight, list: fullTextRecallResults }
{ weight: embeddingWeight, list: embeddingRecallResults },
{ weight: 1 - embeddingWeight, list: fullTextRecallResults }
]);
const rrfConcatResults = (() => {
if (reRankResults.length === 0) return rrfSearchResult;
if (rerankWeight === 1) return reRankResults;
const searchWeight = 1 - rerankWeight; // 搜索结果的 weight 大小
return datasetSearchResultConcat([
{ weight: searchWeight, list: rrfSearchResult },
{ weight: 1 - rerankWeight, list: rrfSearchResult },
{ weight: rerankWeight, list: reRankResults }
]);
})();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment