Answers that cite their source, or refuse to guess.

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.

BM25 vector fused
Two rankings, one fused list
100%
Hit@5
0.88
MRR@10
100%
OOC refusal rate
29
source documents

• Sample output

What an answer actually looks like.

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.

What's the daily UPI limit for a fully KYC-verified customer?

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].

[1] upi_limit_policy_0002 · rerank score 0.91
[2] upi_limit_policy_0003 · rerank score 0.87
[3] upi_limit_policy_0004 · rerank score 0.83
llama 3.1 8b · 4.1s · not cached

• The problem

A wrong banking answer isn't a bad UX. It's a compliance incident.

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

Six stages, each one a checkpoint it can fail.

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.

Rewrite
Follow-up detection
via Ollama
→
BM25
Keyword search
top 20
→
Vector
bge-small-en-v1.5
top 20
→
Fuse + rerank
RRF (k=60), then
cross-encoder, top 5
→
Guardrail
Refuse if top score
< 0.50
→
Generate
Llama 3.1 8B or
Claude Haiku
Why hybrid, not just vector

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.

Why a score gate, not just a prompt

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

Measured against 50 held-out questions.

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

What the numbers actually say.

Known gap

Faithfulness sits below target in every configuration tested.

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.

Tradeoff

HyDE wasn't worth doubling latency for +0.005 MRR.

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.

What's next

A post-generation check that flags unsupported sentences.

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

The parts that don't show up in the eval table.

Response caching

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_cached

Follow-up rewriting

Pronoun-heavy or short questions get rewritten into a standalone query from recent conversation history before retrieval runs.

app/app.py :: rewrite_question

Dual-model generation

The 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.py

Hallucination verifier

An offline checker pairs each generated claim with the chunk it cites and asks whether that chunk actually supports it.

scripts/guardrails.py --hall

Retrieval ablation harness

A standalone script sweeps chunk size, overlap, top-k, and embedding model against the eval set to justify every retrieval parameter.

scripts/ablation.py

Query logging

Every 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

29 documents, three registers of truth.

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

No retrieval framework, on purpose.

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.