← Back to All Projects

DocuMind CAG: Document Intelligence & Knowledge Extractor

A Context-Augmented Generation (CAG) engine that leverages Gemini 2.5 Flash's long-context window for 100% recall Q&A and Pydantic schema extractions.

What I Built

DocuMind CAG is an AI document intelligence dashboard built with Python 3.12, the Google GenAI SDK (gemini-2.5-flash), pypdf, Pydantic v2, and Streamlit. It bypasses vector database chunking by loading full long-form documents directly into active LLM context memory to perform zero-loss Q&A and structured JSON extractions.

Problem

Traditional chunk-based Retrieval-Augmented Generation (RAG) systems fragment documents into small text chunks. When processing holistic questions—such as summarizing overall risk factors or cross-referencing sections across an entire file—vector retrieval often misses critical context, leading to incomplete or inaccurate answers.

Solution

DocuMind CAG solves this by utilizing Context-Augmented Generation (CAG). It ingests full raw text from uploaded PDFs/TXT files, computes active token counts using native Gemini tokenization APIs, and retains the entire document within system context. This enables multi-turn document chat with 100% information recall alongside a Pydantic-validated extraction engine for executive summaries, core insights, and risk flags.

Design Decisions

Tradeoffs

Challenges

During structured extraction setup, newer google-genai SDK builds issued deprecation notices regarding Automatic Function Calling (AFC) triggers inside single generate_content calls. By isolating Pydantic schemas explicitly within GenerateContentConfig and tuning model temperature to 0.2, the schema enforced cleanly without chat-session overhead.

What I’d Improve

Demo

Live Demo on Streamlit Cloud

Source Code

GitHub Repository