Applied AI · Hybrid RAG
Hybrid RAG Knowledge System
A source-grounded assistant that pairs semantic retrieval with an explicit knowledge graph, and declines to answer when the evidence is not there.
- 54official schemes
- 2retrieval layers
- 3guardrail layers
- 30/30evaluations passed
01The problem
Why vector search alone was not enough.
FAISS gave the system semantic search: a farmer’s question could still find the right scheme even when the wording differed from the source. But the scheme data also holds relationships that are naturally structured. Schemes belong to departments, target beneficiaries, have benefit types, are sponsored by organisations, support crops and sit in categories.
Those are relationships, not just similar pieces of text. A question such as training schemes for maize farmers needs both meaning and structure. And because the answers are about government benefits, the system also had to know when not to answer.
02What I built
Similarity and structure, working together.
- 0154 official schemesSource-grounded answers built over official Tamil Nadu farmer scheme information.
- 02Two retrieval layersFAISS semantic search with OpenAI embeddings (text-embedding-3-small), joined by a Neo4j knowledge graph.
- 03Three guardrail layersInput, retrieval and evidence-support checks decide whether an answer is allowed.
- 04Grounded answersGPT-4.1 answers from the supported evidence, in a Streamlit interface.
03How it works
Two retrieval paths. One controlled answer.
Weak or unsupported requests are stopped before they become confident-looking answers.
- QuestionScheme, crop, beneficiary or category
- Input guardrailOut-of-domain input stopped
- FAISS + Neo4jSimilarity and structure
- Retrieval guardrailIs the context relevant?
- Evidence checkCan it support an answer?
- Grounded answerOr: information unavailable
04Decisions that mattered
What I chose, and why.
The reasoning behind the build, not just the parts list.
- 01Add a knowledge graph beside vector searchSemantic similarity answers “what looks relevant?”. A graph answers “what is explicitly connected?”. In the evaluation, a maize and training question returned 5 FAISS results and 2 Neo4j results, and the graph-confirmed schemes were the ones kept.
- 02Three guardrails, each at a different pointThe input guardrail stops out-of-domain, empty, prompt-injection and unsafe requests before retrieval. The retrieval guardrail checks whether what came back actually supports the question. The evidence-support guardrail covers the cases where semantic retrieval alone is not enough.
- 03Refuse instead of filling the gapWhen the data cannot support an answer, the system says the information is not available in the retrieved official data. For example, an apple-farmer question is blocked for insufficient coverage, and a missing deadline is never invented.
- 04Filter before generatingResults from both retrieval methods are combined and filtered, and only that supported context goes to GPT-4.1. The answer comes from evidence, not from the model’s general knowledge.
- 05Test the behaviour, not just the happy pathFive evaluation suites, each with its own script, cover the guardrails, hybrid retrieval and final answers. They include deliberate negatives: an unsupported crop, an unsupported tractor question, a missing scheme field and an out-of-domain cricket question.
- 06Say how complete the data isField coverage was measured rather than assumed: every scheme has a title, sponsor, beneficiaries and benefit type, while funding pattern and how-to-avail are present for 52 of 54.
05Engineering evidence
30 evaluations. 30 passed.
Formal evaluation
- Input guardrails10 / 10
- Retrieval guardrails8 / 8
- Evidence support4 / 4
- Hybrid retrieval4 / 4
- Final answers4 / 4
Graph relationships
- Scheme → BELONGS_TO → Department
- Scheme → TARGETS → Beneficiary
- Scheme → HAS_BENEFIT_TYPE → BenefitType
- Scheme → SPONSORED_BY → Sponsor
- Scheme → SUPPORTS_CROP → Crop
- Scheme → HAS_CATEGORY → Category
Behaviour
- Unsupported or out-of-domain questions are blocked, or answered as information unavailable, rather than fabricated.
- Deployed with Docker on a VPS.
06Under the hood
Stack, lessons and limits.
Stack by layer
- Interface
- Streamlit chatbot
- Orchestration
- LangChain, Python
- Semantic retrieval
- FAISS with OpenAI text-embedding-3-small
- Graph retrieval
- Neo4j AuraDB
- Generation
- GPT-4.1, grounded in retrieved context
- Quality
- Input, retrieval and evidence guardrails; five evaluation suites
- Deployment
- Docker on a VPS
What I learned
- Hybrid RAG was not simply FAISS plus Neo4j. Similarity and structure solve different parts of the retrieval problem.
- A good answer begins with deciding whether the available evidence is good enough to answer at all.
- Evaluation became part of the build itself, rather than something added after the interface looked finished.
Honest limits
- The dataset covers 54 schemes.
- Answers are intentionally limited to the retrieved official data.
- It needs OpenAI and Neo4j AuraDB access to run.
Code, graph model, guardrails and evaluation suite are in the repository.