Installation
DocMind requires Python 3.13 or higher and uses LangGraph for workflow orchestration.Install Dependencies
Install DocMind using your preferred package manager:
DocMind is lightweight by design. The core system has only two dependencies: LangGraph for workflow orchestration and pytest for testing.
Your First Query
Let’s process a legal document query with DocMind. This example shows how to ask about late payment penalties:DocMind runs asynchronously for optimal performance. Always use
asyncio.run() or await when calling run_docmind().Understanding the Output
When you run the query above, DocMind processes it through multiple stages:Query Decomposition
The system extracts:
- Intent:
penalty(detected from “penalties” keyword) - Entities:
["penalties", "late", "payment"] - Constraints:
{}(no specific percentages or timeframes in query) - Temporals:
[](no dates mentioned)
Strategic Retrieval
Based on the intent, DocMind retrieves:
- Primary match: “Late Payment Penalties” (page 8) - highest relevance score
- Secondary match: “Payment Terms” (page 3) - provides context
More Example Queries
Try these queries to see DocMind’s different retrieval strategies:Indemnification Query
IP Infringement Query
Payment Terms Query
Inspecting the Workflow State
For debugging or observability, you can inspect the full state after execution:node_history shows the execution path:
If validation fails, you’ll see retry nodes in the history:
['decompose', 'retrieve', 'generate', 'judge', 'retrieve', 'generate', 'judge', 'output']Understanding Validation Failures
DocMind automatically retries when the LLM-as-judge detects hallucinations:- The system increments
retry_count - Returns to the
retrievenode with updated strategy - Generates a new response
- Re-validates with the judge
- Maximum 2 retry attempts before returning fallback message
Custom Document Stores
The quickstart uses mock data, but you can connect your own document store:section_id: Unique identifiertitle: Section headingpage_num: Page number in source documentcontent: Full section text
Next Steps
Core Concepts
Learn how query decomposition, agentic retrieval, and LLM validation work under the hood
API Reference
Explore the complete API for all components and configuration options
Testing Guide
Learn how to test retrieval accuracy and validation effectiveness
Customization
Customize DocMind for your specific document types and use cases
Common Issues
Query returns 'Unable to provide a confident response'
Query returns 'Unable to provide a confident response'
This means validation failed after 2 retry attempts. Common causes:
- Information doesn’t exist in the documents
- Query is too vague (try adding more specific terms)
- Query uses different terminology than the documents
Retrieval returns irrelevant sections
Retrieval returns irrelevant sections
Check your relevance threshold in
AgenticRetriever._filter_irrelevant(). The default is 2.0, which requires either:- Strong intent match (5-7 points)
- Multiple entity matches
- Entity match in title (1.5 points) + content match (1.0 points)
Judge incorrectly flags valid responses
Judge incorrectly flags valid responses
The judge may be too strict if:
- Your response makes valid inferences not explicitly stated
- Paraphrasing differs significantly from source text
confidence_score threshold (default 0.5) and adjust claim extraction patterns in LLMJudge._extract_claims().Testing Your Setup
Run the test suite to validate your installation:- Strategic Retrieval: Validates section selection accuracy
- LLM-as-Judge: Tests hallucination detection
- End-to-End: Full workflow execution