Searchers keep telling us the patent they know exists is not in the top results, even though it comes back fine when they search with either method on its own.
search.py finds patents two ways and merges them:
- keyword scoring (BM25 style), which returns scores from 0 to about 20
- meaning-based scoring (embeddings), which returns scores from 0 to 1
solve(payload) takes {"query": str, "k": int} and returns {"ids": [...]}, the top k patent ids, best match first.
Your task
- Run the tests and look at what comes back for the failing queries. Three of the six fail today.
- Work out why the meaning-based half of the search has almost no effect on the final order.
- Fix the merge so both methods count. Keep the same function signature and the same return shape.
- Say in your explanation what you changed, what weight you gave each method and why, and what you would check next if this were running over 179 million patents instead of ten.
The expected rankings come from a merge that puts the two scores on the same scale before combining them. If you take a different approach and think one of the cases is wrong, say so in your explanation rather than forcing the test to pass.