readanydoc 0.2.0__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 (286) hide show
  1. {readanydoc-0.2.0 → readanydoc-0.4.0}/CHANGELOG.md +44 -0
  2. {readanydoc-0.2.0 → readanydoc-0.4.0}/PKG-INFO +15 -3
  3. {readanydoc-0.2.0 → readanydoc-0.4.0}/README.md +14 -2
  4. {readanydoc-0.2.0 → readanydoc-0.4.0}/docs/research/README.md +4 -4
  5. {readanydoc-0.2.0 → readanydoc-0.4.0}/plugins/readanydoc/.claude-plugin/plugin.json +1 -1
  6. {readanydoc-0.2.0 → readanydoc-0.4.0}/plugins/readanydoc/.mcp.json +1 -1
  7. {readanydoc-0.2.0 → readanydoc-0.4.0}/pyproject.toml +1 -1
  8. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/__init__.py +1 -1
  9. readanydoc-0.4.0/readanydoc/bench/__init__.py +107 -0
  10. readanydoc-0.4.0/readanydoc/bench/catalog.py +227 -0
  11. readanydoc-0.4.0/readanydoc/bench/fetch.py +100 -0
  12. readanydoc-0.4.0/readanydoc/bench/grade.py +206 -0
  13. readanydoc-0.4.0/readanydoc/bench/report.py +159 -0
  14. readanydoc-0.4.0/readanydoc/bench/runner.py +139 -0
  15. readanydoc-0.4.0/readanydoc/bench/systems.py +222 -0
  16. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/cli.py +85 -0
  17. readanydoc-0.4.0/readanydoc/data/model_limits.json +1 -0
  18. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/library.py +20 -8
  19. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/mcp_server.py +39 -4
  20. readanydoc-0.4.0/readanydoc/model_limits.py +154 -0
  21. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/anthropic_api.py +2 -0
  22. readanydoc-0.4.0/readanydoc/tasks/coded.py +218 -0
  23. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/tasks/extract.py +435 -54
  24. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/tasks/llm.py +94 -4
  25. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/tasks/reply_schema.py +54 -9
  26. readanydoc-0.4.0/readanydoc/textlayer.py +165 -0
  27. readanydoc-0.4.0/readanydoc/trace.py +78 -0
  28. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tasks/test_extract_robust.py +43 -12
  29. readanydoc-0.4.0/tests/tasks/test_reply_schema.py +418 -0
  30. readanydoc-0.4.0/tests/test_bench_suite.py +102 -0
  31. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_mcp_server.py +2 -2
  32. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_robust_fallbacks.py +6 -6
  33. readanydoc-0.2.0/tests/tasks/test_reply_schema.py +0 -211
  34. {readanydoc-0.2.0 → readanydoc-0.4.0}/.gitignore +0 -0
  35. {readanydoc-0.2.0 → readanydoc-0.4.0}/LICENSE +0 -0
  36. {readanydoc-0.2.0 → readanydoc-0.4.0}/examples/showcase/README.md +0 -0
  37. {readanydoc-0.2.0 → readanydoc-0.4.0}/plugins/readanydoc/.claude-plugin/icon.png +0 -0
  38. {readanydoc-0.2.0 → readanydoc-0.4.0}/plugins/readanydoc/README.md +0 -0
  39. {readanydoc-0.2.0 → readanydoc-0.4.0}/plugins/readanydoc/skills/read-documents/SKILL.md +0 -0
  40. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/api/__init__.py +0 -0
  41. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/api/__main__.py +0 -0
  42. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/api/app.py +0 -0
  43. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/api/config.py +0 -0
  44. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/api/contracts.py +0 -0
  45. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/api/errors.py +0 -0
  46. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/api/inputs.py +0 -0
  47. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/api/schemas.py +0 -0
  48. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/api/service.py +0 -0
  49. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/api/webhooks.py +0 -0
  50. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/api/worker.py +0 -0
  51. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/cvsafe.py +0 -0
  52. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/__init__.py +0 -0
  53. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/common.py +0 -0
  54. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/docx_reader.py +0 -0
  55. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/errors.py +0 -0
  56. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/heic.py +0 -0
  57. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/legacy.py +0 -0
  58. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/msg.py +0 -0
  59. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/pdf.py +0 -0
  60. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/pptx_reader.py +0 -0
  61. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/prepare.py +0 -0
  62. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/sheets.py +0 -0
  63. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/sniff.py +0 -0
  64. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/intake/text.py +0 -0
  65. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/integrations/__init__.py +0 -0
  66. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/integrations/langchain.py +0 -0
  67. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/integrations/llamaindex.py +0 -0
  68. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/layout/__init__.py +0 -0
  69. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/layout/base.py +0 -0
  70. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/layout/cached.py +0 -0
  71. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/layout/claude.py +0 -0
  72. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/layout/onnx.py +0 -0
  73. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/localmodels.py +0 -0
  74. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/model/__init__.py +0 -0
  75. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/model/document.py +0 -0
  76. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/modelspec.py +0 -0
  77. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/paths.py +0 -0
  78. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/__init__.py +0 -0
  79. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/assemble.py +0 -0
  80. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/assembly/__init__.py +0 -0
  81. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/assembly/annotations.py +0 -0
  82. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/assembly/furniture.py +0 -0
  83. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/assembly/headings.py +0 -0
  84. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/assembly/paragraphs.py +0 -0
  85. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/assembly/tables.py +0 -0
  86. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/base.py +0 -0
  87. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/checks/__init__.py +0 -0
  88. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/checks/common.py +0 -0
  89. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/checks/complete.py +0 -0
  90. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/checks/flags.py +0 -0
  91. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/checks/gridrepair.py +0 -0
  92. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/checks/htmlgrid.py +0 -0
  93. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/checks/numbers.py +0 -0
  94. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/checks/reread.py +0 -0
  95. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/common.py +0 -0
  96. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/figures/__init__.py +0 -0
  97. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/figures/layout_pictures.py +0 -0
  98. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/figures/locate.py +0 -0
  99. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/forms/__init__.py +0 -0
  100. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/forms/acroform.py +0 -0
  101. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/forms/checkbox.py +0 -0
  102. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/forms/fillable.py +0 -0
  103. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/forms/grid.py +0 -0
  104. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/forms/lines.py +0 -0
  105. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/forms/locate.py +0 -0
  106. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/forms/region.py +0 -0
  107. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/forms/rules.py +0 -0
  108. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/ground.py +0 -0
  109. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/grounding/__init__.py +0 -0
  110. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/grounding/align.py +0 -0
  111. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/grounding/confidence.py +0 -0
  112. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/grounding/ocr.py +0 -0
  113. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/grounding/sources.py +0 -0
  114. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/grounding/tables.py +0 -0
  115. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/grounding/tokens.py +0 -0
  116. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/intake.py +0 -0
  117. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/layout.py +0 -0
  118. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/mdblocks.py +0 -0
  119. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/read.py +0 -0
  120. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/__init__.py +0 -0
  121. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/budget.py +0 -0
  122. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/effort_route.py +0 -0
  123. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/escalate.py +0 -0
  124. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/evidence.py +0 -0
  125. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/form_prefetch.py +0 -0
  126. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/formulas.py +0 -0
  127. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/fusion.py +0 -0
  128. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/handwriting.py +0 -0
  129. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/robust.py +0 -0
  130. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/select.py +0 -0
  131. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/strips.py +0 -0
  132. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/tables.py +0 -0
  133. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/zoom.py +0 -0
  134. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/zoom_gate.py +0 -0
  135. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/zoom_regions.py +0 -0
  136. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/reading/zoom_schedule.py +0 -0
  137. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/regions/__init__.py +0 -0
  138. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/regions/assemble.py +0 -0
  139. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/regions/complete.py +0 -0
  140. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/regions/crops.py +0 -0
  141. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/regions/fields.py +0 -0
  142. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/regions/formevidence.py +0 -0
  143. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/regions/forms.py +0 -0
  144. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/regions/furniture.py +0 -0
  145. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/regions/match.py +0 -0
  146. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/regions/structure.py +0 -0
  147. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/regions/tables.py +0 -0
  148. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/request.py +0 -0
  149. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/shape.py +0 -0
  150. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/shaping/__init__.py +0 -0
  151. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/shaping/agentic.py +0 -0
  152. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/shaping/chunking.py +0 -0
  153. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/shaping/embed.py +0 -0
  154. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/shaping/merge.py +0 -0
  155. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/shaping/options.py +0 -0
  156. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/shaping/page_range.py +0 -0
  157. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/shaping/response.py +0 -0
  158. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/shaping/searchable.py +0 -0
  159. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/shaping/summarize.py +0 -0
  160. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/shaping/tables.py +0 -0
  161. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/tables/__init__.py +0 -0
  162. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/tables/evidence.py +0 -0
  163. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/tables/hygiene.py +0 -0
  164. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/tables/prefetch.py +0 -0
  165. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/tables/reread.py +0 -0
  166. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/triage.py +0 -0
  167. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/typing/__init__.py +0 -0
  168. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/typing/layout.py +0 -0
  169. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/typing/markup.py +0 -0
  170. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/pipeline/verify.py +0 -0
  171. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/profiles.py +0 -0
  172. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/__init__.py +0 -0
  173. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/anthropic_batch.py +0 -0
  174. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/base.py +0 -0
  175. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/batch_mode.py +0 -0
  176. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/cached.py +0 -0
  177. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/claude_cli.py +0 -0
  178. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/crop_cache.py +0 -0
  179. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/live_cache.py +0 -0
  180. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/ocr_words.py +0 -0
  181. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/openai_compatible.py +0 -0
  182. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/prompts.py +0 -0
  183. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/sizing.py +0 -0
  184. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/readers/usage.py +0 -0
  185. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/serialize/__init__.py +0 -0
  186. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/serialize/citations.py +0 -0
  187. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/serialize/reducto.py +0 -0
  188. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/star.py +0 -0
  189. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/store/__init__.py +0 -0
  190. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/store/cleanup.py +0 -0
  191. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/store/db.py +0 -0
  192. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/store/files.py +0 -0
  193. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/store/jobs.py +0 -0
  194. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/tasks/__init__.py +0 -0
  195. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/tasks/classify.py +0 -0
  196. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/tasks/common.py +0 -0
  197. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/tasks/detect.py +0 -0
  198. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/tasks/edit.py +0 -0
  199. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/tasks/extract_extras.py +0 -0
  200. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/tasks/field_report.py +0 -0
  201. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/tasks/schema.py +0 -0
  202. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/tasks/split.py +0 -0
  203. {readanydoc-0.2.0 → readanydoc-0.4.0}/readanydoc/textnorm.py +0 -0
  204. {readanydoc-0.2.0 → readanydoc-0.4.0}/research/README.md +0 -0
  205. {readanydoc-0.2.0 → readanydoc-0.4.0}/research/benchmarks/README.md +0 -0
  206. {readanydoc-0.2.0 → readanydoc-0.4.0}/results/README.md +0 -0
  207. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/__init__.py +0 -0
  208. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/api/__init__.py +0 -0
  209. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/api/conftest.py +0 -0
  210. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/api/sdk_check.py +0 -0
  211. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/api/test_auth.py +0 -0
  212. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/api/test_cleanup.py +0 -0
  213. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/api/test_config_defaults.py +0 -0
  214. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/api/test_contract.py +0 -0
  215. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/api/test_e2e.py +0 -0
  216. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/api/test_jobs.py +0 -0
  217. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/api/test_sdk.py +0 -0
  218. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/api/test_webhooks.py +0 -0
  219. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/assembly/__init__.py +0 -0
  220. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/assembly/evaluate.py +0 -0
  221. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/assembly/synth.py +0 -0
  222. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/assembly/test_assembly.py +0 -0
  223. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/assembly/test_real_documents.py +0 -0
  224. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/checks/__init__.py +0 -0
  225. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/checks/test_checks_stage.py +0 -0
  226. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/checks/test_complete.py +0 -0
  227. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/checks/test_htmlgrid.py +0 -0
  228. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/checks/test_numbers.py +0 -0
  229. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/conftest.py +0 -0
  230. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/cost/__init__.py +0 -0
  231. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/cost/test_r3b_cost.py +0 -0
  232. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/figures/__init__.py +0 -0
  233. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/figures/test_figures.py +0 -0
  234. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/forms/__init__.py +0 -0
  235. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/forms/test_fillable.py +0 -0
  236. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/forms/test_grid.py +0 -0
  237. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/forms/test_lines_crops.py +0 -0
  238. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/forms/test_rules.py +0 -0
  239. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/grounding/__init__.py +0 -0
  240. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/grounding/test_grounding.py +0 -0
  241. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/intake/__init__.py +0 -0
  242. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/intake/test_intake.py +0 -0
  243. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/judge/__init__.py +0 -0
  244. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/judge/test_judge.py +0 -0
  245. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/reading/__init__.py +0 -0
  246. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/reading/test_handwriting_route.py +0 -0
  247. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/reading/test_live_profile.py +0 -0
  248. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/reading/test_reading_pipeline.py +0 -0
  249. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/reading/test_reading_units.py +0 -0
  250. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/reading/test_robustness.py +0 -0
  251. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/regions/__init__.py +0 -0
  252. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/regions/test_fields.py +0 -0
  253. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/regions/test_furniture.py +0 -0
  254. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/regions/test_regions.py +0 -0
  255. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/shaping/__init__.py +0 -0
  256. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/shaping/test_chunking.py +0 -0
  257. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/shaping/test_round2_options.py +0 -0
  258. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/shaping/test_tables.py +0 -0
  259. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tables/__init__.py +0 -0
  260. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tables/test_tables_round2.py +0 -0
  261. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tasks/__init__.py +0 -0
  262. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tasks/conftest.py +0 -0
  263. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tasks/live_notes.md +0 -0
  264. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tasks/live_smoke.py +0 -0
  265. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tasks/test_edit.py +0 -0
  266. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tasks/test_extract.py +0 -0
  267. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tasks/test_extract_extras.py +0 -0
  268. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tasks/test_llm.py +0 -0
  269. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tasks/test_review.py +0 -0
  270. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tasks/test_schema.py +0 -0
  271. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/tasks/test_split_classify.py +0 -0
  272. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_bench.py +0 -0
  273. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_engine_final.py +0 -0
  274. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_integrations.py +0 -0
  275. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_library.py +0 -0
  276. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_localmodels.py +0 -0
  277. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_model.py +0 -0
  278. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_pipeline.py +0 -0
  279. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_readers.py +0 -0
  280. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_serializer.py +0 -0
  281. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_star.py +0 -0
  282. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_ws4_ocr_prep.py +0 -0
  283. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_ws4_speed_batch.py +0 -0
  284. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/test_zoom_vote.py +0 -0
  285. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/typing/__init__.py +0 -0
  286. {readanydoc-0.2.0 → readanydoc-0.4.0}/tests/typing/test_typing.py +0 -0
@@ -1,5 +1,49 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0 (2026-11-19)
4
+
5
+ Test it yourself: compare ReadAnyDoc with other systems on public test sets or your own documents.
6
+
7
+ - `readanydoc bench`: compare ReadAnyDoc with Reducto, a plain model call or its own other modes, on 8 public test
8
+ sets (invoices, receipts, quarterly reports, credit agreements, research papers, resumes, result tables, long
9
+ reports) or on your own documents, with your own keys. Cost estimate and confirmation before spending, a budget
10
+ cap, resumable runs, scoring by code against answer keys, and an HTML report with every system's citation boxes on
11
+ the page. Also as MCP tools (`list_test_sets`, `run_test`) and in Python (`readanydoc.bench`).
12
+
13
+ ## 0.3.0 (2026-11-19)
14
+
15
+ Every extraction call is enforced by the API, whatever the schema's size, and reads one cached copy of the
16
+ document; citations point where a person checking a value would look; and a cheaper one-stage mode.
17
+
18
+ - Enforced output at any size. A schema the API refuses as one structured-output call is asked in one fixed answer
19
+ format (`{"values": [{"code", "item", "value"}]}`, codes from your schema's own fields), the same in every call,
20
+ and turned back into your exact shape. No call is ever made just to fix the shape.
21
+ - The document is cached within a run: after the first group of fields, every group reads it at a tenth of the
22
+ price. Nothing is reused between runs.
23
+ - Page parts are sized in tokens: `part_tokens` (default 30,000, capped by the model's own limit; `extract(...,
24
+ part_tokens=...)`, `settings.part_tokens`, MCP `part_tokens`). Measured on a 43-page 10-Q: 30,000 kept the
25
+ accuracy of small parts at lower cost; one 43-page part lost a third of the values.
26
+ - Model limits (context, output, price jump, prices) come from a snapshot of LiteLLM's public model list, about
27
+ 4,300 models, or an OpenAI-compatible server's `/models`; your own file in `READANYDOC_MODEL_LIMITS` overrides
28
+ them. An unknown model is an error naming `part_tokens`, never a guess. The output limit is the model's own.
29
+ - One log line per run with every setting chosen (`readanydoc` logger, `extract settings: {...}`), and
30
+ `READANYDOC_TRACE=<file.jsonl>`: one line per model call (tokens, cache reads and writes, cost, seconds, why the
31
+ call was made, the reply) and per decision.
32
+ - A value stated once for a whole table or page (a unit, "in thousands", a period in a heading) is written on every
33
+ item it covers; of two copies of the same list item, the less complete one is dropped; names are copied in full.
34
+ - Citations: the table the model read each row from is kept across page parts; worked-out values (a period from a
35
+ column heading, a scale from "in millions", a code from a name) are boxed on the printed words they come from;
36
+ a category chosen from your schema's list is never boxed on the same word elsewhere; a number is matched only as
37
+ a whole number; a short value printed in several places is not boxed at a guess. On a 10-Q, numbers boxed on the
38
+ right row: 94% (Reducto 81%); category boxes on the cover page: 128 to 0.
39
+ - `extract(..., parse=False)` (MCP `parse_first=false`): one stage, off by default. The model reads the file itself
40
+ (PDF, scans, images, Office files) and citations come from the PDF's own words or local OCR, with no model. About
41
+ half the cost and 2.5 times faster on a 43-page 10-Q, but less accurate (102-110 values against 99-129) and with
42
+ 3-4 times fewer citations.
43
+ - A value the document does not give stays null, also for a required field: never an invented value.
44
+
45
+ Full research record: `docs/research/extraction.md`.
46
+
3
47
  ## 0.2.0 (2026-11-18)
4
48
 
5
49
  Extraction costs what the answer costs again, and stays reliable on schemas of any size. Breaking: the
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: readanydoc
3
- Version: 0.2.0
3
+ Version: 0.4.0
4
4
  Summary: Document parsing and extraction with vision models: an open engine around Claude (or any model), with a Reducto-compatible API
5
5
  Project-URL: Homepage, https://arpitpatel25.github.io/ReadAnyDoc/
6
6
  Project-URL: Repository, https://github.com/arpitpatel25/ReadAnyDoc
@@ -224,6 +224,17 @@ from readanydoc.integrations.llamaindex import ReadAnyDocReader # pip install
224
224
 
225
225
  One Markdown document per page with its page number. [Guide](https://arpitpatel25.github.io/ReadAnyDoc/docs/guides/integrations/).
226
226
 
227
+ ### Test it against what you use now
228
+
229
+ ```bash
230
+ readanydoc bench list # invoices, receipts, filings, contracts, resumes...
231
+ readanydoc bench run invoices --systems readanydoc,plain:claude-haiku-5-5,reducto --limit 10
232
+ readanydoc bench mine ./my_docs --schema schema.json --answers ./answer_keys # your own documents
233
+ ```
234
+
235
+ Your own keys, a cost estimate before anything runs, scoring by code against answer keys, and an HTML report with
236
+ every system's citations on the page. [Guide](https://arpitpatel25.github.io/ReadAnyDoc/docs/guides/testing/).
237
+
227
238
  ## How it works
228
239
 
229
240
  Each page goes through a fixed sequence of stages (`readanydoc/pipeline/`): intake (file type, pages), triage
@@ -246,8 +257,9 @@ independent evidence. Design decisions and their reasons: [docs/decisions.md](ht
246
257
  | | |
247
258
  |---|---|
248
259
  | [BENCHMARKS.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/BENCHMARKS.md) | full results against Reducto, cost, method, caveats; per-document scores in [results/](https://github.com/arpitpatel25/ReadAnyDoc/tree/main/results/) |
249
- | [docs/story.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/docs/story.md) | why this exists, the bet behind it, what we learned |
250
- | [docs/research/journey.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/docs/research/journey.md) | the full research record: every stage, every experiment, what was kept and dropped and why |
260
+ | [docs/story.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/docs/story.md) | the whole story: the idea, how we measured, the parser, the extractor, two stages or one, what we learned |
261
+ | [docs/research/journey.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/docs/research/journey.md) | the parser research record: every stage, every experiment, what was kept and dropped and why |
262
+ | [docs/research/extraction.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/docs/research/extraction.md) | the extraction research record: structured output, caching, page parts, citations, one stage |
251
263
  | [docs/decisions.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/docs/decisions.md) | every design decision with its reason |
252
264
  | [Documentation](https://arpitpatel25.github.io/ReadAnyDoc/docs/) | guides, API reference, configuration, migrating from Reducto |
253
265
  | [examples/](https://github.com/arpitpatel25/ReadAnyDoc/tree/main/examples/) | runnable scripts |
@@ -178,6 +178,17 @@ from readanydoc.integrations.llamaindex import ReadAnyDocReader # pip install
178
178
 
179
179
  One Markdown document per page with its page number. [Guide](https://arpitpatel25.github.io/ReadAnyDoc/docs/guides/integrations/).
180
180
 
181
+ ### Test it against what you use now
182
+
183
+ ```bash
184
+ readanydoc bench list # invoices, receipts, filings, contracts, resumes...
185
+ readanydoc bench run invoices --systems readanydoc,plain:claude-haiku-5-5,reducto --limit 10
186
+ readanydoc bench mine ./my_docs --schema schema.json --answers ./answer_keys # your own documents
187
+ ```
188
+
189
+ Your own keys, a cost estimate before anything runs, scoring by code against answer keys, and an HTML report with
190
+ every system's citations on the page. [Guide](https://arpitpatel25.github.io/ReadAnyDoc/docs/guides/testing/).
191
+
181
192
  ## How it works
182
193
 
183
194
  Each page goes through a fixed sequence of stages (`readanydoc/pipeline/`): intake (file type, pages), triage
@@ -200,8 +211,9 @@ independent evidence. Design decisions and their reasons: [docs/decisions.md](ht
200
211
  | | |
201
212
  |---|---|
202
213
  | [BENCHMARKS.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/BENCHMARKS.md) | full results against Reducto, cost, method, caveats; per-document scores in [results/](https://github.com/arpitpatel25/ReadAnyDoc/tree/main/results/) |
203
- | [docs/story.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/docs/story.md) | why this exists, the bet behind it, what we learned |
204
- | [docs/research/journey.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/docs/research/journey.md) | the full research record: every stage, every experiment, what was kept and dropped and why |
214
+ | [docs/story.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/docs/story.md) | the whole story: the idea, how we measured, the parser, the extractor, two stages or one, what we learned |
215
+ | [docs/research/journey.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/docs/research/journey.md) | the parser research record: every stage, every experiment, what was kept and dropped and why |
216
+ | [docs/research/extraction.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/docs/research/extraction.md) | the extraction research record: structured output, caching, page parts, citations, one stage |
205
217
  | [docs/decisions.md](https://github.com/arpitpatel25/ReadAnyDoc/blob/main/docs/decisions.md) | every design decision with its reason |
206
218
  | [Documentation](https://arpitpatel25.github.io/ReadAnyDoc/docs/) | guides, API reference, configuration, migrating from Reducto |
207
219
  | [examples/](https://github.com/arpitpatel25/ReadAnyDoc/tree/main/examples/) | runnable scripts |
@@ -4,8 +4,9 @@ How ReadAnyDoc was built and why it looks the way it does.
4
4
 
5
5
  | Page | What it answers |
6
6
  |---|---|
7
- | [../story.md](../story.md) | The short story: the bet, what we found, what we chose to build |
8
- | [journey.md](journey.md) | The full record, stage by stage (11-14 November 2026): every idea tested, kept or dropped and why, the sample results the full benchmarks overturned, and the 272-entry experiment ledger (Appendix D) |
7
+ | [../story.md](../story.md) | The whole story in one page: the idea, how we measured, the parser, the extractor, two stages or one, where we stand, what we learned |
8
+ | [journey.md](journey.md) | The full record, stage by stage (11-14 November 2026): every idea tested, kept or dropped and why, the sample results the full benchmarks overturned, and the 272-entry experiment ledger (Appendix C) |
9
+ | [extraction.md](extraction.md) | Extraction research (15-19 November 2026): structured output at any schema size, cost and caching, page-part size, citations, one stage against two stages, with every measurement |
9
10
  | [../../BENCHMARKS.md](../resources/benchmarks.md) | The final results against Reducto r-1, with method and caveats |
10
11
  | [../../results/](https://github.com/arpitpatel25/ReadAnyDoc/tree/main/results) | Per-document scores behind those results |
11
12
  | [../decisions.md](../decisions.md) | Every design decision with its reason |
@@ -16,5 +17,4 @@ Where to look in `journey.md` for common questions:
16
17
  - *Why no AI judge?* Section 16 and lesson 2.
17
18
  - *Why do some early results disagree with the final ones?* Section 23 and Appendix A (every reversal).
18
19
  - *What exactly does the shipped engine do?* Appendix B.
19
- - *What did it cost to build and measure?* Appendix C.
20
- - *Was idea X tried?* Appendix D, the experiment ledger.
20
+ - *Was idea X tried?* Appendix C, the experiment ledger.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "readanydoc",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Parse PDFs, scans, photos and Office files into Markdown, and extract typed fields with a citation for every value. Open-source alternative to Reducto, on your own Anthropic key.",
5
5
  "author": {
6
6
  "name": "Unmute"
@@ -2,7 +2,7 @@
2
2
  "mcpServers": {
3
3
  "readanydoc": {
4
4
  "command": "uvx",
5
- "args": ["--from", "git+https://github.com/arpitpatel25/ReadAnyDoc@5cf3b10e80d37ddafa27ddc676099b5e89c40fe1", "readanydoc", "mcp"]
5
+ "args": ["--from", "git+https://github.com/arpitpatel25/ReadAnyDoc@587d4511ace2142756fe488ee7ec3b349d8690c1", "readanydoc", "mcp"]
6
6
  }
7
7
  }
8
8
  }
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "readanydoc"
3
- version = "0.2.0"
3
+ version = "0.4.0"
4
4
  description = "Document parsing and extraction with vision models: an open engine around Claude (or any model), with a Reducto-compatible API"
5
5
  readme = "README.md"
6
6
  authors = [{ name = "readanydoc contributors" }]
@@ -3,7 +3,7 @@
3
3
  Use it as a library (``readanydoc.parse``, ``readanydoc.extract``) or run the server (``readanydoc serve``).
4
4
  """
5
5
 
6
- __version__ = "0.2.0"
6
+ __version__ = "0.4.0"
7
7
 
8
8
  from .library import (Block, BoundingBox, Citation, ExtractResult, ParseResult, Usage, # noqa: E402
9
9
  extract, parse)
@@ -0,0 +1,107 @@
1
+ """Test ReadAnyDoc against other systems on public test sets or on your own documents.
2
+
3
+ readanydoc bench list
4
+ readanydoc bench run invoices --systems readanydoc,plain:claude-haiku-5-5,reducto --limit 10
5
+ readanydoc bench mine ./my_docs --schema schema.json [--answers ./answer_keys]
6
+
7
+ Every system uses your own key (``ANTHROPIC_API_KEY``, ``REDUCTO_API_KEY``). A run first shows what it will cost
8
+ roughly and asks before spending; ``budget_usd`` stops it from starting more documents once that much is spent.
9
+ Scoring is done by code against the answer key, never by a model. The report (``report.html``) has a summary per
10
+ system, every document, and a page viewer with each system's citation boxes.
11
+
12
+ Python:
13
+
14
+ from readanydoc import bench
15
+ bench.sets() # the catalogue
16
+ plan = bench.prepare("invoices", ["readanydoc", "reducto"], limit=10)
17
+ plan["estimate"] # documents, pages, rough cost per system
18
+ bench.run_prepared(plan, budget_usd=2) # -> summary, with plan["out"]/report.html
19
+ """
20
+
21
+ from __future__ import annotations
22
+
23
+ import json
24
+ import time
25
+ from pathlib import Path
26
+ from typing import Optional
27
+
28
+ from . import catalog, report, runner, systems
29
+
30
+ DEFAULT_SYSTEMS = ["readanydoc", "plain:claude-haiku-5-5"]
31
+
32
+
33
+ def sets() -> list[dict]:
34
+ return [s.info() for s in catalog.SETS.values()]
35
+
36
+
37
+ def _out(name: str, out: Optional[str]) -> str:
38
+ if out:
39
+ return out
40
+ return str(Path.cwd() / "readanydoc-bench" / f"{name}-{time.strftime('%Y%m%d-%H%M%S')}")
41
+
42
+
43
+ def prepare(set_id: Optional[str] = None, system_specs: Optional[list[str]] = None, limit: Optional[int] = None,
44
+ out: Optional[str] = None, folder: Optional[str] = None, schema: Optional[str] = None,
45
+ answers: Optional[str] = None, instructions: Optional[str] = None) -> dict:
46
+ """Download the documents and work out the plan and its rough cost; nothing is sent to any model."""
47
+ specs = system_specs or DEFAULT_SYSTEMS
48
+ syss = [systems.make(s) for s in specs]
49
+ if folder:
50
+ if not schema:
51
+ raise ValueError("your own documents need a schema (a JSON Schema file)")
52
+ cases = catalog.own_documents(folder, schema, answers, instructions)
53
+ title, info = f"Your documents: {Path(folder).name}", None
54
+ else:
55
+ ts = catalog.get(set_id or "")
56
+ cases = ts.load(limit if limit is not None else ts.default_limit)
57
+ title, info = ts.title, ts.info()
58
+ if limit and folder:
59
+ cases = cases[:limit]
60
+ not_ready = {s.name: why for s in syss if (why := s.ready())}
61
+ return {"title": title, "info": info, "cases": cases, "systems": syss, "out": _out(set_id or "mine", out),
62
+ "estimate": runner.estimate(cases, syss), "not_ready": not_ready,
63
+ "request": {"set_id": set_id, "systems": specs, "limit": limit, "folder": folder, "schema": schema,
64
+ "answers": answers, "instructions": instructions}}
65
+
66
+
67
+ def run_prepared(plan: dict, budget_usd: Optional[float] = None, workers: int = 4, fresh: bool = False,
68
+ on_done=None) -> dict:
69
+ syss = [s for s in plan["systems"] if s.name not in plan["not_ready"]]
70
+ Path(plan["out"]).mkdir(parents=True, exist_ok=True)
71
+ (Path(plan["out"]) / "plan.json").write_text(json.dumps(plan["request"], indent=1))
72
+ if not syss:
73
+ raise RuntimeError("no system can run: " + "; ".join(f"{k}: {v}" for k, v in plan["not_ready"].items()))
74
+ summary = runner.run(plan["cases"], syss, plan["out"], budget_usd, workers, fresh, on_done)
75
+ summary["skipped_systems"] = plan["not_ready"]
76
+ summary["report"] = report.write(plan["out"], plan["cases"], [s.name for s in syss], plan["title"], summary,
77
+ plan["info"])
78
+ report.write_json(plan["out"], summary)
79
+ return summary
80
+
81
+
82
+ def rescore(out: str) -> dict:
83
+ """Score saved results again (after a grader or answer-key fix) and rewrite the report; no model is called."""
84
+ req = json.loads((Path(out) / "plan.json").read_text())
85
+ plan = prepare(req["set_id"], req["systems"], req["limit"], out, folder=req["folder"], schema=req["schema"],
86
+ answers=req["answers"], instructions=req["instructions"])
87
+ names = []
88
+ for s in plan["systems"]:
89
+ for c in plan["cases"]:
90
+ p = Path(out) / s.name.replace(":", "_") / f"{c['id']}.json"
91
+ if not p.exists():
92
+ continue
93
+ rec = json.loads(p.read_text())
94
+ if c.get("gold") is not None:
95
+ rec["score"] = runner.grade.score(c["gold"], rec.get("data"), c.get("alternatives"), c.get("only"))
96
+ rec["citation_check"] = runner.citation_check(c, rec)
97
+ p.write_text(json.dumps(rec, default=str))
98
+ if s.name not in names:
99
+ names.append(s.name)
100
+ ran = [s for s in plan["systems"] if s.name in names]
101
+ summary = runner.summarize(out, plan["cases"], ran)
102
+ summary["report"] = report.write(out, plan["cases"], names, plan["title"], summary, plan["info"])
103
+ report.write_json(out, summary)
104
+ return summary
105
+
106
+
107
+ __all__ = ["rescore", "sets", "prepare", "run_prepared", "catalog", "systems", "runner", "report", "DEFAULT_SYSTEMS"]
@@ -0,0 +1,227 @@
1
+ """Public test sets, by document type. Each is downloaded on first use into the ReadAnyDoc cache (nothing is
2
+ redistributed with ReadAnyDoc) and pinned to a fixed revision so that a score can be reproduced.
3
+
4
+ Every set has an answer key written by people or generated with the documents, and is scored by code
5
+ (``grade.py``), never by a model. Check a set's licence before you use it: some allow research use only.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import json
11
+ import re
12
+ from dataclasses import dataclass, field
13
+ from pathlib import Path
14
+ from typing import Any, Callable, Optional
15
+
16
+ from . import fetch
17
+
18
+ EB_REPO, EB_REV = "ContextualAI/extract-bench", "ca817638852a23bb17ca9aaeb82ccdd29e9af9ca"
19
+ INV_REPO = "drew-ipp/invoice-extraction-benchmark"
20
+ LX_REPO = "micro1-inc/longextract-bench-50"
21
+ CORD_REPO = "naver-clova-ix/cord-v2"
22
+
23
+
24
+ @dataclass
25
+ class TestSet:
26
+ id: str
27
+ title: str
28
+ doc_type: str
29
+ what: str
30
+ documents: int
31
+ licence: str
32
+ source: str
33
+ default_limit: int
34
+ load: Callable[[Optional[int]], list[dict]]
35
+ note: str = ""
36
+ tags: list[str] = field(default_factory=list)
37
+
38
+ def info(self) -> dict:
39
+ return {"id": self.id, "title": self.title, "document_type": self.doc_type, "what_it_tests": self.what,
40
+ "documents": self.documents, "licence": self.licence, "source": self.source,
41
+ "default_sample": self.default_limit, "note": self.note}
42
+
43
+
44
+ # ---------------------------------------------------------------- ExtractBench (Contextual AI, MIT)
45
+
46
+ def _eb_strip(n: Any) -> Any:
47
+ if isinstance(n, dict):
48
+ return {k: _eb_strip(v) for k, v in n.items() if k != "evaluation_config"}
49
+ if isinstance(n, list):
50
+ return [_eb_strip(v) for v in n]
51
+ return n
52
+
53
+
54
+ def _extractbench(folder: str) -> Callable[[Optional[int]], list[dict]]:
55
+ def load(limit: Optional[int]) -> list[dict]:
56
+ tree = fetch.github_tree(EB_REPO, EB_REV)
57
+ base = f"dataset/{folder}/"
58
+ schema_path = next(p for p in tree if p.startswith(base) and p.endswith("-schema.json"))
59
+ schema = json.loads(fetch.github_file(EB_REPO, EB_REV, schema_path).read_text())
60
+ if "schema_definition" in schema and "type" not in schema:
61
+ schema = schema["schema_definition"]
62
+ pdfs = sorted(p for p in tree if p.startswith(base + "pdf+gold/") and p.endswith(".pdf")
63
+ and p[:-4] + ".gold.json" in tree)
64
+ out = []
65
+ for p in pdfs[:limit] if limit else pdfs:
66
+ stem = Path(p).stem
67
+ out.append({"id": re.sub(r"[^\w.-]+", "_", stem), "file": str(fetch.github_file(EB_REPO, EB_REV, p)),
68
+ "schema": _eb_strip(schema),
69
+ "gold": json.loads(fetch.github_file(EB_REPO, EB_REV, p[:-4] + ".gold.json").read_text())})
70
+ return out
71
+ return load
72
+
73
+
74
+ # ---------------------------------------------------------------- invoices (InvoiceParser Pro, CC-BY-4.0)
75
+
76
+ INVOICE_SCHEMA = {
77
+ "type": "object",
78
+ "properties": {
79
+ "document_type": {"type": "string", "enum": ["invoice", "credit_note", "other"],
80
+ "description": "other for a supplier statement"},
81
+ "vendor_name": {"type": "string", "description": "the company that issued the document"},
82
+ "invoice_number": {"type": "string"},
83
+ "invoice_date": {"type": "string", "description": "YYYY-MM-DD"},
84
+ "due_date": {"type": ["string", "null"], "description": "YYYY-MM-DD"},
85
+ "currency": {"type": "string", "description": "ISO 4217 code, e.g. USD"},
86
+ "subtotal": {"type": ["number", "null"]},
87
+ "tax": {"type": ["number", "null"]},
88
+ "total": {"type": "number", "description": "the amount payable"},
89
+ "lines": {"type": "array", "items": {"type": "object", "properties": {
90
+ "description": {"type": "string"}, "amount": {"type": "number", "description": "the line total"}}}},
91
+ },
92
+ }
93
+
94
+
95
+ def _invoices(limit: Optional[int]) -> list[dict]:
96
+ meta = [json.loads(l) for l in fetch.hf_file(INV_REPO, "corpus/v1/metadata.jsonl").read_text().splitlines()
97
+ if l.strip()]
98
+ if limit: # a spread of every category before more of any one
99
+ by: dict[str, list] = {}
100
+ for m in meta:
101
+ by.setdefault(m["category"], []).append(m)
102
+ mixed, i = [], 0
103
+ while len(mixed) < min(limit, len(meta)):
104
+ for c in sorted(by):
105
+ if i < len(by[c]) and len(mixed) < limit:
106
+ mixed.append(by[c][i])
107
+ i += 1
108
+ meta = mixed
109
+ out = []
110
+ for m in meta:
111
+ exp = m["expected"]
112
+ gold = {k: exp.get(k) for k in INVOICE_SCHEMA["properties"] if k != "lines"}
113
+ gold["lines"] = [{"description": l.get("description"), "amount": l.get("amount")} for l in exp.get("lines") or []]
114
+ alts = {f"lines[{i}].amount": list(l.get("alt_amounts") or []) for i, l in enumerate(exp.get("lines") or [])}
115
+ if exp.get("document_type") == "credit_note": # the set's rule: credit notes compare magnitudes
116
+ for k in ("subtotal", "tax", "total"):
117
+ if isinstance(gold.get(k), (int, float)):
118
+ alts.setdefault(k, []).append(-gold[k])
119
+ for i, l in enumerate(gold["lines"]):
120
+ if isinstance(l.get("amount"), (int, float)):
121
+ alts[f"lines[{i}].amount"].append(-l["amount"])
122
+ scored = [s for s in m.get("scored") or [] if s in INVOICE_SCHEMA["properties"]] + \
123
+ (["lines"] if "line_items" in (m.get("scored") or []) else [])
124
+ out.append({"id": m["doc_id"], "file": str(fetch.hf_file(INV_REPO, "corpus/v1/" + m["file_name"])),
125
+ "schema": INVOICE_SCHEMA, "gold": gold, "alternatives": alts, "only": scored or None,
126
+ "meta": {"category": m["category"], "difficulty": m.get("difficulty")}})
127
+ return out
128
+
129
+
130
+ # ---------------------------------------------------------------- receipts (CORD v2, CC-BY-4.0)
131
+
132
+ RECEIPT_SCHEMA = {
133
+ "type": "object",
134
+ "properties": {
135
+ "items": {"type": "array", "items": {"type": "object", "properties": {
136
+ "name": {"type": "string"}, "quantity": {"type": ["string", "null"]},
137
+ "price": {"type": ["string", "null"], "description": "the line price as printed"}}}},
138
+ "subtotal": {"type": ["string", "null"], "description": "as printed"},
139
+ "tax": {"type": ["string", "null"], "description": "as printed"},
140
+ "total": {"type": ["string", "null"], "description": "the total paid, as printed"},
141
+ },
142
+ }
143
+
144
+
145
+ def _cord(limit: Optional[int]) -> list[dict]:
146
+ rows = fetch.hf_rows(CORD_REPO, "test", limit or 100)
147
+ out = []
148
+ for i, r in rows:
149
+ gt = json.loads(r["ground_truth"]).get("gt_parse", {})
150
+ menu = gt.get("menu") or []
151
+ menu = [menu] if isinstance(menu, dict) else menu
152
+ sub, tot = gt.get("sub_total") or {}, gt.get("total") or {}
153
+ gold = {"items": [{"name": m.get("nm"), "quantity": m.get("cnt"), "price": m.get("price")} for m in menu
154
+ if isinstance(m, dict)],
155
+ "subtotal": sub.get("subtotal_price") if isinstance(sub, dict) else None,
156
+ "tax": sub.get("tax_price") if isinstance(sub, dict) else None,
157
+ "total": tot.get("total_price") if isinstance(tot, dict) else None}
158
+ out.append({"id": f"cord_test_{i:03d}", "file": str(fetch.hf_row_image(CORD_REPO, "test", i, r["image"])),
159
+ "schema": RECEIPT_SCHEMA, "gold": gold})
160
+ return out
161
+
162
+
163
+ # ---------------------------------------------------------------- long documents (LongExtract, CC-BY-4.0)
164
+
165
+ def _longextract(limit: Optional[int]) -> list[dict]:
166
+ tree = fetch.hf_tree(LX_REPO)
167
+ docs = sorted((size, path.rsplit("/", 1)[0]) for path, size in tree.items() if path.endswith("/document.pdf"))
168
+ out = []
169
+ for _, d in docs[:limit] if limit else docs: # shortest first: the longest has 11,622 pages
170
+ out.append({"id": re.sub(r"[^\w.-]+", "_", d)[:80], "file": str(fetch.hf_file(LX_REPO, d + "/document.pdf")),
171
+ "schema": json.loads(fetch.hf_file(LX_REPO, d + "/schema.json").read_text()),
172
+ "gold": json.loads(fetch.hf_file(LX_REPO, d + "/ground_truth.json").read_text())})
173
+ return out
174
+
175
+
176
+ SETS: dict[str, TestSet] = {s.id: s for s in [
177
+ TestSet("invoices", "Invoices", "invoices and credit notes",
178
+ "digital PDFs in US/UK/EU/ZA formats, 6 currencies, VAT, credit notes, multi-page, freight, scans, phone "
179
+ "photos, handwritten invoice books, several invoices in one file",
180
+ 181, "CC-BY-4.0 (made by InvoiceParser Pro, a vendor; synthetic documents)",
181
+ f"https://huggingface.co/datasets/{INV_REPO}", 20, _invoices,
182
+ note="Our field-by-field grader with the set's rules (credit notes compare magnitudes), not its own scorer."),
183
+ TestSet("receipts", "Restaurant and shop receipts (CORD)", "receipts", "photographed Indonesian receipts: items, "
184
+ "quantities, prices, subtotal, tax, total", 100, "CC-BY-4.0", f"https://huggingface.co/datasets/{CORD_REPO}",
185
+ 20, _cord),
186
+ TestSet("financial-reports", "Quarterly and annual reports (10-Q, 10-K)", "financial filings",
187
+ "income statement, balance sheet and cash-flow values with periods, units and scales, by segment",
188
+ 7, "MIT (ExtractBench)", f"https://github.com/{EB_REPO}", 2, _extractbench("finance/10kq"),
189
+ note="Long documents (40-100+ pages); a schema the API cannot enforce in one call."),
190
+ TestSet("credit-agreements", "Credit agreements", "legal contracts", "parties, facilities, amounts, rates and key "
191
+ "terms from corporate credit agreements", 10, "MIT (ExtractBench)", f"https://github.com/{EB_REPO}", 2,
192
+ _extractbench("finance/credit_agreement"), note="Very long documents (often 100+ pages)."),
193
+ TestSet("research-papers", "Research papers", "academic papers", "title, authors, affiliations, abstract, "
194
+ "identifiers and references", 6, "MIT (ExtractBench)", f"https://github.com/{EB_REPO}", 3,
195
+ _extractbench("academic/research")),
196
+ TestSet("resumes", "Resumes", "resumes and CVs", "experience, education, skills and certifications", 7,
197
+ "MIT (ExtractBench)", f"https://github.com/{EB_REPO}", 3, _extractbench("hiring/resume")),
198
+ TestSet("sports-results", "Championship results", "result tables", "rankings, times, records and athlete details "
199
+ "from long result tables", 5, "MIT (ExtractBench)", f"https://github.com/{EB_REPO}", 2,
200
+ _extractbench("sport/swimming")),
201
+ TestSet("long-documents", "Long government and business reports (LongExtract)", "long reports",
202
+ "every row of long repeated tables across many pages (statistics, budgets, utilisation reports)", 50,
203
+ "CC-BY-4.0", f"https://huggingface.co/datasets/{LX_REPO}", 2, _longextract,
204
+ note="Some documents run to thousands of pages; samples take the shortest first."),
205
+ ]}
206
+
207
+
208
+ def get(set_id: str) -> TestSet:
209
+ if set_id not in SETS:
210
+ raise KeyError(f"unknown test set {set_id!r}; known: {', '.join(SETS)}")
211
+ return SETS[set_id]
212
+
213
+
214
+ def own_documents(folder: str, schema_path: str, answers: Optional[str] = None,
215
+ instructions: Optional[str] = None) -> list[dict]:
216
+ """Your own documents: every file in ``folder`` against one schema; an answer key per document is optional
217
+ (``<answers>/<file stem>.json``). Without answer keys, systems are compared on cost, time and agreement."""
218
+ schema = json.loads(Path(schema_path).read_text())
219
+ out = []
220
+ for f in sorted(Path(folder).iterdir()):
221
+ if f.is_file() and not f.name.startswith("."):
222
+ gold = None
223
+ if answers and (Path(answers) / (f.stem + ".json")).exists():
224
+ gold = json.loads((Path(answers) / (f.stem + ".json")).read_text())
225
+ out.append({"id": re.sub(r"[^\w.-]+", "_", f.stem), "file": str(f), "schema": schema, "gold": gold,
226
+ **({"instructions": instructions} if instructions else {})})
227
+ return out
@@ -0,0 +1,100 @@
1
+ """Downloads for the test sets, cached on disk (``<ReadAnyDoc cache>/bench``). Public sources only, no keys."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import os
7
+ import threading
8
+ from pathlib import Path
9
+ from typing import Optional
10
+ from urllib.parse import quote
11
+
12
+ import httpx
13
+
14
+ _lock = threading.Lock()
15
+
16
+
17
+ def root() -> Path:
18
+ from .. import paths
19
+ d = Path(os.environ.get("READANYDOC_BENCH_DATA") or paths.cache_dir() / "bench")
20
+ d.mkdir(parents=True, exist_ok=True)
21
+ return d
22
+
23
+
24
+ def _get(url: str, dest: Path) -> Path:
25
+ if dest.exists() and dest.stat().st_size > 0:
26
+ return dest
27
+ dest.parent.mkdir(parents=True, exist_ok=True)
28
+ tmp = dest.with_suffix(dest.suffix + ".part")
29
+ with httpx.stream("GET", url, follow_redirects=True, timeout=300) as r:
30
+ r.raise_for_status()
31
+ with open(tmp, "wb") as f:
32
+ for chunk in r.iter_bytes():
33
+ f.write(chunk)
34
+ tmp.replace(dest)
35
+ return dest
36
+
37
+
38
+ def _json(url: str, dest: Path) -> object:
39
+ return json.loads(_get(url, dest).read_text())
40
+
41
+
42
+ def github_tree(repo: str, rev: str) -> set[str]:
43
+ d = _json(f"https://api.github.com/repos/{repo}/git/trees/{rev}?recursive=1",
44
+ root() / "github" / repo.replace("/", "__") / rev / "_tree.json")
45
+ return {t["path"] for t in d.get("tree", []) if t.get("type") == "blob"} # type: ignore[union-attr]
46
+
47
+
48
+ def github_file(repo: str, rev: str, path: str) -> Path:
49
+ return _get(f"https://raw.githubusercontent.com/{repo}/{rev}/{quote(path)}",
50
+ root() / "github" / repo.replace("/", "__") / rev / path)
51
+
52
+
53
+ def hf_tree(repo: str, rev: str = "main") -> dict[str, int]:
54
+ d = _json(f"https://huggingface.co/api/datasets/{repo}/tree/{rev}?recursive=1",
55
+ root() / "hf" / repo.replace("/", "__") / rev / "_tree.json")
56
+ return {t["path"]: t.get("size", 0) for t in d if t.get("type") == "file"} # type: ignore[union-attr]
57
+
58
+
59
+ def hf_file(repo: str, path: str, rev: str = "main") -> Path:
60
+ return _get(f"https://huggingface.co/datasets/{repo}/resolve/{rev}/{quote(path)}",
61
+ root() / "hf" / repo.replace("/", "__") / rev / path)
62
+
63
+
64
+ def hf_rows(repo: str, split: str, n: int, config: str = "default") -> list[tuple[int, dict]]:
65
+ """Rows 0..n-1 of a dataset split through the Hugging Face dataset viewer (no full download)."""
66
+ cache = root() / "hf" / repo.replace("/", "__") / "rows" / f"{config}_{split}_{n}.json"
67
+ if cache.exists():
68
+ return [(r["row_idx"], r["row"]) for r in json.loads(cache.read_text())]
69
+ rows: list = []
70
+ for off in range(0, n, 100):
71
+ url = (f"https://datasets-server.huggingface.co/rows?dataset={quote(repo, safe='')}&config={config}"
72
+ f"&split={split}&offset={off}&length={min(100, n - off)}")
73
+ r = httpx.get(url, timeout=120)
74
+ r.raise_for_status()
75
+ rows += r.json().get("rows", [])
76
+ cache.parent.mkdir(parents=True, exist_ok=True)
77
+ cache.write_text(json.dumps(rows))
78
+ return [(r["row_idx"], r["row"]) for r in rows]
79
+
80
+
81
+ def hf_row_image(repo: str, split: str, idx: int, image: Optional[dict]) -> Path:
82
+ dest = root() / "hf" / repo.replace("/", "__") / "images" / split / f"{idx:05d}.jpg"
83
+ if dest.exists():
84
+ return dest
85
+ src = (image or {}).get("src")
86
+ if not src:
87
+ raise RuntimeError(f"{repo} {split} row {idx} has no image")
88
+ try:
89
+ return _get(src, dest)
90
+ except httpx.HTTPStatusError: # a signed viewer link that has expired: ask for the row again
91
+ fresh = hf_rows_one(repo, split, idx)
92
+ return _get(fresh["image"]["src"], dest)
93
+
94
+
95
+ def hf_rows_one(repo: str, split: str, idx: int, config: str = "default") -> dict:
96
+ url = (f"https://datasets-server.huggingface.co/rows?dataset={quote(repo, safe='')}&config={config}"
97
+ f"&split={split}&offset={idx}&length=1")
98
+ r = httpx.get(url, timeout=120)
99
+ r.raise_for_status()
100
+ return r.json()["rows"][0]["row"]