perf: rrf code (#5558)

This commit is contained in:
Archer
2025-08-29 01:24:19 +08:00
committed by GitHub
parent e4756c76dd
commit a952539875
8 changed files with 504 additions and 19 deletions

View File

@@ -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 }
]);
})();