P.05RAG
Build a search API that combines embeddings with keyword search, reranks results and serves them behind a FastAPI service with clear relevance metrics.
01
Keyword search misses results that use different wording, while pure vector search can miss exact matches such as product codes, error messages and names. Many teams need both, plus a way to tell whether a change actually improved relevance.
In this project you build a search service over a realistic dataset that runs keyword and vector retrieval in parallel, merges the results, reranks the top candidates and exposes it all through a documented API. You measure relevance with a labeled query set rather than intuition.
02
Documents are chunked and indexed for both full-text search and vector similarity in Postgres. The FastAPI service runs both queries, fuses the rankings, optionally reranks the top results and returns scored hits with highlights.
Index
Chunk documents and store full-text search vectors alongside pgvector embeddings and metadata.
Query
Accept a search request with filters and pagination through a typed FastAPI endpoint.
Hybrid retrieval
Run keyword and vector searches in parallel and merge the results with reciprocal rank fusion.
Rerank
Rescore the top candidates with a reranking model and apply a relevance cut-off.
Respond
Return ranked results with scores, highlights and timing information for each stage.
03
Suggested stack. Equivalent tools are fine; document the choice in your decision record.
04
Stage 01
Choose a public dataset and write a set of queries with labeled relevant documents.
Stage 02
Implement each retrieval method separately and measure both against the labeled queries.
Stage 03
Combine both methods with rank fusion, add reranking and compare relevance against the baselines.
Stage 04
Finalize the API contract, add caching and load-test the service to understand latency at each stage.
05
06
Build the foundations, projects, and habits needed to design more dependable AI applications.