未验证 提交 3cc8ee29 编写于 作者: D dragondriver 提交者: GitHub

Filter NaN when reducing search results (#6806)

Signed-off-by: Ndragondriver <jiquan.long@zilliz.com>
上级 93f0c9d8
......@@ -1698,6 +1698,10 @@ func reduceSearchResultDataParallel(searchResultData []*schemapb.SearchResultDat
continue
}
distance := searchResultData[q].Scores[idx*topk+loc]
// https://github.com/milvus-io/milvus/issues/6781
if math.IsNaN(float64(distance)) {
continue
}
if distance > maxDistance || (math.Abs(float64(distance-maxDistance)) < math.SmallestNonzeroFloat32 && choice != q) {
choice = q
maxDistance = distance
......@@ -1710,7 +1714,12 @@ func reduceSearchResultDataParallel(searchResultData []*schemapb.SearchResultDat
choiceOffset := locs[choice]
// check if distance is valid, `invalid` here means very very big,
// in this process, distance here is the smallest, so the rest of distance are all invalid
if searchResultData[choice].Scores[idx*topk+choiceOffset] <= minFloat32 {
// https://github.com/milvus-io/milvus/issues/6781
// tanimoto distance between two binary vectors maybe -inf, so -inf distance shouldn't be filtered,
// otherwise it will cause that the number of hit records is less than needed (topk).
// in the above process, we have already filtered NaN distance.
distance := searchResultData[choice].Scores[idx*topk+choiceOffset]
if distance < minFloat32 {
break
}
curIdx := idx*topk + choiceOffset
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册