diff --git a/internal/util/function/rerank/decay_function.go b/internal/util/function/rerank/decay_function.go index 953bc07d1a..ed2da41160 100644 --- a/internal/util/function/rerank/decay_function.go +++ b/internal/util/function/rerank/decay_function.go @@ -187,7 +187,7 @@ func (decay *DecayFunction[T, R]) processOneSearchData(ctx context.Context, sear ids := col.ids.([]T) for idx, id := range ids { if _, ok := decayScores[id]; !ok { - idLocations[id] = IDLoc{batchIdx: i, offset: idx} + idLocations[id] = IDLoc{batchIdx: i, offset: idx + int(col.nqOffset)} decayScores[id] = float32(decay.reScorer(decay.origin, decay.scale, decay.decay, decay.offset, float64(nums[idx]))) } } diff --git a/internal/util/function/rerank/model_function.go b/internal/util/function/rerank/model_function.go index a543c22626..75a4e50e67 100644 --- a/internal/util/function/rerank/model_function.go +++ b/internal/util/function/rerank/model_function.go @@ -151,7 +151,7 @@ func (model *ModelFunction[T]) processOneSearchData(ctx context.Context, searchP ids := col.ids.([]T) for idx, id := range ids { if _, ok := uniqueData[id]; !ok { - idLocations[id] = IDLoc{batchIdx: i, offset: idx} + idLocations[id] = IDLoc{batchIdx: i, offset: idx + int(col.nqOffset)} uniqueData[id] = texts[idx] } } diff --git a/internal/util/function/rerank/rrf_function.go b/internal/util/function/rerank/rrf_function.go index 9e1c9c49ec..def489150c 100644 --- a/internal/util/function/rerank/rrf_function.go +++ b/internal/util/function/rerank/rrf_function.go @@ -77,7 +77,7 @@ func (rrf *RRFFunction[T]) processOneSearchData(ctx context.Context, searchParam ids := col.ids.([]T) for idx, id := range ids { if score, ok := rrfScores[id]; !ok { - idLocations[id] = IDLoc{batchIdx: i, offset: idx} + idLocations[id] = IDLoc{batchIdx: i, offset: idx + int(col.nqOffset)} rrfScores[id] = 1 / (rrf.k + float32(idx+1)) } else { rrfScores[id] = score + 1/(rrf.k+float32(idx+1)) diff --git a/internal/util/function/rerank/util.go b/internal/util/function/rerank/util.go index e388d0f3e5..cd1a035e50 100644 --- a/internal/util/function/rerank/util.go +++ b/internal/util/function/rerank/util.go @@ -41,6 +41,8 @@ type columns struct { size int64 ids any scores []float32 + + nqOffset int64 } type rerankInputs struct { @@ -101,6 +103,7 @@ func newRerankInputs(multipSearchResultData []*schemapb.SearchResultData, inputF cols[i][retIdx].size = size cols[i][retIdx].ids = getIds(searchResult.Ids, start, size) cols[i][retIdx].scores = searchResult.Scores[start : start+size] + cols[i][retIdx].nqOffset = start } for _, fieldId := range inputFieldIds { fieldData, exist := multipIdField[retIdx][fieldId] diff --git a/internal/util/function/rerank/weighted_function.go b/internal/util/function/rerank/weighted_function.go index 552ba9fe89..3f5576c484 100644 --- a/internal/util/function/rerank/weighted_function.go +++ b/internal/util/function/rerank/weighted_function.go @@ -97,7 +97,7 @@ func (weighted *WeightedFunction[T]) processOneSearchData(ctx context.Context, s ids := col.ids.([]T) for j, id := range ids { if score, ok := weightedScores[id]; !ok { - idLocations[id] = IDLoc{batchIdx: i, offset: j} + idLocations[id] = IDLoc{batchIdx: i, offset: j + int(col.nqOffset)} weightedScores[id] = weighted.weight[i] * normFunc(col.scores[j]) } else { weightedScores[id] = score + weighted.weight[i]*normFunc(col.scores[j])