Building a Modern Search Engine for Parliamentary Records with RAG Capabilities

1 Feb 2024

Problem

Singapore's Open Government Products team found that the search over Hansard, the official record of Parliament debates since 1955, worked poorly. It was pure keyword search, so documents that mention one query word often rank high even when they ignore the rest of the phrase. Results show only titles, with no snippets that tell a reader whether a link is worth opening. Policy officers and the public lose time, and the authors argue that a good search engine is the heart of a good RAG system.

Example from the article: the query "covid 19 rapid testing" returned results flooded with reports that were only tangentially related, because Covid is mentioned in so many debates.

Solution in brief

The team indexed about 30,000 reports in Vespa and combined keyword retrieval (weakAnd, nativeRank, BM25) with semantic retrieval on e5 embeddings. A three-phase ranking narrows candidates cheaply on each node, applies ColBERT v2 to the survivors, and mixes all scores into one hybrid score globally.

Questions this case answers
  • How to improve relevance of a keyword-only search over a long-running document corpus when frequent terms flood the results
  • How to combine lexical, dense and late-interaction scores into one ranking while keeping query latency low
  • How to replace a keyword-only search over a large document archive with hybrid semantic and keyword retrieval?
  • How to add expensive reranking without making search slow?

Tools and methods

  • Vespa — open-source serving engine that holds the index and runs retrieval and multi-phase ranking
  • BM25 with weakAnd and nativeRank — keyword retrieval and scoring
  • e5 embeddings — dense semantic retrieval, chosen over OpenAI's ada embeddings
  • ColBERT v2 — multi-vector late-interaction reranker for the best candidates
  • Hybrid score — weighted sum of normalized semantic, ColBERT and keyword scores
Continue reading — it's free

Google or a one-time email code. No password.