Class ReciprocalRankFusion
- Namespace
- MailFathom.Application.Emails.Search
- Assembly
- MailFathom.Application.dll
Combines two rankings of the same emails into one, reading only where each ranking placed them.
public static class ReciprocalRankFusion
- Inheritance
-
ReciprocalRankFusion
- Inherited Members
Remarks
Reciprocal Rank Fusion is the method, and the reason it is the method is that the two inputs are not on one scale and never will be. A full-text rank is a function of term frequency and document length; a vector distance is a function of a model's geometry. Adding, averaging, or min-max normalizing them would ask which number is worth more, and every answer to that would be a constant that a change of embedding model silently invalidates. Fusion by rank asks nothing of the numbers at all — only of the order they put the documents in — so changing the model changes which documents are found and never how the two findings are weighed.
The formula is the published one: a document scores 1 / (k + rank) in each ranking that returned it, counting
ranks from one, and its fused score is the sum over both. A document only one ranking found therefore still scores,
which is what lets a semantic match with no shared word rank at all — and a document both found outranks either of
them, which is what keeps an exact phrase from being displaced by a merely related message.
The result is deterministic for a given pair of inputs. Equal fused scores are not rare here and are not a tie-breaking detail: two documents at symmetric places — first lexically and fifth semantically against fifth and first — score identically by construction. The timeline order settles those, which is the same order that settles a tie in the lexical ranking alone, so a search returns one sequence rather than whichever the sums happened to produce.
Fields
- RankConstant
The constant that flattens the difference between the very top places.
Methods
- Fuse(IReadOnlyList<RankedEmailCandidate>, IReadOnlyList<RankedEmailCandidate>, int)
Fuses a lexical ranking and a semantic ranking into one bounded ordering.
- Score<TDocument>(IReadOnlyList<TDocument>, IReadOnlyList<TDocument>)
Scores every document either ranking placed by the places it holds in them, and orders nothing.