rrf_weight (#5551)

Co-authored-by: xxYyh <xxyyh@xxYyhdeMacBook-Pro.local>
This commit is contained in:
YeYuheng
2025-08-29 00:54:29 +08:00
committed by GitHub
parent 486d791b94
commit e4756c76dd
4 changed files with 16 additions and 17 deletions

View File

@@ -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,取最大值