Case study · Academic · 2025

Hybrid RAG Q&A

A question-answering system over a 500+ page corpus that fuses dense and keyword retrieval, evaluated across three open LLMs.

~25%better retrieval relevance after tuning

Role
Solo, academic project
Status
Live.
Stack
Python, FAISS, BM25, LLMs

The problem

Retrieval-augmented question answering depends on finding the right passages before the language model writes anything. Dense vector search finds passages that mean the same thing as the question, but it can miss exact terms such as names, codes and numbers. Keyword search has the opposite weakness.

What I built

A question-answering pipeline over a corpus of more than 500 pages, with chunking, embedding, retrieval, reranking and answer generation as separate stages.

Retrieval is hybrid. FAISS handles dense vector search and BM25 handles keyword search. Their two ranked lists are merged with reciprocal rank fusion, so a passage that either method ranks highly survives.

Measuring it

I built an evaluation framework that scores retrieval accuracy, faithfulness (does the answer stick to the retrieved text) and answer relevancy, and ran it across three open language models: Llama 3.2, Qwen 2.5 and Phi-2.

With that in place I tuned chunk size, the number of passages retrieved and the fusion weights. Retrieval relevance improved by about 25% over the starting configuration.

Three panels: retrieval relevance about 25% higher after tuning; a worked example of reciprocal rank fusion merging a dense and a keyword ranking; and the evaluation set-up of three models, three questions and six scores
The result, the fusion method and the evaluation set-up. The fusion panel is a worked example, not measured data.

Try the system

DWG S-04 · Retrieval pipeline

L1
Input
L2
Retrieve
L3
Fuse
L4
Answer
Both retrievers run and fusion keeps passages that either one ranks highly. Tuning raised retrieval relevance by about 25%.

Interactive · switch scenarios, hover a part, or break one

Live link coming soonAsk me about this project
Next case studyFameWheels →