pagedoc-rag 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pagedoc-rag-0.1.0/LICENSE +17 -0
- pagedoc-rag-0.1.0/PKG-INFO +182 -0
- pagedoc-rag-0.1.0/README.md +147 -0
- pagedoc-rag-0.1.0/pyproject.toml +58 -0
- pagedoc-rag-0.1.0/setup.cfg +4 -0
- pagedoc-rag-0.1.0/setup.py +57 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/__init__.py +40 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/api.py +234 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/cli.py +97 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/config.py +45 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/document/__init__.py +1 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/document/elements.py +175 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/document/loader.py +47 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/document/normalizer.py +83 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/document/renderer.py +146 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/eval/__init__.py +0 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/eval/benchmark.py +136 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/index/__init__.py +1 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/index/base.py +49 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/index/faiss.py +134 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/index/memory.py +108 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/index/milvus.py +6 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/index/qdrant.py +6 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/models/__init__.py +1 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/models/chart.py +30 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/models/embeddings.py +91 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/models/layout.py +71 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/models/ocr.py +83 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/models/seal.py +26 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/models/signature.py +26 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/models/table.py +70 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/pipeline.py +207 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/retrieval/__init__.py +1 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/retrieval/candidate.py +17 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/retrieval/hybrid.py +34 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/retrieval/maxsim.py +39 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/retrieval/query.py +32 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/retrieval/reranker.py +19 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/storage/__init__.py +1 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/storage/cache.py +33 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/storage/metadata.py +56 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/storage/source.py +39 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/utils/__init__.py +1 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/utils/batching.py +11 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/utils/hashing.py +18 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag/utils/logging.py +32 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag.egg-info/PKG-INFO +182 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag.egg-info/SOURCES.txt +50 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag.egg-info/dependency_links.txt +1 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag.egg-info/entry_points.txt +4 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag.egg-info/requires.txt +23 -0
- pagedoc-rag-0.1.0/src/pagedoc_rag.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2026 PaddleColPali Contributors
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pagedoc-rag
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CPU-First Multimodal Document Chunking, Ingestion & Retrieval Engine using Native PDF Extraction, OCR, Multi-Vector Embeddings, and MaxSim Late Interaction
|
|
5
|
+
Home-page: https://github.com/anoopchandra/pagedoc-rag
|
|
6
|
+
Author: PageDoc Contributors
|
|
7
|
+
Author-email: maintainers@pagedoc.dev
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Project-URL: Documentation, https://github.com/anoopchandra/pagedoc-rag#readme
|
|
10
|
+
Project-URL: Source, https://github.com/anoopchandra/pagedoc-rag
|
|
11
|
+
Project-URL: Tracker, https://github.com/anoopchandra/pagedoc-rag/issues
|
|
12
|
+
Keywords: rag,document-chunking,pdf-ingestion,multimodal-rag,table-extraction,chart-parsing,maxsim,cpu-first,information-retrieval
|
|
13
|
+
Platform: UNKNOWN
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
Provides-Extra: charts
|
|
28
|
+
Provides-Extra: tables
|
|
29
|
+
Provides-Extra: vector
|
|
30
|
+
Provides-Extra: api
|
|
31
|
+
Provides-Extra: all
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
|
|
34
|
+
# PageDoc-RAG: CPU-First Multimodal Document Ingestion & Retrieval Engine
|
|
35
|
+
|
|
36
|
+
[](https://pypi.org/project/pagedoc-rag/)
|
|
37
|
+
[](LICENSE)
|
|
38
|
+
[](https://www.python.org/downloads/)
|
|
39
|
+
|
|
40
|
+
**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.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 🌟 Why PageDoc-RAG?
|
|
45
|
+
|
|
46
|
+
1. **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.
|
|
47
|
+
2. **CPU-First Architecture**: High-speed, cost-effective inference on standard CPU hardware without requiring heavy multi-gigabyte GPU models for standard enterprise document corpora.
|
|
48
|
+
3. **Atomic Multimodal Chunking**:
|
|
49
|
+
- **Tables**: Extracted as structured atomic units with header context preserved across rows.
|
|
50
|
+
- **Charts**: Decomposed into 3 vector streams: Chart Title, Data Series pairs, and Synthesized Semantic Relational Insights (e.g., *"Q4 has highest revenue"*).
|
|
51
|
+
- **Text**: Extracted with bounding boxes $[x_0, y_0, x_1, y_1]$ and reading-order continuity.
|
|
52
|
+
- **Seals & Stamps**: Detected and isolated for compliance and verification workflows.
|
|
53
|
+
4. **ColPali/ColBERT-Style Late Interaction (MaxSim)**: Generates fine-grained multi-vector representations per page and scores queries using token-level late interaction:
|
|
54
|
+
$$\\text{Score}(Q, P) = \\sum_{i=1}^{M} \\max_{j=1}^{N} \\text{sim}(q_i, p_j)$$
|
|
55
|
+
5. **Source-of-Truth Principle**: Returns original PDF page references, visual crops, and bounding boxes alongside similarity scores.
|
|
56
|
+
6. **Two-Stage Scalable Retrieval**: ANN candidate filtering before MaxSim reranking to scale effortlessly to tens of thousands of documents.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 📦 Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Core installation (Zero heavy dependencies, pure CPU)
|
|
64
|
+
pip install pagedoc-rag
|
|
65
|
+
|
|
66
|
+
# Optional extras:
|
|
67
|
+
pip install "pagedoc-rag[vector]" # Adds FAISS-CPU vector index backend
|
|
68
|
+
pip install "pagedoc-rag[all]" # Full suite (PyMuPDF, FAISS-CPU, Pillow, FastAPI)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 🚀 Quickstart (Python API)
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from pagedoc_rag import PageDocRAG
|
|
77
|
+
|
|
78
|
+
# 1. Initialize engine
|
|
79
|
+
rag = PageDocRAG(
|
|
80
|
+
embedding_model="small-cpu",
|
|
81
|
+
index_backend="memory", # or "faiss"
|
|
82
|
+
enable_charts=True,
|
|
83
|
+
enable_tables=True,
|
|
84
|
+
enable_seals=True
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# 2. Ingest document (PDF, PNG, JPG)
|
|
88
|
+
doc = rag.ingest("annual_report.pdf")
|
|
89
|
+
print(f"Ingested {doc.num_pages} pages ({doc.document_id})")
|
|
90
|
+
|
|
91
|
+
# 3. Perform natural language search
|
|
92
|
+
results = rag.search("What was the Net Operating Profit in FY2025?", top_k=5)
|
|
93
|
+
|
|
94
|
+
for res in results:
|
|
95
|
+
print(f"Rank Page #{res.page_number} | Score: {res.score:.4f}")
|
|
96
|
+
print(f"Snippet: {res.text[:140]}...")
|
|
97
|
+
print(f"Source PDF: {res.source_pdf}")
|
|
98
|
+
print(f"Evidence items found: {len(res.evidence)}")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 💻 CLI Usage
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Index a directory of documents
|
|
107
|
+
pagedoc index ./documents --backend memory
|
|
108
|
+
|
|
109
|
+
# Search across indexed pages
|
|
110
|
+
pagedoc search "What was revenue in 2025?" --top-k 5
|
|
111
|
+
|
|
112
|
+
# Inspect structured elements & bounding boxes on a page
|
|
113
|
+
pagedoc inspect ./documents/report.pdf --page 2
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 🏛️ Architecture & Processing Pipeline
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
PDF / Scanned Document
|
|
122
|
+
│
|
|
123
|
+
▼
|
|
124
|
+
PyMuPDF High-Res Rendering
|
|
125
|
+
│
|
|
126
|
+
┌──────────────────────┴──────────────────────┐
|
|
127
|
+
▼ ▼
|
|
128
|
+
Native Digital Stream Scanned Document Stream
|
|
129
|
+
• Text Blocks & Coordinates • PaddleOCR DBNet / SVTR
|
|
130
|
+
• Native Table Matrices (find_tables) • PP-Structure Layout Router
|
|
131
|
+
• Vector Drawings & Images • Chart2Table & Seal Detector
|
|
132
|
+
│ │
|
|
133
|
+
└──────────────────────┬──────────────────────┘
|
|
134
|
+
▼
|
|
135
|
+
Semantic Multimodal Chunking
|
|
136
|
+
├── Text Paragraphs with Bounding Boxes
|
|
137
|
+
├── Structured Table Matrices (CSV / Headers)
|
|
138
|
+
└── Decomposed Chart Relations & Trends
|
|
139
|
+
│
|
|
140
|
+
▼
|
|
141
|
+
Multi-Vector Embedding Model
|
|
142
|
+
[p1, p2, p3, ... pN per page]
|
|
143
|
+
│
|
|
144
|
+
▼
|
|
145
|
+
Two-Stage Candidate Search & Filtering
|
|
146
|
+
│
|
|
147
|
+
▼
|
|
148
|
+
Vectorized MaxSim Late Interaction
|
|
149
|
+
│
|
|
150
|
+
▼
|
|
151
|
+
Authoritative Page Retrieval & RAG Context
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 📊 Evaluation & Benchmarking
|
|
157
|
+
|
|
158
|
+
PageDoc-RAG includes a built-in evaluation suite for standard information retrieval metrics:
|
|
159
|
+
- **Recall@1, Recall@5, Recall@10**
|
|
160
|
+
- **Mean Reciprocal Rank (MRR)**
|
|
161
|
+
- **nDCG@5, nDCG@10**
|
|
162
|
+
- **Latency Percentiles (p50, p95) & QPS**
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
from pagedoc_rag.eval.benchmark import Evaluator, BenchmarkQuery
|
|
166
|
+
|
|
167
|
+
queries = [
|
|
168
|
+
BenchmarkQuery(query="Revenue breakdown", target_page_ids=["doc_p2"], query_type="table"),
|
|
169
|
+
BenchmarkQuery(query="Executive summary", target_page_ids=["doc_p1"], query_type="text"),
|
|
170
|
+
]
|
|
171
|
+
|
|
172
|
+
report = Evaluator.evaluate(rag, queries)
|
|
173
|
+
print(f"Recall@1: {report.recall_at_1:.2%}, MRR: {report.mrr:.4f}")
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## 📄 License
|
|
179
|
+
|
|
180
|
+
Licensed under the [Apache License, Version 2.0](LICENSE).
|
|
181
|
+
|
|
182
|
+
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# PageDoc-RAG: CPU-First Multimodal Document Ingestion & Retrieval Engine
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/pagedoc-rag/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
|
|
7
|
+
**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.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🌟 Why PageDoc-RAG?
|
|
12
|
+
|
|
13
|
+
1. **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.
|
|
14
|
+
2. **CPU-First Architecture**: High-speed, cost-effective inference on standard CPU hardware without requiring heavy multi-gigabyte GPU models for standard enterprise document corpora.
|
|
15
|
+
3. **Atomic Multimodal Chunking**:
|
|
16
|
+
- **Tables**: Extracted as structured atomic units with header context preserved across rows.
|
|
17
|
+
- **Charts**: Decomposed into 3 vector streams: Chart Title, Data Series pairs, and Synthesized Semantic Relational Insights (e.g., *"Q4 has highest revenue"*).
|
|
18
|
+
- **Text**: Extracted with bounding boxes $[x_0, y_0, x_1, y_1]$ and reading-order continuity.
|
|
19
|
+
- **Seals & Stamps**: Detected and isolated for compliance and verification workflows.
|
|
20
|
+
4. **ColPali/ColBERT-Style Late Interaction (MaxSim)**: Generates fine-grained multi-vector representations per page and scores queries using token-level late interaction:
|
|
21
|
+
$$\\text{Score}(Q, P) = \\sum_{i=1}^{M} \\max_{j=1}^{N} \\text{sim}(q_i, p_j)$$
|
|
22
|
+
5. **Source-of-Truth Principle**: Returns original PDF page references, visual crops, and bounding boxes alongside similarity scores.
|
|
23
|
+
6. **Two-Stage Scalable Retrieval**: ANN candidate filtering before MaxSim reranking to scale effortlessly to tens of thousands of documents.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 📦 Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Core installation (Zero heavy dependencies, pure CPU)
|
|
31
|
+
pip install pagedoc-rag
|
|
32
|
+
|
|
33
|
+
# Optional extras:
|
|
34
|
+
pip install "pagedoc-rag[vector]" # Adds FAISS-CPU vector index backend
|
|
35
|
+
pip install "pagedoc-rag[all]" # Full suite (PyMuPDF, FAISS-CPU, Pillow, FastAPI)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 🚀 Quickstart (Python API)
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from pagedoc_rag import PageDocRAG
|
|
44
|
+
|
|
45
|
+
# 1. Initialize engine
|
|
46
|
+
rag = PageDocRAG(
|
|
47
|
+
embedding_model="small-cpu",
|
|
48
|
+
index_backend="memory", # or "faiss"
|
|
49
|
+
enable_charts=True,
|
|
50
|
+
enable_tables=True,
|
|
51
|
+
enable_seals=True
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
# 2. Ingest document (PDF, PNG, JPG)
|
|
55
|
+
doc = rag.ingest("annual_report.pdf")
|
|
56
|
+
print(f"Ingested {doc.num_pages} pages ({doc.document_id})")
|
|
57
|
+
|
|
58
|
+
# 3. Perform natural language search
|
|
59
|
+
results = rag.search("What was the Net Operating Profit in FY2025?", top_k=5)
|
|
60
|
+
|
|
61
|
+
for res in results:
|
|
62
|
+
print(f"Rank Page #{res.page_number} | Score: {res.score:.4f}")
|
|
63
|
+
print(f"Snippet: {res.text[:140]}...")
|
|
64
|
+
print(f"Source PDF: {res.source_pdf}")
|
|
65
|
+
print(f"Evidence items found: {len(res.evidence)}")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 💻 CLI Usage
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Index a directory of documents
|
|
74
|
+
pagedoc index ./documents --backend memory
|
|
75
|
+
|
|
76
|
+
# Search across indexed pages
|
|
77
|
+
pagedoc search "What was revenue in 2025?" --top-k 5
|
|
78
|
+
|
|
79
|
+
# Inspect structured elements & bounding boxes on a page
|
|
80
|
+
pagedoc inspect ./documents/report.pdf --page 2
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 🏛️ Architecture & Processing Pipeline
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
PDF / Scanned Document
|
|
89
|
+
│
|
|
90
|
+
▼
|
|
91
|
+
PyMuPDF High-Res Rendering
|
|
92
|
+
│
|
|
93
|
+
┌──────────────────────┴──────────────────────┐
|
|
94
|
+
▼ ▼
|
|
95
|
+
Native Digital Stream Scanned Document Stream
|
|
96
|
+
• Text Blocks & Coordinates • PaddleOCR DBNet / SVTR
|
|
97
|
+
• Native Table Matrices (find_tables) • PP-Structure Layout Router
|
|
98
|
+
• Vector Drawings & Images • Chart2Table & Seal Detector
|
|
99
|
+
│ │
|
|
100
|
+
└──────────────────────┬──────────────────────┘
|
|
101
|
+
▼
|
|
102
|
+
Semantic Multimodal Chunking
|
|
103
|
+
├── Text Paragraphs with Bounding Boxes
|
|
104
|
+
├── Structured Table Matrices (CSV / Headers)
|
|
105
|
+
└── Decomposed Chart Relations & Trends
|
|
106
|
+
│
|
|
107
|
+
▼
|
|
108
|
+
Multi-Vector Embedding Model
|
|
109
|
+
[p1, p2, p3, ... pN per page]
|
|
110
|
+
│
|
|
111
|
+
▼
|
|
112
|
+
Two-Stage Candidate Search & Filtering
|
|
113
|
+
│
|
|
114
|
+
▼
|
|
115
|
+
Vectorized MaxSim Late Interaction
|
|
116
|
+
│
|
|
117
|
+
▼
|
|
118
|
+
Authoritative Page Retrieval & RAG Context
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 📊 Evaluation & Benchmarking
|
|
124
|
+
|
|
125
|
+
PageDoc-RAG includes a built-in evaluation suite for standard information retrieval metrics:
|
|
126
|
+
- **Recall@1, Recall@5, Recall@10**
|
|
127
|
+
- **Mean Reciprocal Rank (MRR)**
|
|
128
|
+
- **nDCG@5, nDCG@10**
|
|
129
|
+
- **Latency Percentiles (p50, p95) & QPS**
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from pagedoc_rag.eval.benchmark import Evaluator, BenchmarkQuery
|
|
133
|
+
|
|
134
|
+
queries = [
|
|
135
|
+
BenchmarkQuery(query="Revenue breakdown", target_page_ids=["doc_p2"], query_type="table"),
|
|
136
|
+
BenchmarkQuery(query="Executive summary", target_page_ids=["doc_p1"], query_type="text"),
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
report = Evaluator.evaluate(rag, queries)
|
|
140
|
+
print(f"Recall@1: {report.recall_at_1:.2%}, MRR: {report.mrr:.4f}")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 📄 License
|
|
146
|
+
|
|
147
|
+
Licensed under the [Apache License, Version 2.0](LICENSE).
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pagedoc-rag"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "CPU-First Multimodal Document Chunking, Ingestion & Retrieval Engine using Native PDF Extraction, OCR, Multi-Vector Embeddings, and MaxSim Late Interaction"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "Apache-2.0" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "PageDoc Contributors" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"rag",
|
|
17
|
+
"document-chunking",
|
|
18
|
+
"pdf-ingestion",
|
|
19
|
+
"multimodal-rag",
|
|
20
|
+
"table-extraction",
|
|
21
|
+
"chart-parsing",
|
|
22
|
+
"maxsim",
|
|
23
|
+
"cpu-first",
|
|
24
|
+
"information-retrieval"
|
|
25
|
+
]
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Development Status :: 4 - Beta",
|
|
28
|
+
"Intended Audience :: Developers",
|
|
29
|
+
"Intended Audience :: Science/Research",
|
|
30
|
+
"License :: OSI Approved :: Apache Software License",
|
|
31
|
+
"Programming Language :: Python :: 3",
|
|
32
|
+
"Programming Language :: Python :: 3.9",
|
|
33
|
+
"Programming Language :: Python :: 3.10",
|
|
34
|
+
"Programming Language :: Python :: 3.11",
|
|
35
|
+
"Programming Language :: Python :: 3.12",
|
|
36
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
37
|
+
"Topic :: Text Processing :: Indexing"
|
|
38
|
+
]
|
|
39
|
+
dependencies = [
|
|
40
|
+
"numpy>=1.20.0",
|
|
41
|
+
"pydantic>=2.0.0",
|
|
42
|
+
"click>=8.0.0"
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.optional-dependencies]
|
|
46
|
+
charts = ["pillow>=9.0.0"]
|
|
47
|
+
tables = ["pillow>=9.0.0"]
|
|
48
|
+
vector = ["faiss-cpu>=1.7.0"]
|
|
49
|
+
api = ["fastapi>=0.95.0", "uvicorn>=0.20.0"]
|
|
50
|
+
all = ["pillow>=9.0.0", "pymupdf>=1.20.0", "faiss-cpu>=1.7.0", "fastapi>=0.95.0", "uvicorn>=0.20.0"]
|
|
51
|
+
dev = ["pytest>=7.0.0", "pytest-cov>=4.0.0"]
|
|
52
|
+
|
|
53
|
+
[project.scripts]
|
|
54
|
+
pagedoc-rag = "pagedoc_rag.cli:main"
|
|
55
|
+
pagedoc = "pagedoc_rag.cli:main"
|
|
56
|
+
|
|
57
|
+
[tool.setuptools.packages.find]
|
|
58
|
+
where = ["src"]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from setuptools import setup, find_packages
|
|
3
|
+
|
|
4
|
+
with open("README.md", "r", encoding="utf-8") as f:
|
|
5
|
+
long_description = f.read()
|
|
6
|
+
|
|
7
|
+
setup(
|
|
8
|
+
name="pagedoc-rag",
|
|
9
|
+
version="0.1.0",
|
|
10
|
+
description="CPU-First Multimodal Document Chunking, Ingestion & Retrieval Engine using Native PDF Extraction, OCR, Multi-Vector Embeddings, and MaxSim Late Interaction",
|
|
11
|
+
long_description=long_description,
|
|
12
|
+
long_description_content_type="text/markdown",
|
|
13
|
+
author="PageDoc Contributors",
|
|
14
|
+
author_email="maintainers@pagedoc.dev",
|
|
15
|
+
url="https://github.com/anoopchandra/pagedoc-rag",
|
|
16
|
+
project_urls={
|
|
17
|
+
"Documentation": "https://github.com/anoopchandra/pagedoc-rag#readme",
|
|
18
|
+
"Source": "https://github.com/anoopchandra/pagedoc-rag",
|
|
19
|
+
"Tracker": "https://github.com/anoopchandra/pagedoc-rag/issues",
|
|
20
|
+
},
|
|
21
|
+
license="Apache-2.0",
|
|
22
|
+
package_dir={"": "src"},
|
|
23
|
+
packages=find_packages(where="src"),
|
|
24
|
+
classifiers=[
|
|
25
|
+
"Development Status :: 4 - Beta",
|
|
26
|
+
"Intended Audience :: Developers",
|
|
27
|
+
"Intended Audience :: Science/Research",
|
|
28
|
+
"License :: OSI Approved :: Apache Software License",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Python :: 3.9",
|
|
31
|
+
"Programming Language :: Python :: 3.10",
|
|
32
|
+
"Programming Language :: Python :: 3.11",
|
|
33
|
+
"Programming Language :: Python :: 3.12",
|
|
34
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
35
|
+
"Topic :: Text Processing :: Indexing",
|
|
36
|
+
],
|
|
37
|
+
keywords=["rag", "document-chunking", "pdf-ingestion", "multimodal-rag", "table-extraction", "chart-parsing", "maxsim", "cpu-first", "information-retrieval"],
|
|
38
|
+
python_requires=">=3.9",
|
|
39
|
+
install_requires=[
|
|
40
|
+
"numpy>=1.20.0",
|
|
41
|
+
"pydantic>=2.0.0",
|
|
42
|
+
"click>=8.0.0",
|
|
43
|
+
],
|
|
44
|
+
extras_require={
|
|
45
|
+
"charts": ["pillow>=9.0.0"],
|
|
46
|
+
"tables": ["pillow>=9.0.0"],
|
|
47
|
+
"vector": ["faiss-cpu>=1.7.0"],
|
|
48
|
+
"api": ["fastapi>=0.95.0", "uvicorn>=0.20.0"],
|
|
49
|
+
"all": ["pillow>=9.0.0", "pymupdf>=1.20.0", "faiss-cpu>=1.7.0", "fastapi>=0.95.0", "uvicorn>=0.20.0"],
|
|
50
|
+
},
|
|
51
|
+
entry_points={
|
|
52
|
+
"console_scripts": [
|
|
53
|
+
"pagedoc-rag=pagedoc_rag.cli:main",
|
|
54
|
+
"pagedoc=pagedoc_rag.cli:main",
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""PageDoc-RAG: CPU-First Multimodal Document Chunking, Ingestion & Retrieval Engine."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.0"
|
|
4
|
+
|
|
5
|
+
from pagedoc_rag.api import DocumentRetriever, SearchResult, PageEvidence
|
|
6
|
+
from pagedoc_rag.config import RetrieverConfig, HybridWeights
|
|
7
|
+
from pagedoc_rag.document.elements import (
|
|
8
|
+
Document,
|
|
9
|
+
Page,
|
|
10
|
+
ElementType,
|
|
11
|
+
TextElement,
|
|
12
|
+
TableElement,
|
|
13
|
+
ChartElement,
|
|
14
|
+
SealElement,
|
|
15
|
+
SignatureElement,
|
|
16
|
+
BoundingBox
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
# Intuitive top-level aliases
|
|
20
|
+
PageDocRAG = DocumentRetriever
|
|
21
|
+
MultimodalDocRetriever = DocumentRetriever
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"PageDocRAG",
|
|
25
|
+
"DocumentRetriever",
|
|
26
|
+
"MultimodalDocRetriever",
|
|
27
|
+
"SearchResult",
|
|
28
|
+
"PageEvidence",
|
|
29
|
+
"RetrieverConfig",
|
|
30
|
+
"HybridWeights",
|
|
31
|
+
"Document",
|
|
32
|
+
"Page",
|
|
33
|
+
"ElementType",
|
|
34
|
+
"TextElement",
|
|
35
|
+
"TableElement",
|
|
36
|
+
"ChartElement",
|
|
37
|
+
"SealElement",
|
|
38
|
+
"SignatureElement",
|
|
39
|
+
"BoundingBox"
|
|
40
|
+
]
|