ProjectBuild an AI-Powered Digital Bank with RAG: the explanation · Module 9: Hybrid retrieval: finding the right passage · part 11 of 20
Part 11 · Module 9: Hybrid retrieval: finding the right passage

Module 9: Hybrid retrieval: finding the right passage

21 min read·
About 40 minutes · Needs: Module 8 (how documents become chunks), Module 2 (where retrieval fits) · Code: backend/app/rag/retriever.py, backend/app/rag/embeddings.py, backend/app/models/documents.py

Where this fits

WHERE THIS FITS The Kestrel Bank system this module CLIENT API LAYER FastAPI SAFETY AGENT LangGraph MODELS RETRIEVAL DATA AND INGESTION Postgres, Redis QUALITY Langfuse Customer app React Admin app React FastAPI REST + streaming Auth + RBAC tokens, roles Document upload admin only, checked Guardrails injection, PII Router small or large Agent LangGraph Banking tools ledger, transfers LLMs Groq, Gemini Retrieval hybrid + rerank Ingestion parse, chunk, embed PostgreSQL + pgvector ledger, chunks, state Redis limits, queue Observability Langfuse, metrics, logs Evaluation golden set, release gate
Retrieval (blue: this module) sits between the agent and Postgres: the agent asks, retrieval finds passages in the chunks table.

When the agent needs a bank rule, it calls search_bank_policies, which calls the retriever in this module. The retriever searches the 89 chunks in Postgres and returns the few passages the model may answer from. A wrong passage here means a wrong rule with a citation that looks correct.

The rest of this project is yours to keep

This project is bought on its own, once, and stays readable afterwards, including the parts added to it later.

Or open everything with a plan