feat: retrival eval title fallback add fuzzy matching#434
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces fuzzy title matching capabilities and fallback metrics computation to the retrieval evaluation pipeline. Specifically, it adds configuration options and CLI arguments for fuzzy matching, implements character n-gram prefiltering to optimize candidate selection, and updates the hit resolution logic to use SequenceMatcher. Additionally, it expands standard retrieval metrics (adding NDCG@100, Recall@20, Precision@10, and MAP@10) and introduces a fallback mechanism to compute metrics from search traces when MTEB results are empty or tasks fail. The review feedback suggests a valuable performance optimization in the fuzzy matching loop of resolve_hit by leveraging real_quick_ratio() and quick_ratio() to skip expensive similarity computations for unlikely candidates.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| for candidate_norm, candidate_ids in iterable_candidates: | ||
| score = SequenceMatcher(None, norm, candidate_norm).ratio() | ||
| if score > best_score: | ||
| second_score = best_score | ||
| best_score = score | ||
| best_ids = candidate_ids | ||
| elif score > second_score: | ||
| second_score = score |
There was a problem hiding this comment.
Using SequenceMatcher.ratio() in a loop over hundreds of candidates for every search hit can be extremely slow and lead to significant performance bottlenecks. We can optimize this by leveraging real_quick_ratio() and quick_ratio(), which are fast-to-compute upper bounds of the true ratio. If these upper bounds are less than or equal to the current second_score, we can safely skip the expensive ratio() computation.
for candidate_norm, candidate_ids in iterable_candidates:
matcher = SequenceMatcher(None, norm, candidate_norm)
if matcher.real_quick_ratio() <= second_score:
continue
if matcher.quick_ratio() <= second_score:
continue
score = matcher.ratio()
if score > best_score:
second_score = best_score
best_score = score
best_ids = candidate_ids
elif score > second_score:
second_score = score
No description provided.