Repository navigation
Conversation
…nt#10611) DBSF (Distribution-Based Score Fusion) normalized scores assuming higher scores are always better (Order::LargeBetter). For distance metrics where smaller values indicate closer matches (Order::SmallBetter, such as Euclidean and Manhattan), this inverted relative score magnitudes and reversed result rankings, violating search idempotence when fusing identical retrievers. - Update ScoreFusion to support source-level source_orders. - Make norm, min_max_norm, and distr_norm aware of Order::SmallBetter, inverting score normalization to map closest distances to high normalized scores. - Automatically infer Order::SmallBetter when source results are ordered ascending. - Propagate prefetch metric orders in collection query fusion. - Add unit tests reproducing the identical Euclidean retriever fusion and hybrid scoring. Closes qdrant#10611.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughDBSF now tracks the ordering direction of each prefetch result. Collection queries derive these orders from query configuration and pass them to Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The metric-order wiring preserves Euclidean distance ordering for reachable configured vector queries, with no unresolved merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. I’m a rabbit with scores in a row Comment |
All Submissions:
devbranch (notmaster) and my branch was created fromdev.Changes to Core Features:
Description
Fixes #10611
When fusing scores from multiple retrievers with Distribution-Based Score Fusion (DBSF), normalization ($(s - min) / (max - min)$ , implicitly assuming that higher raw scores always mean better similarity (
distr_normandmin_max_norm) was previously computed asOrder::LargeBetter).For distance metrics such as Euclidean (L2) or Manhattan, smaller values indicate closer/better points ($(s - min) / (max - min)$ inverted the score ordering: points with the lowest distance (best match) received normalized scores near
Order::SmallBetter). Normalizing with0.0, while the farthest points received scores near1.0. Consequently, fusing identical Euclidean retrievers completely reversed the result ranking order (the worst point became top-1).Key Changes:
lib/segment/src/common/score_fusion.rs:source_orders: Vec<Order>support toScoreFusionwith constructorScoreFusion::dbsf_with_orders(...).norm,min_max_norm,distr_norm) to accept the source metricOrder.Order::SmallBetter, scores are normalized inversely as1.0.score_fusion: if explicitsource_ordersare not supplied, inspects whether the input list is ascending (first.score < last.score), as Qdrant searches return results pre-sorted best-to-worst.test_dbsf_euclid_identical_retrievers: verifies that fusing identical Euclidean score lists preserves ranking order.test_dbsf_small_better_ordering: verifies single and multi-point normalization forOrder::SmallBetter.test_dbsf_hybrid_large_and_small_better: verifies hybrid fusion betweenOrder::LargeBetter(cosine/dot) andOrder::SmallBetter(Euclidean).test_min_max_norm_small_better: unit tests formin_max_normunder both orderings.lib/collection/src/collection/query.rs:intermediates_to_final_list, resolved prefetch source orders viashard_query::query_result_order(prefetch.query.as_ref(), &collection_params).source_orderstoScoreFusion::dbsf_with_orders(source_orders)whenFusion::Dbsfis invoked.Verification
cargo test -p segment -- common::score_fusion: 5/5 unit tests passed.cargo clippy -p segment -p collection -- -D warnings: passed with 0 warnings.rustfmt(--edition 2024).