| title | FinSight AI |
|---|---|
| emoji | π |
| colorFrom | blue |
| colorTo | indigo |
| sdk | docker |
| app_port | 7860 |
| pinned | false |
FinSight AI is a production-ready, highly advanced Retrieval-Augmented Generation (RAG) platform tailored for the ingestion, querying, and analysis of complex documents such as financial reports, SEC filings, and corporate presentations.
Unlike standard RAG tutorials or basic wrappers, FinSight AI implements a robust, asynchronous backend architecture and an interactive, GenUI-powered frontend designed to deliver low-latency, highly accurate, and fully auditable conversational intelligence.
Standard RAG systems fail when faced with real-world financial documents. They destroy tabular data during naive text-splitting, retrieve irrelevant chunks using basic vector search, and hallucinate when they don't know the answer.
Here is how we solved these problems and built a vastly superior system:
- The Problem: Naive chunking (e.g., splitting by 1000 characters) splits tables in half and merges unrelated paragraphs, destroying context.
- Our Solution: We integrated Docling for advanced layout extraction. Our pipeline understands the document's structure, preserving complex financial tables as Markdown/HTML and maintaining hierarchical relationships (Headings -> Paragraphs). This allows the LLM to read data exactly as it was formatted.
- The Problem: Basic dense vector search (Cosine Similarity) struggles with exact keyword matching (like ticker symbols or specific financial metrics).
- Our Solution: We built an enterprise-grade retrieval pipeline:
- Hybrid Search: We run Dense Vector Search (semantic meaning) and Sparse BM25 Search (exact keyword matching) in parallel using Qdrant.
- Reciprocal Rank Fusion (RRF): We merge the results mathematically to get the best of both worlds.
- Neural Reranking: We pass the top candidates through a Cross-Encoder Neural Reranker for extreme precision.
- Section Routing & Session Scoping: The system uses conversation history to bias retrieval towards currently active document sections.
- The Problem: LLMs are eager to please and will hallucinate answers if the retrieved context doesn't contain the requested information.
- Our Solution: We implemented Dynamic Refusal Gates. The system mathematically evaluates the confidence scores from the retrieval pipeline. If the context isn't highly relevant, the system intentionally "refuses" to answer, guaranteeing zero hallucinations.
- The Problem: Financial analysis requires more than just text.
- Our Solution: The LLM dynamically streams structured JSON alongside text. The frontend intercepts this JSON and natively renders interactive Recharts (bar charts, line graphs) and Mermaid.js flowcharts directly inside the chat interface.
- The Problem: Users cannot trust AI without verification.
- Our Solution: Our LLM is heavily prompted to ground every claim with a chunk coordinate (e.g.,
[cite:p2:c4]). The frontend transforms these into clickable citation badges. Clicking a badge opens a resizable Document Explorer that scrolls to the exact source page and highlights the specific paragraph or table the LLM used.
- The Problem: Typing complex financial queries is tedious.
- Our Solution: We implemented a hands-free, end-to-end voice interface. It features real-time Speech-to-Text (STT), intelligent silence detection to auto-submit queries, and Text-to-Speech (TTS) for the response. Crucially, we implemented Barge-In, allowing users to interrupt the AI mid-sentence to ask follow-up questions.
To prove our system's superiority, we built an automated LLM-as-a-Judge Evaluation Suite directly into the platform. Users can evaluate any response in real-time.
Our evaluation pipeline uses Llama-3.3 (via Groq) to calculate:
- Faithfulness (Target: >95%): Measures if the generated answer is strictly derived from the retrieved context.
- Answer Relevance (Target: >90%): Measures how well the response directly addresses the user's initial query.
- Context Relevance: Measures the signal-to-noise ratio of our retrieval pipeline (did we retrieve the right chunks?).
Furthermore, our backend evaluation scripts track core Information Retrieval metrics:
- Hit Rate: Ensuring the correct document section appears in the top retrieved results.
- Mean Reciprocal Rank (MRR): Ensuring the most relevant chunk is ranked as close to #1 as possible.
The system is built on a distributed micro-services architecture, optimized for high-throughput document processing and low-latency interactive queries.
graph TD
User([User / Browser])
subgraph "Frontend Layer (Next.js 15)"
NextJS[Next.js App Router]
GenUI[GenUI Router / Mermaid / Recharts]
DocExp[Document Explorer / Citations]
Voice[Voice Integration STT/TTS]
end
subgraph "Security Layer"
Auth[JWT Auth Middleware]
end
subgraph "Backend API Layer (FastAPI)"
ChatAPI[Chat & Voice API]
ProjAPI[Project & File Management]
EvalAPI[RAG Evaluation API]
end
subgraph "Processing & Retrieval (Async)"
Celery[Celery Worker Pool]
Ingestion[Docling Ingestion Pipeline]
HybridSearch[Hybrid Retriever BM25 + Vector]
Reranker[Cross-Encoder Reranker]
RefusalGate[Dynamic Refusal Gates]
end
subgraph "Infrastructure Layer"
Postgres[(PostgreSQL)]
Redis[(Redis)]
Qdrant[(Qdrant Vector DB)]
Storage[Local / S3 Storage]
end
subgraph "External AI Services"
Gemini[Google Gemini API]
Groq[Groq / Llama-3.3 Evaluator]
end
User <--> NextJS
NextJS --> Auth
Auth --> ChatAPI & ProjAPI & EvalAPI
ChatAPI <--> HybridSearch
HybridSearch --> Reranker
Reranker --> RefusalGate
RefusalGate --> ChatAPI
ProjAPI -->|Task| Redis
Redis --> Celery
Celery --> Ingestion
Ingestion -->|Parse| Docling(Docling SDK)
Ingestion -->|Index| Qdrant & Postgres
EvalAPI --> Groq
- Framework: Next.js 15 (App Router), React 19, TypeScript, Tailwind CSS.
- Visual Intelligence:
- GenUI: Dynamic rendering of LLM-generated JSON into interactive UI components (Recharts).
- Mermaid.js: Direct rendering of system architecture and financial flowcharts within chat.
- Document Explorer: Coordinate-mapped PDF viewer for precise citation jumping and source verification.
- Interaction: WebSockets for real-time Voice STT/TTS, SSE (Server-Sent Events) for streaming chat.
- Core: FastAPI, Pydantic v2, SQLAlchemy 2.0 (Asyncpg).
- Retrieval Engine:
- Parsing: Docling SDK for structural layout extraction (preserving complex tables and headers).
- Search: Hybrid (Dense Vector via Qdrant + Sparse Lexical via BM25).
- Fusion: Reciprocal Rank Fusion (RRF) to unify disparate search signals.
- Refinement: Neural Reranking using cross-encoders for final context selection.
- Guardrails: Refusal Gates with Dynamic Thresholding to prevent hallucinations.
- Auth: JWT-based session management,
bcryptpassword hashing, and user-project isolation. - Database: PostgreSQL (Stateful metadata), Qdrant (High-dimensional vectors), Redis (Task broker & Cache).
- Asynchronous Processing: Celery with a robust Windows-optimized configuration (
--pool=solo).
- Structural Parsing: Docling extracts layout primitives, identifying headings, paragraphs, and tables with bounding boxes.
- Logical Chunking:
StructuralChunkerslices documents based on the extracted hierarchy. - Contextual Enrichment: LLMs summarize chunks and extract key metadata to enrich the index.
- Dual Indexing: Chunks are embedded in Qdrant; lexical signatures are indexed in BM25.
- Section Routing: Predicts relevant document sections to narrow the search space.
- Session Scoping: Incorporates conversation history to bias retrieval.
- Hybrid Retrieval: Parallel search across Vector and BM25 indices.
- RRF Merger: Harmonizes results using Reciprocal Rank Fusion.
- Neural Reranking: A cross-encoder re-scores candidates for final precision.
- Refusal Gate: Dynamically evaluates if the top-scored context is sufficient.
FinSight AI employs a Hybrid Execution Model optimized for rapid development:
- Infra-in-Docker: Stateful services (PostgreSQL, Redis, Qdrant) run in containers via
docker-compose.infra.yml. - App-on-Host: The application code (FastAPI, Celery, Next.js) runs natively, ensuring instant hot-reloading and native performance for heavy Docling/Torch operations.
- Celery Solo Pool: On Windows, we utilize
--pool=soloto ensure thread-safe processing of heavy PDF tasks. - Orchestrated Startup:
start-local.ps1handles environment verification, dependency checks, and synchronized boot-up.
- Environment Setup: Ensure your
.envfiles in the root and/backendcontain your required API keys (e.g.,GROQ_API_KEY). - Start Services: Execute the unified PowerShell orchestrator:
(To stop all services and containers later, run
.\start-local.ps1.\start-local.ps1 -StopAll) - Access:
- Frontend UI: http://localhost:3000
- Backend API Docs: http://localhost:8000/docs
- Qdrant Dashboard: http://localhost:6333/dashboard