PageDoc-RAG: CPU-First Multimodal Document Ingestion & Retrieval Engine
PageDoc-RAG is a production-grade, CPU-first multimodal document engine that bridges the gap between raw documents (PDFs, scans, images) and modern RAG pipelines. It performs native layout extraction, semantic multimodal chunking (preserving tables, charts, and text reading order), multi-vector indexing, and fine-grained MaxSim late-interaction retrieval with authoritative page evidence.
🌟 Why PageDoc-RAG?
- End-to-End Document Lifecycle: Not just a retriever. It handles the entire pipeline: high-resolution PDF rendering, native layout & table extraction, OCR fallback, semantic multimodal chunking, multi-vector generation, and database indexing.
- CPU-First Architecture: High-speed, cost-effective inference on standard CPU hardware without requiring heavy multi-gigabyte GPU models for standard enterprise document corpora.
- Atomic Multimodal Chunking:
- Tables: Extracted as structured atomic units with header context preserved across rows.
- Charts: Decomposed into 3 vector streams: Chart Title, Data Series pairs, and Synthesized Semantic Relational Insights (e.g., "Q4 has highest revenue").
- Text: Extracted with bounding boxes $[x_0, y_0, x_1, y_1]$ and reading-order continuity.
- Seals & Stamps: Detected and isolated for compliance and verification workflows.
- ColPali/ColBERT-Style Late Interaction (MaxSim): Generates fine-grained multi-vector representations per page and scores queries using token-level late interaction: $$\text{Score}(Q, P) = \sum_{i=1}^{M} \max_{j=1}^{N} \text{sim}(q_i, p_j)$$
- Source-of-Truth Principle: Returns original PDF page references, visual crops, and bounding boxes alongside similarity scores.
- Two-Stage Scalable Retrieval: ANN candidate filtering before MaxSim reranking to scale effortlessly to tens of thousands of documents.
📦 Installation
# Core installation (Zero heavy dependencies, pure CPU)
pip install pagedoc-rag
# Optional extras:
pip install "pagedoc-rag[vector]" # Adds FAISS-CPU vector index backend
pip install "pagedoc-rag[all]" # Full suite (PyMuPDF, FAISS-CPU, Pillow, FastAPI)
🚀 Quickstart (Python API)
from pagedoc_rag import PageDocRAG
# 1. Initialize engine
rag = PageDocRAG(
embedding_model="small-cpu",
index_backend="memory", # or "faiss"
enable_charts=True,
enable_tables=True,
enable_seals=True
)
# 2. Ingest document (PDF, PNG, JPG)
doc = rag.ingest("annual_report.pdf")
print(f"Ingested {doc.num_pages} pages ({doc.document_id})")
# 3. Perform natural language search
results = rag.search("What was the Net Operating Profit in FY2025?", top_k=5)
for res in results:
print(f"Rank Page #{res.page_number} | Score: {res.score:.4f}")
print(f"Snippet: {res.text[:140]}...")
print(f"Source PDF: {res.source_pdf}")
print(f"Evidence items found: {len(res.evidence)}")
💻 CLI Usage
# Index a directory of documents
pagedoc index ./documents --backend memory
# Search across indexed pages
pagedoc search "What was revenue in 2025?" --top-k 5
# Inspect structured elements & bounding boxes on a page
pagedoc inspect ./documents/report.pdf --page 2
🏛️ Architecture & Processing Pipeline
PDF / Scanned Document
│
▼
PyMuPDF High-Res Rendering
│
┌──────────────────────┴──────────────────────┐
▼ ▼
Native Digital Stream Scanned Document Stream
• Text Blocks & Coordinates • PaddleOCR DBNet / SVTR
• Native Table Matrices (find_tables) • PP-Structure Layout Router
• Vector Drawings & Images • Chart2Table & Seal Detector
│ │
└──────────────────────┬──────────────────────┘
▼
Semantic Multimodal Chunking
├── Text Paragraphs with Bounding Boxes
├── Structured Table Matrices (CSV / Headers)
└── Decomposed Chart Relations & Trends
│
▼
Multi-Vector Embedding Model
[p1, p2, p3, ... pN per page]
│
▼
Two-Stage Candidate Search & Filtering
│
▼
Vectorized MaxSim Late Interaction
│
▼
Authoritative Page Retrieval & RAG Context
📊 Evaluation & Benchmarking
PageDoc-RAG includes a built-in evaluation suite for standard information retrieval metrics:
- Recall@1, Recall@5, Recall@10
- Mean Reciprocal Rank (MRR)
- nDCG@5, nDCG@10
- Latency Percentiles (p50, p95) & QPS
from pagedoc_rag.eval.benchmark import Evaluator, BenchmarkQuery
queries = [
BenchmarkQuery(query="Revenue breakdown", target_page_ids=["doc_p2"], query_type="table"),
BenchmarkQuery(query="Executive summary", target_page_ids=["doc_p1"], query_type="text"),
]
report = Evaluator.evaluate(rag, queries)
print(f"Recall@1: {report.recall_at_1:.2%}, MRR: {report.mrr:.4f}")
📄 License
Licensed under the Apache License, Version 2.0.
Metadata
Release files for pagedoc-rag 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pagedoc_rag-0.1.0.tar.gz | 31.5 kB | Without provenance | Details for pagedoc_rag-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pagedoc_rag-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pagedoc_rag-0.1.0-py3-none-any.whl |
Total release size: 72.2 kB
Release files / pagedoc_rag-0.1.0.tar.gz
| Download URL | pagedoc_rag-0.1.0.tar.gz |
|---|---|
| Size | 31.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ee12b603b98b5bae063bf3b447589db9c89a020e0c59b73d80f94f873d5abc4
|
|
BLAKE2b-256 checksum How to use checksums |
73bcec377abe3d8aefcb4d4f0efdb3e3a23b88fdf58a6cb78e0abe3a2e910a6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / pagedoc_rag-0.1.0-py3-none-any.whl
| Download URL | pagedoc_rag-0.1.0-py3-none-any.whl |
|---|---|
| Size | 40.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11715689383f059ef9b57b71c17b696633b2a9e0476bf0815050641fbd373f2b
|
|
BLAKE2b-256 checksum How to use checksums |
20e2cae3d46a6795d0eec16399aafd5c2a2bd47dc58288b86f65dca1202f04aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for pagedoc-rag 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.