The developer problem
A keyword ranker and an embedding ranker return scores on different scales. Reciprocal rank fusion combines each document’s position in the lists. It gives a developer an inspectable baseline before tuning a score calibration or training a reranker.
Run the project locally
A literal-word search and a paraphrase search return different article IDs. The example prints the first three fused results. Article 21 wins because both rankers put it near the top. Install Blyx 0.2.1, Rust and a host linker, then run these commands.
git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-shrike.git
cd blyx-shrike
blyxc native-run project.blyxUse the API
Supply two ranked vectors of nonnegative integer IDs up to 2^53−1 and an offset from 0 to 1,000,000. The first occurrence in each list contributes 1/(offset + one-based position). Missing IDs contribute zero. Equal scores use ascending ID. Start the cursor at −1. Each next-result call can take quadratic time in the combined shortlist length; use this version with small candidate sets.
| Function | Behavior |
|---|---|
| sh_valid_inputs(left, right, offset) | Validate every ID and the smoothing offset. |
| sh_score(left, right, id, offset) | Get the fused score of one document. Zero means absent and −1 means invalid input. |
| sh_next(left, right, offset, previous) | Get the next ID after a cursor, or −1 for exhaustion or invalid input. Each ID is returned once. |
Verify a change
Run the package checks from its release directory. Compare the browser example with its expected output, then change the input in the exercise below.
blyxc native-run tests.blyxTry the program
Expected output
17 83
Practice
Move article 41 to first place in both lists. Which two articles lead?
Hint
Change only the worked example’s input. The API table describes the output.
Worked solution
41 wins both lists and 83 retains a contribution from each.
Find
let semantic = [17, 83, 99];Replace with
let semantic = [41, 83, 99];Output after the change
41 83
