FinSight is a retrieval-augmented generation system for neobanking compliance questions: UPI limits, KYC rules, dispute SLAs, RBI directions. No LangChain, no LlamaIndex. The retrieval, reranking, and guardrail logic are written and measured by hand, against a 50-question eval set built for this corpus.
• Sample output
There's no hosted live demo, the stack needs a local Ollama instance and a persistent vector store, neither of which run on serverless. What's below is real: the question, the cited chunk IDs, and the rerank scores all came from an actual run against the corpus in this repo.
For a Tier 2 (fully KYC-verified) customer, the standard daily UPI limit is ₹1,00,000, with no monthly cap subject to account balance [1]. This is enhanced to ₹2,00,000 per transaction for healthcare, education, and insurance-premium payments, provided the merchant carries the correct category code [2]. Accounts opened in the last 24 hours are held to a ₹10,000/day cooling-period cap regardless of KYC tier [3].
• The problem
A support assistant that confidently states the wrong UPI limit, or invents a KYC exception that doesn't exist, isn't just unhelpful, it's a liability for a regulated business. FinSight is built around one constraint: never state a policy fact without the exact chunk that supports it, and when nothing in the corpus supports an answer, say so instead of guessing.
That constraint shapes everything downstream: what gets retrieved, how it gets reranked, and the score threshold that decides whether a model gets called at all.
• Architecture
A question is rewritten if it looks like a follow-up, retrieved two different ways, fused, reranked, and gated against the corpus, and only then handed to a model. Any of the first few steps can end the request before a model is ever called.
Dense retrieval misses exact terms it hasn't learned to associate, like a specific NPCI circular number. BM25 catches those verbatim; Reciprocal Rank Fusion means a strong match in either method survives even if the other misses it entirely.
Telling a model to refuse out-of-corpus questions in its system prompt isn't reliable on its own. A hard threshold on the top retrieved chunk's score refuses before generation runs at all, which is most of why the refusal rate holds at 100%.
• Evaluation
Thirty in-corpus, ten out-of-corpus, ten adversarial, run against both models with and without HyDE query expansion.
| Metric | Target | Llama | Llama + HyDE | Claude | Claude + HyDE |
|---|---|---|---|---|---|
| Hit@5 | ≥ 80% | 100.0% | 100.0% | 100.0% | 100.0% |
| MRR@10 | ≥ 0.65 | 0.878 | 0.883 | 0.878 | 0.883 |
| OOC refusal rate | ≥ 95% | 100.0% | 100.0% | 100.0% | 100.0% |
| Citation accuracy | ≥ 90% | 92.0% | 90.0% | 90.0% | 88.7% |
| Faithfulness (RAGAS) | ≥ 0.85 | 0.615 | 0.633 | 0.673 | 0.677 |
| Answer relevance (RAGAS) | ≥ 0.80 | 0.835 | 0.809 | 0.867 | 0.888 |
| p95 latency | < 3s | 17.5s | 25.3s | 4.3s | 9.4s |
| Cost per query | logged | $0.00 | $0.00 | $0.00305 | ~$0.00305 |
• Engineering notes
Both models occasionally add background context that isn't directly in the retrieved chunks: correct in substance, but not strictly grounded. The hallucination verifier catches some of this after the fact, but it runs offline; it doesn't block a live answer.
Query expansion via a hypothetical document embedding moved MRR@10 from 0.878 to 0.883, a marginal gain, while roughly doubling end-to-end latency on both models. Not worth it at this corpus size; it stays in the repo as an eval flag, not the default path.
The fix for the faithfulness gap isn't better retrieval, retrieval is already at 100% Hit@5, it's a cheap verification pass after generation that strips or flags claims the hallucination verifier can't trace back to a chunk, before the answer reaches a user.
• Also in the request path
Identical question and model pairs within a one-hour window return instantly from SQLite instead of re-running retrieval and generation.
app/app.py :: get_cachedPronoun-heavy or short questions get rewritten into a standalone query from recent conversation history before retrieval runs.
app/app.py :: rewrite_questionThe same retrieved context goes to a local Llama 3.1 8B via Ollama or Claude Haiku via AWS Bedrock, so cost and latency are directly comparable.
scripts/generate.pyAn offline checker pairs each generated claim with the chunk it cites and asks whether that chunk actually supports it.
scripts/guardrails.py --hallA standalone script sweeps chunk size, overlap, top-k, and embedding model against the eval set to justify every retrieval parameter.
scripts/ablation.pyEvery request, cached or not, is logged to SQLite and a JSONL trace file with its retrieved chunks and scores for later review.
app/app.py :: log_query• Corpus
Real regulation, synthetic policy, synthetic product notes, deliberately mixed so retrieval has to tell an RBI clause apart from an internal interpretation of it.
• Stack
Python 3.11, Flask, ChromaDB, rank_bm25, bge-small-en-v1.5 for embeddings, ms-marco-MiniLM-L-6-v2 for reranking, Ollama running Llama 3.1 8B locally, AWS Bedrock for Claude Haiku, RAGAS for the eval harness, SQLite for logs and caching, and a React UI loaded from a CDN with no build step. Chunking, embedding, fusion, reranking, and caching are each a few hundred lines, small enough to read end to end.