AI Wiki中文/EN

Hybrid search: merge evidence without trusting its scale

混合检索

Compare raw scores, normalization and reciprocal ranks on complementary lists.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Two lists find different repair notes

A lexical search finds exact product terms. A learned retriever finds a useful paraphrase. Combining their candidates can cover more of the reader’s need, but combining their scores is not automatically meaningful: 12 points from one ranker and 0.95 from another are not measurements on a shared scale.

Hybrid search combines retrieval signals or candidate sources. A typical application mixes lexical and learned retrieval, but the same issues arise when combining fields, indexes or several learned retrievers. First keep a non-AI lexical baseline, define the query needs and relevance labels, and decide how many candidates the latency budget permits. A fusion method should earn its place on development queries and a separate final test set.

The DPR first version provides a specific historical hybrid: rerank the top 2,000 BM25 passages by BM25 score plus 1.1 times DPR similarity, with the coefficient selected on development retrieval accuracy. It does not describe a union of two independently truncated lists for that experiment. Our experiment below uses such a union and declares its missing-score policy separately. DPR, physical PDF5

The candidate union can cover every relevant document while fusion misorders them.
The candidate union can cover every relevant document while fusion misorders them.

Scores, normalized scores and ranks

With lexical score a and learned score b, a weighted blend is:

sα(d)=αa(d)+(1−α)b(d),0≤α≤1.s_\alpha(d)=\alpha a(d)+(1-\alpha)b(d),\qquad 0\leq\alpha\leq1.

If b is multiplied by 100 without changing its order, the blend can change dramatically. The weight only has meaning together with the score conventions. Multiplying a complete blend by a positive constant does not change its order; rescaling just one input usually does.

Our optional normalization first fills missing scores with zero over the candidate union, then applies min-max scaling independently to each input list:

s~(d)={s(d)−smin⁡smax⁡−smin⁡,smax⁡>smin⁡,0,smax⁡=smin⁡.\tilde s(d)=\begin{cases}\dfrac{s(d)-s_{\min}}{s_{\max}-s_{\min}},&s_{\max}>s_{\min},\\0,&s_{\max}=s_{\min}.\end{cases}

This is a declared engineering convention. Missing does not mean observed irrelevance, and zero need not be a natural neutral score for another system. A constant list becomes zero rather than dividing by zero. Min-max normalization can be sensitive to outliers and does not calibrate probabilities.

Reciprocal rank fusion (RRF) discards score magnitudes. Each list ranks its first document at 1. With nonnegative constant c and retained rankings L, our truncated-list extension is:

RRF(d)=∑ℓ∈L: d∈ℓ1c+rℓ(d).\mathrm{RRF}(d)=\sum_{\ell\in L:\,d\in\ell}\frac{1}{c+r_\ell(d)}.

A missing document contributes zero. The original paper defines rankings as permutations of a common document set; its equation sums over those rankings. The paper selected constant 60 in a pilot and held it fixed in later validation. That historical choice is neither a universal optimum nor the number of returned documents. RRF, section 1

A strictly increasing score transformation preserves each list’s order, hence preserves RRF if retained documents and tie rules also stay unchanged. RRF still depends on truncation depth, the number of contributing lists and correlated mistakes. Adding the same list twice effectively increases its vote; accidental duplicate document IDs within a list should not count twice.

For candidate union C and nonempty relevant set R, the maximum recall before display truncation is:

CandidateRecall=∣C∩R∣∣R∣,C=⋃ℓprefix⁡K(ℓ).\mathrm{CandidateRecall}=\frac{|C\cap R|}{|R|},\qquad C=\bigcup_\ell\operatorname{prefix}_K(\ell).

Sorting can waste some of that potential. At a displayed cutoff k, our precision and recall are:

P@k=∣Lk∩R∣k,Recall@k=∣Lk∩R∣∣R∣.P@k=\frac{|L_k\cap R|}{k},\qquad\mathrm{Recall}@k=\frac{|L_k\cap R|}{|R|}.

Unused display slots count as misses for this precision convention. The experiment has four relevant documents, so precision and recall at four happen to be equal; this is not generally true.

The shared error gets two votes

Run the standard-library program with Python 3.12. It uses authored scores for the fictional bicycle-repair documents, with relevance set {0,4,5,7}. A returns [0,5,3,1,7], B returns [4,7,3,2,0]. Document 3 concerns car repair and is irrelevant to this need. These score tables isolate fusion behavior; they are not measured BM25 or neural-model outputs.

"""Original score-fusion fixture; these scores are authored, not model outputs."""
import json
import math
A={0:12.,5:11.,3:10.,1:2.,7:1.}
B={4:.95,7:.9,3:.89,2:.2,0:.1}
RELEVANT={0,4,5,7}

def order(scores):
    if any(type(i) is not int or not math.isfinite(s) for i,s in scores.items()):
        raise ValueError('integer IDs and finite scores required')
    return sorted(scores,key=lambda i:(-scores[i],i))

def rrf(rankings,constant=60.):
    if not math.isfinite(constant) or constant<0:raise ValueError('nonnegative constant required')
    scores={}
    for ranking in rankings:
        if any(type(i) is not int for i in ranking) or len(ranking)!=len(set(ranking)):
            raise ValueError('each list must contain unique integer IDs')
        for rank,i in enumerate(ranking,1):scores[i]=scores.get(i,0.)+1/(constant+rank)
    return scores

def blend(a,b,weight=.5,normalize=False):
    order(a);order(b)
    if not math.isfinite(weight) or not 0<=weight<=1:raise ValueError('weight in [0,1] required')
    ids=set(a)|set(b);rows=[]
    for source in [a,b]:
        values={i:source.get(i,0.) for i in ids}
        if normalize and values:
            lo=min(values.values());span=max(values.values())-lo
            values={i:(v-lo)/span if span else 0. for i,v in values.items()}
        rows.append(values)
    return {i:weight*rows[0][i]+(1-weight)*rows[1][i] for i in ids}

def demo():
    a=order(A);b=order(B);fused=order(rrf([a,b]));scaled={i:100*s for i,s in B.items()}
    rows=[]
    for depth in [1,3,5]:
        pool=set(a[:depth])|set(b[:depth]);rank=order(rrf([a[:depth],b[:depth]]))[:4]
        rows.append(dict(depth=depth,pool_size=len(pool),candidate_recall=len(pool&RELEVANT)/4,
                         ids=rank,relevance_recall=len(set(rank)&RELEVANT)/4))
    return dict(a=a,b=b,rrf=fused,rrf_scaled=order(rrf([a,order(scaled)])),
        raw=order(blend(A,B)),raw_scaled=order(blend(A,scaled)),
        normalized=order(blend(A,B,normalize=True)),normalized_scaled=order(blend(A,scaled,normalize=True)),
        precision_at4=[len(set(r[:4])&RELEVANT)/4 for r in [a,b,fused]],depths=rows,
        scope='Authored two-ranker score tables; missing scores filled with zero before optional min-max normalization.')

if __name__=='__main__':print(json.dumps(demo(),sort_keys=True,allow_nan=False))

At c=60 the full retained lists fuse to [0,3,7,4,5,1,2]. Precision at four rises from 0.5 for either list to 0.75 after fusion. Yet shared irrelevant document 3 outranks document 4, which B placed first. Agreement between rankers is evidence about their behavior, not proof of relevance.

Keeping only three items per input produces a five-document union containing every relevant document. Candidate recall is 1, but RRF puts document 3 first and returns [3,0,4,5] in its first four: relevance recall is 0.75. Keeping one item per input restricts candidate recall to 0.5 before any scoring method is applied.

Multiplying B’s scores by 100 preserves RRF but changes the raw blended order. Under this particular zero-fill and min-max convention, normalized fusion is also unchanged by this positive scaling. Its first item is still irrelevant document 3. Neither invariance nor normalization is a quality guarantee.

Pay for candidates and evaluate the cascade

Accumulating RRF over lists of total length T takes O(T) time with a hash map and O(U) score storage for U distinct document IDs; sorting the union takes O(U log U). Retrieving the lists, transferring candidates and running any later reranker add separate costs. Parallel retrieval can reduce some waiting time but consumes resources in both systems; tail latency and partial failures still matter.

Tune the cutoff, weights and constant on development data. Report the lexical baseline, each standalone retriever, candidate-union recall, fused ranking quality and any final reranking at matched budgets. Include exact identifiers and semantic paraphrases, and inspect cases where both systems make the same mistake. A missing or timed-out source requires an explicit fallback policy; do not silently compare one-source and two-source runs as identical configurations.

The RRF paper reports historical TREC and LETOR experiments, including settings where another method scored higher. Those results support studying the method, not a theorem that it improves every ranking. The synthetic gain here is likewise one constructed case. RRF, tables 2–3

Predict the fused result

  1. What does a document ranked first in one list contribute at c=60, and what does absence contribute?

Answer: First place contributes 1/61. Absence contributes zero under this article’s truncated-list extension. The original full-permutation definition does not need that missing-document rule.

  1. Why can document 3 outrank B’s first choice?

Answer: Document 3 receives rank-three contributions from both lists: 2/63. Document 4 appears only in B at rank one, contributing 1/61. Since 2/63 is larger, the shared error wins that comparison.

  1. Must scaling B’s scores by 100 leave a raw blend unchanged?

Answer: No. It changes B’s relative magnitude at fixed α. RRF is unchanged when the retained order stays fixed because it uses ranks, not these magnitudes.

  1. The depth-three union has full relevant coverage but only 0.75 recall at four. What would you change and test?

Answer: The remaining failure is ordering within the pool, not candidate absence. Try a tuned fusion or reranker on development queries, inspect the shared car-repair error, and evaluate a held-out set at the same candidate and latency budget. More candidates alone need not fix the ordering.

Record the fusion policy as part of the model

Read RRF’s rank origin, pilot constant and experimental exceptions alongside DPR’s specific score-combination setup. They illustrate different ways to combine signals, with different candidate pools and scale assumptions. Continue to cross-encoder reranking for a model that jointly reads each query–candidate pair after fusion.

Make a prediction, then check

Multiplying one ranker’s scores by100 preserves its order. What must stay unchanged under RRF?

Choose one answer

Learning objectives

  • Compute RRF with explicit missing-document rules and diagnose shared errors.
  • Run the original example and explain its failure case.

Prerequisites & connections

Explore related knowledge →

References

  1. Reciprocal Rank Fusion outperforms Condorcet and individual Rank Learning Methods
    G. V. Cormack; C. L. A. Clarke; Stefan Büttcher · 2009
  2. Dense Passage Retrieval for Open-Domain Question Answering — arXiv v1
    Vladimir Karpukhin; Barlas Oğuz; Sewon Min; Ledell Wu; Sergey Edunov; Danqi Chen; Wen-tau Yih · 2020

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-20 · Single AI author. Viewed both physical pages: one-based permutations, constant60 chosen in pilot and held fixed, TREC/LETOR comparisons and exceptions. Truncated-list zero contribution is our declared extension. Viewed physical PDF3–4: independent encoders, dot product, loss and negatives. Read PDF5 hybrid-score paragraph; v1 author list differs from final proceedings. 5 paired equations and four explained exercises. Checked one-based RRF, missing/duplicate conventions, scale invariance, normalization, shared errors and candidate depth; authored scores, no learned-model benchmark.

  • Checked one-based RRF, missing/duplicate conventions, scale invariance, normalization, shared errors and candidate depth; authored scores, no learned-model benchmark.
  • Four computed SVG variants per topic;10 numeric/geometry tests and30 responsive cases passed. Ten selected final captures directly viewed. Full article acceptance recorded separately.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.