Beyond Hamming: Query-Aware Decoding of Binary Cosine Sketches
Abstract
Lay Summary
Many search and recommendation systems first make a quick guess about which items are worth checking, then spend more time scoring only those candidates. To keep this first step fast, systems often store each database item as a tiny yes/no fingerprint rather than the full vector. This is efficient, but the usual way of comparing fingerprints is least reliable for items that are neither clearly similar nor clearly different from the query. Our work asks whether we can use a fact available at search time: the query itself is still kept in full detail. We propose QA-Cos, a decoding method that keeps stored fingerprints unchanged but reads their bits more carefully using the query. Instead of treating every bit as an equally reliable vote, QA-Cos gives more weight to bits that are more informative for the current query. On standard retrieval benchmarks, this improves candidate selection: difficult queries recover more relevant items under the same budget, and the same recall can often be reached with fewer candidates. This can make retrieval faster or cheaper without retraining the model or rebuilding the database index. Overall, the work shows that reading compact representations better can matter as much as storing them differently.