How im-girisankar/ai-pdf-processor-local works
Project Type and Purpose
• This is a CLI-based, two-step document-processing tool.
• Purpose: 1) Convert plain-English criteria into structured rules (rules.json). 2) Apply those rules to a PDF using vision and text AI models to extract data and produce a Markdown report.
Main Components
a. User Interfaces & Inputs
• criteria.txt (user-defined extraction criteria)
• PDF file (user’s document to analyze)
b. Processing Scripts
• 1_create_rules.py (“Rule Creator”)
• 2_analyze_document.py (“Document Analyzer”)
c. Local Services & Libraries
• Ollama daemon (hosts the AI models)
• LLM model (e.g., llama3) for rule generation
• Vision model (e.g., llava) for PDF analysis
• Poppler utilities for PDF rendering
d. Data Artifacts
• rules.json (generated structured rules)
• <pdf_name>_analysis_report.md (final Markdown report)
e. Python Environment
• requirements.txt (dependencies: ollama SDK, poppler wrapper, etc.)
High-Level Workflow & Interactions
• Step 1: Rule Generation
1. User writes plain-English criteria in criteria.txt.
2. User runs python 1_create_rules.py.
3. Rule Creator script loads criteria.txt and calls the LLM (via Ollama API).
4. Ollama + llama3 model returns a structured rules.json.
5. rules.json is stored on disk.
• Step 2: Document Analysis
1. User runs python 2_analyze_document.py.
2. Script prompts for PDF file path.
3. Document Analyzer:
• Uses Poppler to convert PDF pages into images/text.
• Loads rules.json to know what data to extract.
• Calls the vision model (llava) via Ollama API to find and extract data from the rendered PDF.
4. Script assembles results and writes <pdf_name>_analysis_report.md.
Additional Architectural Notes
• 100% local processing: Ollama and Poppler are on-premise services.
• Dependency on the Python runtime and requirements.txt.
• Optionally, indicate error handling paths (e.g., missing PDF, model load failure).