AI / LLM Python

DocuMind

Multi-agent research that reads your documents and writes cited reports, in seconds.

Multi-AgentRAGLangGraphAWS Bedrock
User QueryHybrid RAGLangGraph AgentsCited ReportDense / ChromaDBSparse / LanceDBLangGraph · CrewAI · ChromaDB · LanceDB
System architecture

01 Background

Enterprise knowledge is trapped in PDFs, internal wikis, and siloed documentation systems. When engineers need answers, they spend hours manually searching across sources, and still miss crucial context. DocuMind replaces that with an enterprise-grade multi-agent research platform deployed on AWS that synthesizes across custom knowledge bases and produces structured, cited reports. The key architectural decisions: hybrid retrieval combining pgvector dense search with BM25 sparse matching, fused via Reciprocal Rank Fusion (RRF k=60) and reranked with a CrossEncoder, achieving higher recall and precision than either approach alone. Document ingestion runs through an asynchronous AWS Step Functions pipeline (S3 → Lambda parse via Textract → Lambda embed via Bedrock Titan Embed v2 → Lambda store into pgvector), keeping the API non-blocking even for complex multi-page PDFs.

02 How It Works

01

Document Ingestion Pipeline

Users upload documents (PDF, DOCX) or provide URLs. An AWS Step Functions 3-stage pipeline handles ingestion asynchronously: Lambda parses content (pymupdf for PDFs, Amazon Textract for complex docs), Lambda embeds chunks using Bedrock Titan Embed v2 (1024-dim vectors), and Lambda stores into RDS pgvector with SHA-256 idempotent deduplication. Typical ingest is 400–800ms.

02

Hybrid RAG Retrieval

On each query, pgvector retrieves semantically similar chunks via dense embedding search while BM25 retrieves keyword-matched chunks. Scores are fused using Reciprocal Rank Fusion (RRF k=60), then a CrossEncoder (ms-marco-MiniLM-L-6-v2) reranks the top candidates, with ~15ms p50 retrieval latency.

03

4-Agent Research Pipeline

LangGraph routes the query through a typed state machine of four CrewAI agents powered by Bedrock Claude Haiku: Researcher (gathers and synthesizes context from retrieved chunks), Analyst (identifies gaps and validates claims), Writer (drafts the structured report), and Critic (challenges accuracy). The critic→revise loop runs up to 2 iterations before finalizing.

04

Citation-Grounded Output

Every claim in the final report is traced back to a source chunk with page-level provenance. The Critic agent catches hallucinations before reaching the user. A human-in-the-loop approval mechanism allows engineer review before the report is delivered.

05

AWS Infrastructure & MCP Integration

3-tier deployment: CloudFront CDN → EC2 t3.micro (FastAPI + Streamlit + nginx) → RDS PostgreSQL 15 with pgvector. Supporting services: S3 (document storage), SQS ingestion queue with DLQ, DynamoDB (job tracking), Lambda, Step Functions, CloudWatch. Claude Desktop MCP integration exposes DocuMind as a callable tool in extended AI conversations.

03 Results & Impact

PDF ingestion: ~176ms for 15-page papers; full pipeline 400–800ms; 3.5s for complex arxiv PDFs

RAG retrieval at ~15ms p50 using pgvector dense + BM25 sparse fused via RRF with CrossEncoder reranking

Hybrid retrieval achieves higher recall than dense-only or sparse-only approaches on internal benchmarks

RAGAS evaluation integrated: faithfulness, answer relevancy, context precision & recall (target ≥0.60)

Claude Desktop MCP integration enables DocuMind as a reusable research tool in AI workflows