Building a Modern Search Engine for Parliamentary Records with RAG Capabilities

hansard · Government · 2024 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.4 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Public-sector search and RAG retrieval

Singapore's Pair Search team needed to make decades of Hansard parliamentary records searchable for policy officers, civic users, and downstream RAG systems because the existing keyword-only search produced poor rankings and weak snippets.

Constraints:

Architecture

Pair Search uses Vespa as a scalable serving engine over a standardized Hansard corpus. The pipeline has three phases: document processing for scraping, parsing, and normalizing Hansard records; retrieval using keyword matching with weakAnd/nativeRank/BM25 plus semantic e5 embeddings; and reranking with ColBERTv2 plus a global hybrid score that combines semantic, keyword, and reranker signals. The system also exposes base search and RAG retrieval APIs for other applications.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  hansard-corpus[Hansard corpus] --> document-processing[Document processing]
  document-processing --> vespa-search-engine[Vespa search engine]
  vespa-search-engine --> keyword-retrieval[Keyword retrieval]
  vespa-search-engine --> semantic-retrieval[Semantic retrieval]
  vespa-search-engine --> colbertv2-reranker[ColBERTv2 reranker]
  keyword-retrieval --> global-hybrid-scorer[Global hybrid scorer]
  semantic-retrieval --> global-hybrid-scorer
  colbertv2-reranker --> global-hybrid-scorer
  global-hybrid-scorer --> search-ui-and-api[Search UI and API]
  search-ui-and-api --> pair-chat-assistants[Pair Chat assistants]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Hansard corpus Official parliamentary reports and debates used by policy makers, professionals, and the public. Document processing
Document processing Scrapes, parses, and standardizes historical Hansard records into a uniform searchable format. Hansard corpus, Vespa search engine
Vespa search engine Serving engine for keyword search, semantic search, and reranking. Document processing, Keyword retrieval, Semantic retrieval, ColBERTv2 reranker, Global hybrid scorer
Keyword retrieval Uses weakAnd, nativeRank, and BM25 to retrieve lexical matches efficiently. Vespa search engine, Global hybrid scorer
Semantic retrieval Uses e5 embeddings to capture query intent beyond exact keyword overlap. Vespa search engine, Global hybrid scorer
ColBERTv2 reranker Performs resource-intensive reranking to prioritize the most relevant documents. Vespa search engine, Global hybrid scorer
Global hybrid scorer Merges top results from content nodes using semantic, keyword, and ColBERTv2 scores. Keyword retrieval, Semantic retrieval, ColBERTv2 reranker, Search UI and API
Search UI and API Presents useful result snippets to users and exposes base search/RAG retrieval functionality to other products. Global hybrid scorer, Pair Chat assistants
Pair Chat assistants Downstream assistant feature trialing the search engine as a RAG retrieval stack. Search UI and API

Data flow

Hansard reports are scraped, parsed, and standardized into a uniform search format. At query time, Vespa retrieves candidates with keyword-based weakAnd/nativeRank/BM25 and semantic e5 embeddings. Content-node reranking narrows the set, ColBERTv2 reranks more deeply, and a global phase merges top results from all content nodes using a hybrid score. The same search index can support direct user search, snippets, RAG retrieval, and future LLM-assisted query expansion or index enrichment.

4 supporting quotes
“ The search process in Pair Search is meticulously divided into three phases: 1. Document-Processing:”article, stated
“The keyword-based search utilizes Vespa's weakAnd operator alongside nativeRank and BM25 text matching algorithms to efficiently sift through vast amounts of data.”article, stated
“Pair Search incorporates e5 embeddings, which offer a balance of speed, cost-effectiveness, and enhanced performance compared to alternatives like OpenAI's ada embeddings model.”article, stated
“Phase 3 (global phase): The final phase amalgamates the top results from all content nodes, creating a hybrid score that integrates semantic, keyword-based, and ColbertV2 scores.”article, stated

Why this architecture

Pair Search chose a hybrid retrieval and reranking architecture because keyword-only search over parliamentary records overweights frequent terms, while semantic-only or single-score approaches can bias toward one dimension of quality. A staged pipeline keeps latency acceptable while allowing more expensive reranking only after cheaper narrowing steps.

3 supporting quotes
“Results are poor due to being 100% keyword search based, meaning that the documents that frequently mention a single word in a query are often ranked more highly”article, stated
“To keep results speedy despite our usage of complex re-ranking algorithms, we utilize a three phase approach to iteratively refine the search results.”article, stated
“Utilizing a hybrid score gives us significantly better performance than relying on just one metric, which tend to be overly biased towards one dimension of result quality”article, stated

Models used: e5 embeddings · ColBERTv2 · Vespa weakAnd · nativeRank · BM25

Scale

Alternatives considered (roads not taken)

Legacy 100% keyword search

Rejected because: Frequent single-word matches crowded out documents matching the phrase intent, and results lacked helpful snippets.

“Results are poor due to being 100% keyword search based, meaning that the documents that frequently mention a single word in a query are often ranked more highly”article, stated
“only the titles are presented without any smart text snippets to help a user confirm whether a link is likely to be useful.”article, stated

OpenAI ada embeddings

Rejected because: The team selected e5 embeddings as a better balance of speed, cost, and performance.

“e5 embeddings, which offer a balance of speed, cost-effectiveness, and enhanced performance compared to alternatives like OpenAI's ada embeddings model.”article, stated

Rely on one ranking signal

Rejected because: Single metrics over-bias toward one dimension of relevance, so Pair Search uses a hybrid score.

“Utilizing a hybrid score gives us significantly better performance than relying on just one metric, which tend to be overly biased towards one dimension of result quality”article, stated

Launch with Magic Summary first

Rejected because: The team rolled out without generated summaries to focus first on the core search experience.

“*Note, the above video showcases a "Magic Summary" feature that automatically generates a summary of the best results in a chronological timeline. However, we are rolling Pair Search out without it first to focus on the core search experience.”article, stated

Patterns

hybrid-search (knowledge_retrieval)

Pair Search combines keyword-based retrieval with semantic e5 embeddings for Hansard queries.

“The retrieval mechanism combines keyword-based and semantic search strategies.”article, stated
“This dual approach ensures a robust and nuanced search process that captures both the intent behind user queries as well as the actual textual content.”article, stated

retrieval-ranking (knowledge_retrieval)

Pair Search uses cost-effective narrowing, ColBERTv2 reranking, and a global hybrid score to improve result order.

“Phase 2: a more resource-intensive re-ranking is performed using the ColbertV2 model, ensuring that the most relevant documents are prioritized.”article, stated
“The final phase amalgamates the top results from all content nodes, creating a hybrid score that integrates semantic, keyword-based, and ColbertV2 scores.”article, stated

rag-retrieval (knowledge_retrieval)

The search engine is designed to serve as retrieval infrastructure for RAG systems and Pair Chat Assistants.

“we’ve designed it to work out of the box as the retrieval stack for a Retrieval Augmented Generation system as well”article, stated
“By providing an API to both the base search functionality and the RAG retrieval functionality”article, stated

query-rewriting (knowledge_retrieval)

The team is exploring LLM-based query expansion to append related terms and improve retrieval/ranking.

“enhancing the retrieval / ranking process through query expansion (appending additional related terms and phrases to a query to increase the chance of retrieving a relevant hit)”article, stated

Tradeoffs

Prioritize core search before generated summaries

Chose Core retrieval and ranking experience over Launching Magic Summary first.

Rationale: The team held back summarization to focus on search quality and usefulness first.

“we are rolling Pair Search out without it first to focus on the core search experience.”article, stated

Use e5 embeddings

Chose e5 embeddings over OpenAI ada embeddings.

Rationale: e5 offered a balance of speed, cost-effectiveness, and performance for this search workload.

“e5 embeddings, which offer a balance of speed, cost-effectiveness, and enhanced performance compared to alternatives like OpenAI's ada embeddings model.”article, stated

Use hybrid scoring

Chose Semantic, keyword, and ColBERTv2 hybrid score over A single ranking metric.

Rationale: Hybrid scoring reduced bias toward any one dimension of result quality.

“Utilizing a hybrid score gives us significantly better performance than relying on just one metric”article, stated

Gotchas (what bit them)

Keyword frequency can swamp phrase intent.

Root cause: A purely keyword-based engine ranks documents that mention one frequent term many times above documents that answer the full query.

Resolution: Use hybrid semantic and keyword retrieval plus reranking.

“the actual results are flooded with reports that are only tangentially related to the query, if at all.”article, stated
“This dual approach ensures a robust and nuanced search process that captures both the intent behind user queries as well as the actual textual content.”article, stated

Historical government data has inconsistent formats.

Root cause: Hansard records span decades and evolving publication formats.

Resolution: Scrape, parse, and standardize reports into a uniform search format before indexing.

“Given the evolving data formats over the decades, standardizing this diverse information for search purposes presented significant hurdles.”article, stated
“these were successfully navigated to create a uniform format conducive to efficient search operations.”article, stated

Complex reranking can threaten search latency.

Root cause: State-of-the-art rerankers are more resource-intensive than first-stage retrieval.

Resolution: Use a three-phase approach that narrows cheaply before applying ColBERTv2 and global scoring.

“To keep results speedy despite our usage of complex re-ranking algorithms, we utilize a three phase approach to iteratively refine the search results.”article, stated
“Phase 1: each content node employs cost-effective algorithms to narrow down the initial set of results.”article, stated

Evaluation

Pair Search evaluates quality through user feedback and search-performance metrics such as clicked-result rank and the number of pages users need before finding useful results.

Metrics: average rank of clicked results · number of pages before users find desired results · daily users · daily searches · qualitative policy-officer feedback

“we chart through metrics such as the average rank of results that are clicked, or the number of pages a user has to go through before finding results they want.”article, stated
“We are averaging ~150 daily users and ~200 daily searches in the early days of our soft launch, and initial user feedback has been positive”article, stated

Outcomes

The source reports over 30,000 Hansard reports from 1955 to January 2024, around 150 daily users, around 200 daily searches, and use by policy/legal/public-sector users in a soft launch.

3 supporting quotes
“indexed on the full Hansard Database from 1955 - January 2024, spanning over 30,000 reports.”article, stated
“We are averaging ~150 daily users and ~200 daily searches in the early days of our soft launch”article, stated
“We have also seen interest from multiple agencies as well looking to leverage our core Search Engine on their own data.”article, stated