Project Breakdown & Specs (4 sections)
Human-in-the-Loop Thematic RAG: Transparent Retrieval for Canonical Texts
The Thematic RAG System is an intelligent, human-in-the-loop retrieval and synthesis platform engineered for high-precision exploration of dense canonical, sacred, and regulatory texts. By decomposing question-answering into an explicit, multi-stage stateful graph, the system eliminates hallucinations and bridges the linguistic divide between modern queries and classical knowledge bases.
Problem Solved
Standard Retrieval-Augmented Generation (RAG) architectures fail when applied to structured, high-stakes literature:
- Arbitrary Document Chunking: Conventional pipelines slice text by fixed character or token counts, slicing across sentences, chapters, and canonical verse boundaries. This destroys contiguous context and produces disconnected fragments.
- The Semantic & Linguistic Gap: Users typically formulate questions in colloquial, modern phrasing, whereas target knowledge bases use classical terminology, specialized jurisprudence, and distinct morphological roots. Direct embedding searches fail to capture conceptual nuance.
- The Black-Box Hallucination Trap: Generic AI chatbots take a prompt, execute a blind vector search, and immediately generate an answer. When context is ambiguous, the LLM hallucinates citations, misattributes quotes, and produces plausible-sounding falsehoods.
Impact & Engineering Benchmarks
Engineered for rigorous evidence verification, low-latency search, and transparent user agency:
- Strict Contextual Grounding: Constrained the generation engine strictly to user-approved, retrieved excerpts with explicit instructions to refuse synthesis when contextual evidence is lacking.
- Sub-Second Vector Search & Context Hydration: Deployed dense embedding search in Pinecone paired with sub-50ms relational database lookups to rehydrate entire contiguous passages surrounding matched coordinates.
- Transparent Step-by-Step Inspection: Exposed intermediate pipeline steps (thematic expansions, extracted keywords, retrieved textual coordinates) directly to the user interface, enabling real-time review and manual refinement prior to generation.
- Production Cloud Scalability: Containerized the FastAPI orchestration service and deployed it via AWS Copilot onto auto-scaling AWS ECS Fargate clusters backed by CloudFormation infrastructure.
Solution
We architected a stepped, stateful LangGraph workflow that separates query comprehension from synthesis:
- Decomposed 4-Step Graph Workflow:
- Thematic Query Expansion: Translates colloquial user prompts into theological and conceptual domain themes while strictly prohibiting premature answers.
- Keyword & Scope Extraction: Analyzes expanded concepts to extract structured entity targets and canonical vocabulary.
- Structural Canonical Retrieval: Executes vector similarity search in Pinecone and rehydrates contiguous surrounding context using structured database coordinates (
chapter_id,verse_start,verse_end). - Constrained Grounded Generation: Feeds verified, user-inspected passages into the LLM with strict grounding prompts that eliminate confabulation.
- Modern Inspectable UX: Built a responsive Next.js frontend with Firebase Authentication, step-by-step progress steppers, inline editable keyword chips, and interactive source document selection cards.
- Cross-Lingual Concordance Roadmap: Architected morphological lookup tables enabling lexical search and root-word derivations across languages directly alongside semantic vector search.
Tech Stack
- AI & Orchestration: Python, LangChain, LangGraph, OpenAI / HuggingFace Embeddings
- Vector & Storage: Pinecone (Persistent Vector Database), SQLite / PostgreSQL (Relational Metadata)
- API & Frontend: FastAPI, Next.js, React, Tailwind CSS, Firebase Authentication
- Infrastructure & DevOps: AWS ECS (Fargate), AWS Copilot, Docker, AWS CloudFormation