pageindex 0.3.0.dev2__tar.gz → 0.4.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.
Files changed (138) hide show
  1. pageindex-0.4.0/PKG-INFO +308 -0
  2. pageindex-0.4.0/README.md +262 -0
  3. pageindex-0.4.0/pageindex/__init__.py +54 -0
  4. pageindex-0.4.0/pageindex/_version.py +10 -0
  5. pageindex-0.4.0/pageindex/agent_tools.py +1774 -0
  6. pageindex-0.4.0/pageindex/chat_stream.py +69 -0
  7. pageindex-0.4.0/pageindex/client.py +2730 -0
  8. pageindex-0.4.0/pageindex/cloud_api.py +565 -0
  9. pageindex-0.4.0/pageindex/config.yaml +15 -0
  10. pageindex-0.4.0/pageindex/errors.py +16 -0
  11. pageindex-0.4.0/pageindex/flash/README.md +80 -0
  12. pageindex-0.4.0/pageindex/flash/__init__.py +5 -0
  13. pageindex-0.4.0/pageindex/flash/api.py +267 -0
  14. pageindex-0.4.0/pageindex/flash/blocks/__init__.py +56 -0
  15. pageindex-0.4.0/pageindex/flash/blocks/build.py +173 -0
  16. pageindex-0.4.0/pageindex/flash/blocks/join_rules.py +326 -0
  17. pageindex-0.4.0/pageindex/flash/classification/__init__.py +131 -0
  18. pageindex-0.4.0/pageindex/flash/classification/body_text.py +209 -0
  19. pageindex-0.4.0/pageindex/flash/classification/header_footer.py +481 -0
  20. pageindex-0.4.0/pageindex/flash/classification/keyword_tables.py +113 -0
  21. pageindex-0.4.0/pageindex/flash/classification/toc_boilerplate.py +375 -0
  22. pageindex-0.4.0/pageindex/flash/clustering/__init__.py +68 -0
  23. pageindex-0.4.0/pageindex/flash/clustering/build.py +211 -0
  24. pageindex-0.4.0/pageindex/flash/clustering/merge_rules.py +190 -0
  25. pageindex-0.4.0/pageindex/flash/columns/__init__.py +49 -0
  26. pageindex-0.4.0/pageindex/flash/columns/gutters.py +345 -0
  27. pageindex-0.4.0/pageindex/flash/columns/splitting.py +223 -0
  28. pageindex-0.4.0/pageindex/flash/data/boilerplate_phrases.json +1 -0
  29. pageindex-0.4.0/pageindex/flash/data/dictionaries.json +1 -0
  30. pageindex-0.4.0/pageindex/flash/data/glyph_name_table.json +1 -0
  31. pageindex-0.4.0/pageindex/flash/data/normalized_unicodes.json +1 -0
  32. pageindex-0.4.0/pageindex/flash/data/script_bucket_table.json +1 -0
  33. pageindex-0.4.0/pageindex/flash/embedded_toc.py +615 -0
  34. pageindex-0.4.0/pageindex/flash/heading_detection/__init__.py +120 -0
  35. pageindex-0.4.0/pageindex/flash/heading_detection/candidates.py +214 -0
  36. pageindex-0.4.0/pageindex/flash/heading_detection/detectors.py +492 -0
  37. pageindex-0.4.0/pageindex/flash/heading_detection/keyword_tables.py +96 -0
  38. pageindex-0.4.0/pageindex/flash/heading_detection/neighbors.py +155 -0
  39. pageindex-0.4.0/pageindex/flash/heading_detection/page_scan.py +470 -0
  40. pageindex-0.4.0/pageindex/flash/heading_detection/style_detectors.py +383 -0
  41. pageindex-0.4.0/pageindex/flash/heading_detection/text_checks.py +221 -0
  42. pageindex-0.4.0/pageindex/flash/labels/__init__.py +48 -0
  43. pageindex-0.4.0/pageindex/flash/labels/caption_regions.py +366 -0
  44. pageindex-0.4.0/pageindex/flash/labels/caption_text.py +171 -0
  45. pageindex-0.4.0/pageindex/flash/main.py +306 -0
  46. pageindex-0.4.0/pageindex/flash/model/__init__.py +121 -0
  47. pageindex-0.4.0/pageindex/flash/model/block.py +288 -0
  48. pageindex-0.4.0/pageindex/flash/model/char_stats.py +184 -0
  49. pageindex-0.4.0/pageindex/flash/model/numbering.py +131 -0
  50. pageindex-0.4.0/pageindex/flash/model/rects.py +229 -0
  51. pageindex-0.4.0/pageindex/flash/model/span_line.py +228 -0
  52. pageindex-0.4.0/pageindex/flash/outline/__init__.py +54 -0
  53. pageindex-0.4.0/pageindex/flash/outline/filtering.py +241 -0
  54. pageindex-0.4.0/pageindex/flash/outline/tree.py +145 -0
  55. pageindex-0.4.0/pageindex/flash/outline_assembly/__init__.py +108 -0
  56. pageindex-0.4.0/pageindex/flash/outline_assembly/assembly.py +344 -0
  57. pageindex-0.4.0/pageindex/flash/outline_assembly/candidates.py +231 -0
  58. pageindex-0.4.0/pageindex/flash/outline_assembly/cliques.py +403 -0
  59. pageindex-0.4.0/pageindex/flash/outline_assembly/selection.py +385 -0
  60. pageindex-0.4.0/pageindex/flash/outline_assembly/style_context.py +365 -0
  61. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/__init__.py +171 -0
  62. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/char_extract.py +414 -0
  63. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/cmap_parse.py +341 -0
  64. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/code_walk.py +249 -0
  65. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/content_stream.py +424 -0
  66. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/font_unicode.py +436 -0
  67. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/geometry.py +238 -0
  68. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/glyph_tables.py +82 -0
  69. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/merge.py +526 -0
  70. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/pdf_objects.py +191 -0
  71. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/pipeline.py +295 -0
  72. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/remerge.py +327 -0
  73. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/text_normalize.py +290 -0
  74. pageindex-0.4.0/pageindex/flash/parser_pdfium_charlevel/unicode_apply.py +431 -0
  75. pageindex-0.4.0/pageindex/flash/parser_pdfium_parallel.py +193 -0
  76. pageindex-0.4.0/pageindex/flash/phases/__init__.py +50 -0
  77. pageindex-0.4.0/pageindex/flash/phases/line_numbers.py +162 -0
  78. pageindex-0.4.0/pageindex/flash/phases/page_view.py +123 -0
  79. pageindex-0.4.0/pageindex/flash/stats/__init__.py +48 -0
  80. pageindex-0.4.0/pageindex/flash/stats/aggregates.py +313 -0
  81. pageindex-0.4.0/pageindex/flash/stats/scripts.py +85 -0
  82. pageindex-0.4.0/pageindex/flash/title/__init__.py +54 -0
  83. pageindex-0.4.0/pageindex/flash/title/detect.py +125 -0
  84. pageindex-0.4.0/pageindex/flash/title/dicts.py +35 -0
  85. pageindex-0.4.0/pageindex/flash/title/scoring.py +256 -0
  86. pageindex-0.4.0/pageindex/flash/tokens/__init__.py +105 -0
  87. pageindex-0.4.0/pageindex/flash/tokens/hashing.py +139 -0
  88. pageindex-0.4.0/pageindex/flash/tokens/token_types.py +243 -0
  89. pageindex-0.4.0/pageindex/flash/tokens/tokenizer.py +271 -0
  90. pageindex-0.4.0/pageindex/flash/tokens/tries.py +336 -0
  91. pageindex-0.4.0/pageindex/imaging.py +42 -0
  92. pageindex-0.4.0/pageindex/integrations/__init__.py +5 -0
  93. pageindex-0.4.0/pageindex/integrations/anthropic_sdk.py +84 -0
  94. pageindex-0.4.0/pageindex/integrations/claude_agent_sdk.py +65 -0
  95. pageindex-0.4.0/pageindex/integrations/openai_agents.py +102 -0
  96. pageindex-0.4.0/pageindex/local_api.py +414 -0
  97. pageindex-0.4.0/pageindex/local_chat.py +1545 -0
  98. pageindex-0.4.0/pageindex/local_store.py +186 -0
  99. pageindex-0.4.0/pageindex/mcp_bridge.py +297 -0
  100. pageindex-0.4.0/pageindex/naming.py +96 -0
  101. pageindex-0.3.0.dev2/pageindex/index/page_index.py → pageindex-0.4.0/pageindex/page_index_classic.py +248 -72
  102. {pageindex-0.3.0.dev2/pageindex/index → pageindex-0.4.0/pageindex}/page_index_md.py +29 -22
  103. pageindex-0.4.0/pageindex/tree_optimize.py +1122 -0
  104. pageindex-0.4.0/pageindex/types.py +64 -0
  105. pageindex-0.4.0/pageindex/utils.py +1527 -0
  106. pageindex-0.4.0/pyproject.toml +67 -0
  107. pageindex-0.3.0.dev2/PKG-INFO +0 -401
  108. pageindex-0.3.0.dev2/README.md +0 -363
  109. pageindex-0.3.0.dev2/pageindex/__init__.py +0 -64
  110. pageindex-0.3.0.dev2/pageindex/agent.py +0 -168
  111. pageindex-0.3.0.dev2/pageindex/backend/cloud.py +0 -477
  112. pageindex-0.3.0.dev2/pageindex/backend/local.py +0 -335
  113. pageindex-0.3.0.dev2/pageindex/backend/protocol.py +0 -47
  114. pageindex-0.3.0.dev2/pageindex/client.py +0 -329
  115. pageindex-0.3.0.dev2/pageindex/cloud_api.py +0 -283
  116. pageindex-0.3.0.dev2/pageindex/collection.py +0 -138
  117. pageindex-0.3.0.dev2/pageindex/config.py +0 -165
  118. pageindex-0.3.0.dev2/pageindex/errors.py +0 -44
  119. pageindex-0.3.0.dev2/pageindex/events.py +0 -9
  120. pageindex-0.3.0.dev2/pageindex/index/__init__.py +0 -0
  121. pageindex-0.3.0.dev2/pageindex/index/pipeline.py +0 -131
  122. pageindex-0.3.0.dev2/pageindex/index/utils.py +0 -905
  123. pageindex-0.3.0.dev2/pageindex/page_index.py +0 -15
  124. pageindex-0.3.0.dev2/pageindex/page_index_md.py +0 -38
  125. pageindex-0.3.0.dev2/pageindex/parser/__init__.py +0 -0
  126. pageindex-0.3.0.dev2/pageindex/parser/markdown.py +0 -88
  127. pageindex-0.3.0.dev2/pageindex/parser/pdf.py +0 -99
  128. pageindex-0.3.0.dev2/pageindex/parser/protocol.py +0 -31
  129. pageindex-0.3.0.dev2/pageindex/retrieve.py +0 -140
  130. pageindex-0.3.0.dev2/pageindex/storage/__init__.py +0 -0
  131. pageindex-0.3.0.dev2/pageindex/storage/protocol.py +0 -43
  132. pageindex-0.3.0.dev2/pageindex/storage/sqlite.py +0 -192
  133. pageindex-0.3.0.dev2/pageindex/tokens.py +0 -11
  134. pageindex-0.3.0.dev2/pageindex/types.py +0 -32
  135. pageindex-0.3.0.dev2/pageindex/utils.py +0 -14
  136. pageindex-0.3.0.dev2/pyproject.toml +0 -44
  137. {pageindex-0.3.0.dev2 → pageindex-0.4.0}/LICENSE +0 -0
  138. /pageindex-0.3.0.dev2/pageindex/backend/__init__.py → /pageindex-0.4.0/pageindex/py.typed +0 -0
@@ -0,0 +1,308 @@
1
+ Metadata-Version: 2.4
2
+ Name: pageindex
3
+ Version: 0.4.0
4
+ Summary: Python SDK for PageIndex — reasoning-based, vectorless document retrieval, cloud and local
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: rag,document,retrieval,llm,pageindex,vectorless
8
+ Author: Ray
9
+ Author-email: ray@vectify.ai
10
+ Requires-Python: >=3.10
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Provides-Extra: anthropic
23
+ Provides-Extra: claude
24
+ Provides-Extra: openai
25
+ Requires-Dist: Pillow (>=9.0)
26
+ Requires-Dist: PyPDF2 (>=3.0.0)
27
+ Requires-Dist: anthropic (>=0.122.0) ; extra == "anthropic"
28
+ Requires-Dist: claude-agent-sdk (>=0.1.53) ; extra == "claude"
29
+ Requires-Dist: litellm (>=1.105.0)
30
+ Requires-Dist: mcp (>=1.19.0,<3)
31
+ Requires-Dist: openai (>=1.70.0)
32
+ Requires-Dist: openai-agents (>=0.18.1)
33
+ Requires-Dist: pypdfium2 (>=5)
34
+ Requires-Dist: python-dotenv (>=1.0.0)
35
+ Requires-Dist: pyyaml (>=6.0)
36
+ Requires-Dist: regex (>=2024.0.0)
37
+ Requires-Dist: requests (>=2.28.0)
38
+ Requires-Dist: sortedcontainers (>=2.4.0)
39
+ Requires-Dist: urllib3 (>=1.26)
40
+ Project-URL: Documentation, https://docs.pageindex.ai
41
+ Project-URL: Homepage, https://pageindex.ai
42
+ Project-URL: Issues, https://github.com/VectifyAI/PageIndex/issues
43
+ Project-URL: Repository, https://github.com/VectifyAI/PageIndex
44
+ Description-Content-Type: text/markdown
45
+
46
+ <div align="center">
47
+
48
+ <a href="https://vectify.ai/pageindex" target="_blank">
49
+ <img width="1471" alt="pi_github_banner_low" src="https://github.com/user-attachments/assets/bae02956-6c4e-4a0b-adea-257b0be4aaa1" />
50
+ </a>
51
+
52
+ <br/>
53
+ <br/>
54
+
55
+ <p align="center">
56
+ <a href="https://trendshift.io/repositories/14736" target="_blank"><img src="https://trendshift.io/api/badge/repositories/14736" alt="VectifyAI%2FPageIndex | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
57
+ </p>
58
+
59
+ # PageIndex: Vectorless, Reasoning-based RAG
60
+
61
+ <p align="center"><b>Reasoning-based RAG&nbsp; ◦ &nbsp;No Vector DB, No Chunking&nbsp; ◦ &nbsp;Context-Aware Retrieval&nbsp; ◦ &nbsp;Reads Like a Human</b></p>
62
+
63
+ <h4 align="center">
64
+ <a href="https://pageindex.ai/developer">🌐 Website</a>&nbsp; • &nbsp;
65
+ <a href="https://developer.pageindex.ai/">☁️ Cloud</a>&nbsp; • &nbsp;
66
+ <a href="https://docs.pageindex.ai">📖 Docs</a>&nbsp; • &nbsp;
67
+ <a href="https://pageindex.ai/blog">📝 Blog</a>&nbsp; • &nbsp;
68
+ <a href="https://pageindex.ai/contact">✉️ Contact</a>&nbsp;
69
+ </h4>
70
+
71
+ </div>
72
+
73
+
74
+
75
+ <details open>
76
+ <summary><h2>Updates</h2></summary>
77
+
78
+ - [Aug '26] 🔥 [**PageIndex SDK**](#quickstart): `pip install -U pageindex` now ships **local mode**: index, retrieve, and chat entirely on your machine with your own LLM key, or point the same client at PageIndex Cloud with an API key.
79
+ - [Aug '26] ⚡ [**PageIndex Flash**](https://pageindex.ai/blog/pageindex-flash): fast tree index generation for text-based PDFs, now the default indexing method in PageIndex SDK local mode.
80
+ - [Scale PageIndex to Millions of Documents](https://pageindex.ai/blog/pageindex-filesystem): *PageIndex File System* is a file-level tree indexing layer that lets PageIndex reason over an entire corpus, not just a single document.
81
+ - [PageIndex App](https://app.pageindex.ai): a human-like document analysis agent for long professional documents.<!-- Also available via [MCP](https://pageindex.ai/developer) or [API](https://pageindex.ai/developer). -->
82
+
83
+ </details>
84
+
85
+
86
+
87
+ # What is PageIndex?
88
+
89
+ Are you frustrated with vector database retrieval accuracy for long and complex documents? Vector-based RAG retrieves by semantic **similarity**. But **similarity ≠ relevance** — what retrieval actually needs is relevance, and relevance requires **reasoning**. On professional documents that demand contextual understanding, domain expertise, and multi-step reasoning, similarity search misses what is relevant but not similar, and returns what is similar but not relevant.
90
+
91
+ Inspired by AlphaGo, **[PageIndex](https://vectify.ai/pageindex)** replaces the vector index with a **hierarchical tree index** and lets an LLM **reason** its way through it, the way a human expert turns to and reads the right section of a long report. Retrieval happens in two steps:
92
+
93
+ 1. **Index**: generate a **tree-structure index** for each document
94
+ 2. **Retrieve**: agentically **search that tree** with LLM reasoning
95
+
96
+ <div align="center">
97
+ <a href="https://pageindex.ai/blog/pageindex-intro" target="_blank" title="The PageIndex Framework">
98
+ <img src="https://docs.pageindex.ai/images/cookbook/vectorless-rag.png" width="70%">
99
+ </a>
100
+ </div>
101
+
102
+
103
+ ### TL;DR
104
+
105
+ <blockquote>PageIndex is a <b>vectorless</b>, <b>reasoning-based RAG</b> engine that <b>mirrors how humans read</b>, delivering <b>traceable</b>, <b>explainable</b>, and <b>context-aware</b> retrieval, with <b>no vector DBs</b> or <b>chunking</b>.</blockquote>
106
+
107
+ ### Compare with Vector RAG
108
+
109
+ | | Vector RAG | **PageIndex** |
110
+ |---|---|---|
111
+ | **Index** | vector index | tree index |
112
+ | **Retrieval** | semantic similarity search | LLM reasoning over the tree |
113
+ | **Result** | opaque, “vibe retrieval” | traceable to explicit references |
114
+ | **Context** | query embedding only | full context: conversation history, domain knowledge, etc. |
115
+
116
+ It is ideal for financial reports, legal documents, regulatory filings, technical manuals, medical literature, academic textbooks, and any other long, complex professional document.
117
+
118
+
119
+
120
+
121
+ # Quickstart
122
+
123
+ ```bash
124
+ pip install -U pageindex
125
+ ```
126
+
127
+
128
+ ```python
129
+ import os
130
+ from pageindex import PageIndexClient
131
+
132
+ os.environ["OPENAI_API_KEY"] = "your-openai-key"
133
+
134
+ client = PageIndexClient(
135
+ index="gpt-6-luna", # model to build the tree index
136
+ chat="gpt-6-sol", # model to search the tree
137
+ )
138
+ doc_id = client.submit_document("report.pdf")["doc_id"]
139
+
140
+ answer = client.chat("What was the 2023 operating margin?", doc_id=doc_id)
141
+ print(answer)
142
+ ```
143
+
144
+ ### Model Recommendations
145
+
146
+ - **`index=`: a basic model is sufficient.** The tree structure itself is extracted from the document layout without an LLM; the index model only summarizes and refines it, which a basic model does well.
147
+ - **`chat=`: use the best model you can afford.** The chat model searches the tree to retrieve information. See [Query cost and accuracy](#query-cost-and-accuracy).
148
+
149
+ ### [Use PageIndex through the SDK client →](https://docs.pageindex.ai/getting-started)
150
+
151
+ Configure other models, streaming, multi-document search, citations, and more.
152
+
153
+ ### [Integrate PageIndex with your own agent →](https://docs.pageindex.ai/sdk/agents)
154
+
155
+ Drop PageIndex tools into the OpenAI Agents SDK, the Claude Agent SDK, or any other framework.
156
+
157
+
158
+ # Benchmarks
159
+
160
+ ### Local indexing cost and time
161
+
162
+ Building a tree locally runs **about $0.001 per page** with `gpt-5.6-luna` as the index model, so a 1,000-page textbook costs a little over a dollar and a few minutes, once, and every later question reuses it. PageIndex is designed not to rely heavily on the model used at index time, so in our experiments a basic model does not hurt quality.
163
+
164
+ <div align="center">
165
+ <picture>
166
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/index-cost-dark.png">
167
+ <img src="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/index-cost-light.png" width="75%" alt="Indexing cost against document length, log-log, for nine PDFs from 9 to 1,098 pages. Points track a $0.0011-per-page reference line; the spread around it is text density, not length.">
168
+ </picture>
169
+ </div>
170
+
171
+ Indexing time also scales predictably with document length. In the same local setup, the benchmark documents (9 to 1,098 pages) finished in roughly **13 seconds to 4.5 minutes**.
172
+
173
+ <div align="center">
174
+ <picture>
175
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/index-time-dark.png">
176
+ <img src="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/index-time-light.png" width="75%" alt="Indexing time against document length, log-log, for nine PDFs from 9 to 1,098 pages. The measured indexing times range from about 13 seconds to 4.5 minutes and increase predictably with document length.">
177
+ </picture>
178
+ </div>
179
+
180
+
181
+
182
+ ### Query cost and accuracy
183
+
184
+ [**PageIndex-OSS-Benchmark**](https://github.com/VectifyAI/PageIndex-OSS-Benchmark) measures exactly the setup in the quickstart above (`PageIndexClient()` in local mode, flash indexing, no OCR) on 62 lookup questions over 34 PDFs (1,945 pages) drawn from [MMLongBench-Doc-V2](https://github.com/VectifyAI/MMLongBench-Doc-V2). Every question's answer is a fact stated in running text, so a wrong answer is a **retrieval or reading failure**, not a reasoning one.
185
+
186
+ <div align="center">
187
+ <picture>
188
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/results-dark.png">
189
+ <img src="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/results-light.png" width="75%" alt="Accuracy against average cost per question. Each model forms a near-vertical reasoning-effort ladder; moving between models costs an order of magnitude a step.">
190
+ </picture>
191
+ </div>
192
+
193
+
194
+ Full results, data, and the runner are in the [benchmark repo](https://github.com/VectifyAI/PageIndex-OSS-Benchmark).
195
+
196
+ ### Cost per query vs. native PDF input
197
+
198
+ The alternative to retrieval is handing the model the whole PDF on every question. That cost grows with the document; PageIndex's does not, because it reads only the nodes its reasoning reaches. On documents where both routes return the same answer, native PDF input costs **2.1× more at 52 pages and 16.6× more at 420** (`gpt-5.6-sol`, prompt caching excluded) — and at 805 pages the document no longer fits in the context window at all.
199
+
200
+ <div align="center">
201
+ <picture>
202
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/query-cost-dark.png">
203
+ <img src="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/query-cost-light.png" width="75%" alt="Cost per query relative to PageIndex retrieval, for five PDFs from 52 to 805 pages. Passing the PDF natively costs 2.1x, 3.4x, 7.8x, and 16.6x more at 52, 85, 198, and 420 pages; at 805 pages it exceeds the model's context window.">
204
+ </picture>
205
+ </div>
206
+
207
+ ### Leading accuracy on FinanceBench
208
+
209
+ PageIndex reached a state-of-the-art [**98.7% accuracy**](https://vectify.ai/blog/Mafin2.5) on [FinanceBench](https://arxiv.org/abs/2311.11944) (financial document QA benchmark), vastly outperforming vector-based RAG.
210
+
211
+ <div align="center">
212
+ <a href="https://github.com/VectifyAI/Mafin2.5-FinanceBench">
213
+ <picture>
214
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/financebench-dark.png">
215
+ <img src="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/financebench-light.png" width="70%" alt="FinanceBench accuracy: PageIndex 98.7%, vector RAG 50%.">
216
+ </picture>
217
+ </a>
218
+ </div>
219
+
220
+ Explore the full FinanceBench [evaluation results](https://github.com/VectifyAI/Mafin2.5-FinanceBench) and the [blog post](https://vectify.ai/blog/Mafin2.5).
221
+
222
+
223
+ # PageIndex Cloud
224
+
225
+ The open-source version is ideal for text-heavy PDFs and local workflows. With **PageIndex Cloud, document indexing and storage run in the cloud**: PageIndex handles parsing, OCR, image understanding, tree-index construction, and managed storage for you. The chat and retrieval layer remains **compatible with your model**, so you can search the cloud-hosted index using the model provider your application already uses.
226
+
227
+ Moving indexing and storage from Local to Cloud only requires a [PageIndex API key](https://developer.pageindex.ai/):
228
+
229
+ ```python
230
+ import os
231
+ from pageindex import PageIndexClient
232
+
233
+ os.environ["PAGEINDEX_API_KEY"] = "your-pageindex-key"
234
+ os.environ["OPENAI_API_KEY"] = "your-openai-key"
235
+
236
+ client = PageIndexClient(
237
+ index="cloud", # build and store the index in PageIndex Cloud
238
+ chat="gpt-6-sol", # use your preferred compatible model for chat
239
+ )
240
+ doc_id = client.submit_document("report.pdf", wait=True)["doc_id"]
241
+ print(client.chat("What was the 2023 operating margin?", doc_id=doc_id))
242
+ ```
243
+
244
+ | | **Local** | **Cloud** |
245
+ |---|---|---|
246
+ | Handles | Text-based PDFs | Text-based, scanned, and image-rich documents |
247
+ | Indexing | On your machine | Managed by PageIndex |
248
+ | Storage | Local directory | Cloud storage |
249
+ | Citations | Page-level | Block-level |
250
+ | OCR & image understanding | — | ✓ |
251
+ | [Metadata](https://docs.pageindex.ai/sdk/documents#metadata-cloud) | — | ✓ |
252
+ | [Folders](https://docs.pageindex.ai/sdk/documents#folders-cloud) | — | ✓ |
253
+ | [MCP server](https://docs.pageindex.ai/mcp) | — | ✓ |
254
+
255
+ ### More About PageIndex Cloud
256
+
257
+ - [Scale PageIndex to Millions of Documents](https://pageindex.ai/blog/pageindex-filesystem): **PageIndex File System** is a Cloud-only, file-level tree indexing layer that lets PageIndex reason over an entire corpus, not just a single document.
258
+
259
+ ### Ready to Try It?
260
+
261
+ - Get a [PageIndex API key](https://developer.pageindex.ai/)
262
+ - Read the [PageIndex Cloud documentation](https://docs.pageindex.ai/)
263
+
264
+ For dedicated deployment (VPC or on-premises), [contact us](https://pageindex.ai/contact) or [book a demo](https://calendly.com/pageindex/meet).
265
+
266
+
267
+
268
+ ---
269
+
270
+ # ⭐ Support Us
271
+
272
+ Leave us a star 🌟 if you like our project. Thank you!
273
+
274
+ <p>
275
+ <img src="https://github.com/user-attachments/assets/eae4ff38-48ae-4a7c-b19f-eab81201d794" width="80%">
276
+ </p>
277
+
278
+ Please cite this work as:
279
+ ```
280
+ Mingtian Zhang, Yu Tang and PageIndex Team,
281
+ "PageIndex: Next-Generation Vectorless, Reasoning-based RAG",
282
+ PageIndex Blog, Sep 2025.
283
+ ```
284
+
285
+ <details>
286
+ <summary>Or use the BibTeX citation.</summary>
287
+
288
+ ```bibtex
289
+ @article{zhang2025pageindex,
290
+ author = {Mingtian Zhang and Yu Tang and PageIndex Team},
291
+ title = {PageIndex: Next-Generation Vectorless, Reasoning-based RAG},
292
+ journal = {PageIndex Blog},
293
+ year = {2025},
294
+ month = {September},
295
+ note = {https://pageindex.ai/blog/pageindex-intro},
296
+ }
297
+ ```
298
+ </details>
299
+
300
+
301
+
302
+
303
+ ---
304
+
305
+ © 2026 [PageIndex AI](https://pageindex.ai)
306
+
307
+ <img width="288" height="80" alt="pageindex-wordmark-animated-288-warm" src="https://github.com/user-attachments/assets/e1c677f2-b590-4ffc-859d-e8cc7d794bdf" />
308
+
@@ -0,0 +1,262 @@
1
+ <div align="center">
2
+
3
+ <a href="https://vectify.ai/pageindex" target="_blank">
4
+ <img width="1471" alt="pi_github_banner_low" src="https://github.com/user-attachments/assets/bae02956-6c4e-4a0b-adea-257b0be4aaa1" />
5
+ </a>
6
+
7
+ <br/>
8
+ <br/>
9
+
10
+ <p align="center">
11
+ <a href="https://trendshift.io/repositories/14736" target="_blank"><img src="https://trendshift.io/api/badge/repositories/14736" alt="VectifyAI%2FPageIndex | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
12
+ </p>
13
+
14
+ # PageIndex: Vectorless, Reasoning-based RAG
15
+
16
+ <p align="center"><b>Reasoning-based RAG&nbsp; ◦ &nbsp;No Vector DB, No Chunking&nbsp; ◦ &nbsp;Context-Aware Retrieval&nbsp; ◦ &nbsp;Reads Like a Human</b></p>
17
+
18
+ <h4 align="center">
19
+ <a href="https://pageindex.ai/developer">🌐 Website</a>&nbsp; • &nbsp;
20
+ <a href="https://developer.pageindex.ai/">☁️ Cloud</a>&nbsp; • &nbsp;
21
+ <a href="https://docs.pageindex.ai">📖 Docs</a>&nbsp; • &nbsp;
22
+ <a href="https://pageindex.ai/blog">📝 Blog</a>&nbsp; • &nbsp;
23
+ <a href="https://pageindex.ai/contact">✉️ Contact</a>&nbsp;
24
+ </h4>
25
+
26
+ </div>
27
+
28
+
29
+
30
+ <details open>
31
+ <summary><h2>Updates</h2></summary>
32
+
33
+ - [Aug '26] 🔥 [**PageIndex SDK**](#quickstart): `pip install -U pageindex` now ships **local mode**: index, retrieve, and chat entirely on your machine with your own LLM key, or point the same client at PageIndex Cloud with an API key.
34
+ - [Aug '26] ⚡ [**PageIndex Flash**](https://pageindex.ai/blog/pageindex-flash): fast tree index generation for text-based PDFs, now the default indexing method in PageIndex SDK local mode.
35
+ - [Scale PageIndex to Millions of Documents](https://pageindex.ai/blog/pageindex-filesystem): *PageIndex File System* is a file-level tree indexing layer that lets PageIndex reason over an entire corpus, not just a single document.
36
+ - [PageIndex App](https://app.pageindex.ai): a human-like document analysis agent for long professional documents.<!-- Also available via [MCP](https://pageindex.ai/developer) or [API](https://pageindex.ai/developer). -->
37
+
38
+ </details>
39
+
40
+
41
+
42
+ # What is PageIndex?
43
+
44
+ Are you frustrated with vector database retrieval accuracy for long and complex documents? Vector-based RAG retrieves by semantic **similarity**. But **similarity ≠ relevance** — what retrieval actually needs is relevance, and relevance requires **reasoning**. On professional documents that demand contextual understanding, domain expertise, and multi-step reasoning, similarity search misses what is relevant but not similar, and returns what is similar but not relevant.
45
+
46
+ Inspired by AlphaGo, **[PageIndex](https://vectify.ai/pageindex)** replaces the vector index with a **hierarchical tree index** and lets an LLM **reason** its way through it, the way a human expert turns to and reads the right section of a long report. Retrieval happens in two steps:
47
+
48
+ 1. **Index**: generate a **tree-structure index** for each document
49
+ 2. **Retrieve**: agentically **search that tree** with LLM reasoning
50
+
51
+ <div align="center">
52
+ <a href="https://pageindex.ai/blog/pageindex-intro" target="_blank" title="The PageIndex Framework">
53
+ <img src="https://docs.pageindex.ai/images/cookbook/vectorless-rag.png" width="70%">
54
+ </a>
55
+ </div>
56
+
57
+
58
+ ### TL;DR
59
+
60
+ <blockquote>PageIndex is a <b>vectorless</b>, <b>reasoning-based RAG</b> engine that <b>mirrors how humans read</b>, delivering <b>traceable</b>, <b>explainable</b>, and <b>context-aware</b> retrieval, with <b>no vector DBs</b> or <b>chunking</b>.</blockquote>
61
+
62
+ ### Compare with Vector RAG
63
+
64
+ | | Vector RAG | **PageIndex** |
65
+ |---|---|---|
66
+ | **Index** | vector index | tree index |
67
+ | **Retrieval** | semantic similarity search | LLM reasoning over the tree |
68
+ | **Result** | opaque, “vibe retrieval” | traceable to explicit references |
69
+ | **Context** | query embedding only | full context: conversation history, domain knowledge, etc. |
70
+
71
+ It is ideal for financial reports, legal documents, regulatory filings, technical manuals, medical literature, academic textbooks, and any other long, complex professional document.
72
+
73
+
74
+
75
+
76
+ # Quickstart
77
+
78
+ ```bash
79
+ pip install -U pageindex
80
+ ```
81
+
82
+
83
+ ```python
84
+ import os
85
+ from pageindex import PageIndexClient
86
+
87
+ os.environ["OPENAI_API_KEY"] = "your-openai-key"
88
+
89
+ client = PageIndexClient(
90
+ index="gpt-6-luna", # model to build the tree index
91
+ chat="gpt-6-sol", # model to search the tree
92
+ )
93
+ doc_id = client.submit_document("report.pdf")["doc_id"]
94
+
95
+ answer = client.chat("What was the 2023 operating margin?", doc_id=doc_id)
96
+ print(answer)
97
+ ```
98
+
99
+ ### Model Recommendations
100
+
101
+ - **`index=`: a basic model is sufficient.** The tree structure itself is extracted from the document layout without an LLM; the index model only summarizes and refines it, which a basic model does well.
102
+ - **`chat=`: use the best model you can afford.** The chat model searches the tree to retrieve information. See [Query cost and accuracy](#query-cost-and-accuracy).
103
+
104
+ ### [Use PageIndex through the SDK client →](https://docs.pageindex.ai/getting-started)
105
+
106
+ Configure other models, streaming, multi-document search, citations, and more.
107
+
108
+ ### [Integrate PageIndex with your own agent →](https://docs.pageindex.ai/sdk/agents)
109
+
110
+ Drop PageIndex tools into the OpenAI Agents SDK, the Claude Agent SDK, or any other framework.
111
+
112
+
113
+ # Benchmarks
114
+
115
+ ### Local indexing cost and time
116
+
117
+ Building a tree locally runs **about $0.001 per page** with `gpt-5.6-luna` as the index model, so a 1,000-page textbook costs a little over a dollar and a few minutes, once, and every later question reuses it. PageIndex is designed not to rely heavily on the model used at index time, so in our experiments a basic model does not hurt quality.
118
+
119
+ <div align="center">
120
+ <picture>
121
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/index-cost-dark.png">
122
+ <img src="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/index-cost-light.png" width="75%" alt="Indexing cost against document length, log-log, for nine PDFs from 9 to 1,098 pages. Points track a $0.0011-per-page reference line; the spread around it is text density, not length.">
123
+ </picture>
124
+ </div>
125
+
126
+ Indexing time also scales predictably with document length. In the same local setup, the benchmark documents (9 to 1,098 pages) finished in roughly **13 seconds to 4.5 minutes**.
127
+
128
+ <div align="center">
129
+ <picture>
130
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/index-time-dark.png">
131
+ <img src="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/index-time-light.png" width="75%" alt="Indexing time against document length, log-log, for nine PDFs from 9 to 1,098 pages. The measured indexing times range from about 13 seconds to 4.5 minutes and increase predictably with document length.">
132
+ </picture>
133
+ </div>
134
+
135
+
136
+
137
+ ### Query cost and accuracy
138
+
139
+ [**PageIndex-OSS-Benchmark**](https://github.com/VectifyAI/PageIndex-OSS-Benchmark) measures exactly the setup in the quickstart above (`PageIndexClient()` in local mode, flash indexing, no OCR) on 62 lookup questions over 34 PDFs (1,945 pages) drawn from [MMLongBench-Doc-V2](https://github.com/VectifyAI/MMLongBench-Doc-V2). Every question's answer is a fact stated in running text, so a wrong answer is a **retrieval or reading failure**, not a reasoning one.
140
+
141
+ <div align="center">
142
+ <picture>
143
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/results-dark.png">
144
+ <img src="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/results-light.png" width="75%" alt="Accuracy against average cost per question. Each model forms a near-vertical reasoning-effort ladder; moving between models costs an order of magnitude a step.">
145
+ </picture>
146
+ </div>
147
+
148
+
149
+ Full results, data, and the runner are in the [benchmark repo](https://github.com/VectifyAI/PageIndex-OSS-Benchmark).
150
+
151
+ ### Cost per query vs. native PDF input
152
+
153
+ The alternative to retrieval is handing the model the whole PDF on every question. That cost grows with the document; PageIndex's does not, because it reads only the nodes its reasoning reaches. On documents where both routes return the same answer, native PDF input costs **2.1× more at 52 pages and 16.6× more at 420** (`gpt-5.6-sol`, prompt caching excluded) — and at 805 pages the document no longer fits in the context window at all.
154
+
155
+ <div align="center">
156
+ <picture>
157
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/query-cost-dark.png">
158
+ <img src="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/query-cost-light.png" width="75%" alt="Cost per query relative to PageIndex retrieval, for five PDFs from 52 to 805 pages. Passing the PDF natively costs 2.1x, 3.4x, 7.8x, and 16.6x more at 52, 85, 198, and 420 pages; at 805 pages it exceeds the model's context window.">
159
+ </picture>
160
+ </div>
161
+
162
+ ### Leading accuracy on FinanceBench
163
+
164
+ PageIndex reached a state-of-the-art [**98.7% accuracy**](https://vectify.ai/blog/Mafin2.5) on [FinanceBench](https://arxiv.org/abs/2311.11944) (financial document QA benchmark), vastly outperforming vector-based RAG.
165
+
166
+ <div align="center">
167
+ <a href="https://github.com/VectifyAI/Mafin2.5-FinanceBench">
168
+ <picture>
169
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/financebench-dark.png">
170
+ <img src="https://raw.githubusercontent.com/VectifyAI/PageIndex/main/assets/financebench-light.png" width="70%" alt="FinanceBench accuracy: PageIndex 98.7%, vector RAG 50%.">
171
+ </picture>
172
+ </a>
173
+ </div>
174
+
175
+ Explore the full FinanceBench [evaluation results](https://github.com/VectifyAI/Mafin2.5-FinanceBench) and the [blog post](https://vectify.ai/blog/Mafin2.5).
176
+
177
+
178
+ # PageIndex Cloud
179
+
180
+ The open-source version is ideal for text-heavy PDFs and local workflows. With **PageIndex Cloud, document indexing and storage run in the cloud**: PageIndex handles parsing, OCR, image understanding, tree-index construction, and managed storage for you. The chat and retrieval layer remains **compatible with your model**, so you can search the cloud-hosted index using the model provider your application already uses.
181
+
182
+ Moving indexing and storage from Local to Cloud only requires a [PageIndex API key](https://developer.pageindex.ai/):
183
+
184
+ ```python
185
+ import os
186
+ from pageindex import PageIndexClient
187
+
188
+ os.environ["PAGEINDEX_API_KEY"] = "your-pageindex-key"
189
+ os.environ["OPENAI_API_KEY"] = "your-openai-key"
190
+
191
+ client = PageIndexClient(
192
+ index="cloud", # build and store the index in PageIndex Cloud
193
+ chat="gpt-6-sol", # use your preferred compatible model for chat
194
+ )
195
+ doc_id = client.submit_document("report.pdf", wait=True)["doc_id"]
196
+ print(client.chat("What was the 2023 operating margin?", doc_id=doc_id))
197
+ ```
198
+
199
+ | | **Local** | **Cloud** |
200
+ |---|---|---|
201
+ | Handles | Text-based PDFs | Text-based, scanned, and image-rich documents |
202
+ | Indexing | On your machine | Managed by PageIndex |
203
+ | Storage | Local directory | Cloud storage |
204
+ | Citations | Page-level | Block-level |
205
+ | OCR & image understanding | — | ✓ |
206
+ | [Metadata](https://docs.pageindex.ai/sdk/documents#metadata-cloud) | — | ✓ |
207
+ | [Folders](https://docs.pageindex.ai/sdk/documents#folders-cloud) | — | ✓ |
208
+ | [MCP server](https://docs.pageindex.ai/mcp) | — | ✓ |
209
+
210
+ ### More About PageIndex Cloud
211
+
212
+ - [Scale PageIndex to Millions of Documents](https://pageindex.ai/blog/pageindex-filesystem): **PageIndex File System** is a Cloud-only, file-level tree indexing layer that lets PageIndex reason over an entire corpus, not just a single document.
213
+
214
+ ### Ready to Try It?
215
+
216
+ - Get a [PageIndex API key](https://developer.pageindex.ai/)
217
+ - Read the [PageIndex Cloud documentation](https://docs.pageindex.ai/)
218
+
219
+ For dedicated deployment (VPC or on-premises), [contact us](https://pageindex.ai/contact) or [book a demo](https://calendly.com/pageindex/meet).
220
+
221
+
222
+
223
+ ---
224
+
225
+ # ⭐ Support Us
226
+
227
+ Leave us a star 🌟 if you like our project. Thank you!
228
+
229
+ <p>
230
+ <img src="https://github.com/user-attachments/assets/eae4ff38-48ae-4a7c-b19f-eab81201d794" width="80%">
231
+ </p>
232
+
233
+ Please cite this work as:
234
+ ```
235
+ Mingtian Zhang, Yu Tang and PageIndex Team,
236
+ "PageIndex: Next-Generation Vectorless, Reasoning-based RAG",
237
+ PageIndex Blog, Sep 2025.
238
+ ```
239
+
240
+ <details>
241
+ <summary>Or use the BibTeX citation.</summary>
242
+
243
+ ```bibtex
244
+ @article{zhang2025pageindex,
245
+ author = {Mingtian Zhang and Yu Tang and PageIndex Team},
246
+ title = {PageIndex: Next-Generation Vectorless, Reasoning-based RAG},
247
+ journal = {PageIndex Blog},
248
+ year = {2025},
249
+ month = {September},
250
+ note = {https://pageindex.ai/blog/pageindex-intro},
251
+ }
252
+ ```
253
+ </details>
254
+
255
+
256
+
257
+
258
+ ---
259
+
260
+ © 2026 [PageIndex AI](https://pageindex.ai)
261
+
262
+ <img width="288" height="80" alt="pageindex-wordmark-animated-288-warm" src="https://github.com/user-attachments/assets/e1c677f2-b590-4ffc-859d-e8cc7d794bdf" />
@@ -0,0 +1,54 @@
1
+ """PageIndex SDK."""
2
+ from typing import TYPE_CHECKING as _TYPE_CHECKING
3
+
4
+ from .chat_stream import ChatStream
5
+ from .client import PageIndexClient, PageIndexCloudClient, PageIndexLocalClient
6
+ from .errors import PageIndexAPIError
7
+ from .types import (ChatConfig, ChatProcessOptions, CloudIndexConfig,
8
+ IndexConfig, LocalIndexConfig)
9
+
10
+ if _TYPE_CHECKING:
11
+ from .flash import page_index_flash
12
+ from .imaging import highlight_region
13
+ from .page_index_classic import page_index, page_index_main
14
+ from .page_index_md import md_to_tree
15
+ from .tree_optimize import optimize_tree
16
+
17
+ __all__ = [
18
+ "PageIndexClient", "PageIndexCloudClient", "PageIndexLocalClient",
19
+ "PageIndexAPIError",
20
+ "IndexConfig", "CloudIndexConfig", "LocalIndexConfig", "ChatConfig",
21
+ "ChatProcessOptions", "ChatStream",
22
+ "page_index", "page_index_main", "page_index_flash",
23
+ "optimize_tree", "md_to_tree", "highlight_region",
24
+ ]
25
+
26
+ _LAZY = {
27
+ "highlight_region": ".imaging",
28
+ "page_index_flash": ".flash",
29
+ "optimize_tree": ".tree_optimize",
30
+ "md_to_tree": ".page_index_md",
31
+ }
32
+ _SUBMODULES = {"agent_tools", "chat_stream", "client", "cloud_api", "errors",
33
+ "flash", "imaging", "integrations", "local_api", "local_chat",
34
+ "local_store", "mcp_bridge", "page_index_classic",
35
+ "page_index_md", "tree_optimize", "types", "utils"}
36
+
37
+
38
+ def __getattr__(name):
39
+ if name.startswith("_"):
40
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
41
+ import importlib
42
+ if name in _SUBMODULES:
43
+ return importlib.import_module(f".{name}", __name__)
44
+ module = importlib.import_module(_LAZY.get(name, ".page_index_classic"), __name__)
45
+ try:
46
+ value = getattr(module, name)
47
+ except AttributeError:
48
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from None
49
+ globals()[name] = value
50
+ return value
51
+
52
+
53
+ def __dir__():
54
+ return sorted(set(globals()) | set(__all__) | _SUBMODULES)
@@ -0,0 +1,10 @@
1
+ """Installed-package version, shared by every surface that reports it upstream."""
2
+ from __future__ import annotations
3
+
4
+
5
+ def sdk_version() -> str:
6
+ try:
7
+ from importlib.metadata import version
8
+ return version("pageindex")
9
+ except Exception:
10
+ return "0.0.0"