readanydoc 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- readanydoc-0.1.0/.gitignore +9 -0
- readanydoc-0.1.0/CHANGELOG.md +15 -0
- readanydoc-0.1.0/LICENSE +202 -0
- readanydoc-0.1.0/PKG-INFO +206 -0
- readanydoc-0.1.0/README.md +167 -0
- readanydoc-0.1.0/docs/research/README.md +20 -0
- readanydoc-0.1.0/pyproject.toml +66 -0
- readanydoc-0.1.0/readanydoc/__init__.py +12 -0
- readanydoc-0.1.0/readanydoc/api/__init__.py +6 -0
- readanydoc-0.1.0/readanydoc/api/__main__.py +26 -0
- readanydoc-0.1.0/readanydoc/api/app.py +300 -0
- readanydoc-0.1.0/readanydoc/api/config.py +72 -0
- readanydoc-0.1.0/readanydoc/api/contracts.py +139 -0
- readanydoc-0.1.0/readanydoc/api/errors.py +86 -0
- readanydoc-0.1.0/readanydoc/api/inputs.py +142 -0
- readanydoc-0.1.0/readanydoc/api/schemas.py +372 -0
- readanydoc-0.1.0/readanydoc/api/service.py +426 -0
- readanydoc-0.1.0/readanydoc/api/webhooks.py +90 -0
- readanydoc-0.1.0/readanydoc/api/worker.py +79 -0
- readanydoc-0.1.0/readanydoc/cli.py +140 -0
- readanydoc-0.1.0/readanydoc/cvsafe.py +60 -0
- readanydoc-0.1.0/readanydoc/intake/__init__.py +12 -0
- readanydoc-0.1.0/readanydoc/intake/common.py +94 -0
- readanydoc-0.1.0/readanydoc/intake/docx_reader.py +356 -0
- readanydoc-0.1.0/readanydoc/intake/errors.py +71 -0
- readanydoc-0.1.0/readanydoc/intake/heic.py +66 -0
- readanydoc-0.1.0/readanydoc/intake/legacy.py +144 -0
- readanydoc-0.1.0/readanydoc/intake/msg.py +123 -0
- readanydoc-0.1.0/readanydoc/intake/pdf.py +100 -0
- readanydoc-0.1.0/readanydoc/intake/pptx_reader.py +114 -0
- readanydoc-0.1.0/readanydoc/intake/prepare.py +510 -0
- readanydoc-0.1.0/readanydoc/intake/sheets.py +425 -0
- readanydoc-0.1.0/readanydoc/intake/sniff.py +96 -0
- readanydoc-0.1.0/readanydoc/intake/text.py +103 -0
- readanydoc-0.1.0/readanydoc/layout/__init__.py +51 -0
- readanydoc-0.1.0/readanydoc/layout/base.py +51 -0
- readanydoc-0.1.0/readanydoc/layout/cached.py +61 -0
- readanydoc-0.1.0/readanydoc/layout/claude.py +101 -0
- readanydoc-0.1.0/readanydoc/layout/onnx.py +285 -0
- readanydoc-0.1.0/readanydoc/library.py +296 -0
- readanydoc-0.1.0/readanydoc/localmodels.py +83 -0
- readanydoc-0.1.0/readanydoc/model/__init__.py +42 -0
- readanydoc-0.1.0/readanydoc/model/document.py +280 -0
- readanydoc-0.1.0/readanydoc/modelspec.py +79 -0
- readanydoc-0.1.0/readanydoc/paths.py +53 -0
- readanydoc-0.1.0/readanydoc/pipeline/__init__.py +23 -0
- readanydoc-0.1.0/readanydoc/pipeline/assemble.py +70 -0
- readanydoc-0.1.0/readanydoc/pipeline/assembly/__init__.py +1 -0
- readanydoc-0.1.0/readanydoc/pipeline/assembly/annotations.py +69 -0
- readanydoc-0.1.0/readanydoc/pipeline/assembly/furniture.py +255 -0
- readanydoc-0.1.0/readanydoc/pipeline/assembly/headings.py +261 -0
- readanydoc-0.1.0/readanydoc/pipeline/assembly/paragraphs.py +88 -0
- readanydoc-0.1.0/readanydoc/pipeline/assembly/tables.py +320 -0
- readanydoc-0.1.0/readanydoc/pipeline/base.py +178 -0
- readanydoc-0.1.0/readanydoc/pipeline/checks/__init__.py +97 -0
- readanydoc-0.1.0/readanydoc/pipeline/checks/common.py +66 -0
- readanydoc-0.1.0/readanydoc/pipeline/checks/complete.py +426 -0
- readanydoc-0.1.0/readanydoc/pipeline/checks/flags.py +62 -0
- readanydoc-0.1.0/readanydoc/pipeline/checks/gridrepair.py +128 -0
- readanydoc-0.1.0/readanydoc/pipeline/checks/htmlgrid.py +288 -0
- readanydoc-0.1.0/readanydoc/pipeline/checks/numbers.py +318 -0
- readanydoc-0.1.0/readanydoc/pipeline/checks/reread.py +92 -0
- readanydoc-0.1.0/readanydoc/pipeline/common.py +38 -0
- readanydoc-0.1.0/readanydoc/pipeline/figures/__init__.py +530 -0
- readanydoc-0.1.0/readanydoc/pipeline/figures/layout_pictures.py +153 -0
- readanydoc-0.1.0/readanydoc/pipeline/figures/locate.py +212 -0
- readanydoc-0.1.0/readanydoc/pipeline/forms/__init__.py +99 -0
- readanydoc-0.1.0/readanydoc/pipeline/forms/acroform.py +80 -0
- readanydoc-0.1.0/readanydoc/pipeline/forms/checkbox.py +136 -0
- readanydoc-0.1.0/readanydoc/pipeline/forms/fillable.py +303 -0
- readanydoc-0.1.0/readanydoc/pipeline/forms/grid.py +293 -0
- readanydoc-0.1.0/readanydoc/pipeline/forms/lines.py +100 -0
- readanydoc-0.1.0/readanydoc/pipeline/forms/locate.py +135 -0
- readanydoc-0.1.0/readanydoc/pipeline/forms/region.py +159 -0
- readanydoc-0.1.0/readanydoc/pipeline/forms/rules.py +105 -0
- readanydoc-0.1.0/readanydoc/pipeline/ground.py +720 -0
- readanydoc-0.1.0/readanydoc/pipeline/grounding/__init__.py +1 -0
- readanydoc-0.1.0/readanydoc/pipeline/grounding/align.py +270 -0
- readanydoc-0.1.0/readanydoc/pipeline/grounding/confidence.py +66 -0
- readanydoc-0.1.0/readanydoc/pipeline/grounding/ocr.py +204 -0
- readanydoc-0.1.0/readanydoc/pipeline/grounding/sources.py +274 -0
- readanydoc-0.1.0/readanydoc/pipeline/grounding/tables.py +70 -0
- readanydoc-0.1.0/readanydoc/pipeline/grounding/tokens.py +165 -0
- readanydoc-0.1.0/readanydoc/pipeline/intake.py +286 -0
- readanydoc-0.1.0/readanydoc/pipeline/layout.py +63 -0
- readanydoc-0.1.0/readanydoc/pipeline/mdblocks.py +128 -0
- readanydoc-0.1.0/readanydoc/pipeline/read.py +925 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/__init__.py +7 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/budget.py +150 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/effort_route.py +49 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/escalate.py +71 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/evidence.py +101 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/form_prefetch.py +84 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/formulas.py +137 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/fusion.py +128 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/handwriting.py +133 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/robust.py +142 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/select.py +55 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/strips.py +129 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/tables.py +409 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/zoom.py +158 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/zoom_gate.py +91 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/zoom_regions.py +72 -0
- readanydoc-0.1.0/readanydoc/pipeline/reading/zoom_schedule.py +67 -0
- readanydoc-0.1.0/readanydoc/pipeline/regions/__init__.py +207 -0
- readanydoc-0.1.0/readanydoc/pipeline/regions/assemble.py +169 -0
- readanydoc-0.1.0/readanydoc/pipeline/regions/complete.py +103 -0
- readanydoc-0.1.0/readanydoc/pipeline/regions/crops.py +209 -0
- readanydoc-0.1.0/readanydoc/pipeline/regions/fields.py +580 -0
- readanydoc-0.1.0/readanydoc/pipeline/regions/formevidence.py +187 -0
- readanydoc-0.1.0/readanydoc/pipeline/regions/forms.py +114 -0
- readanydoc-0.1.0/readanydoc/pipeline/regions/furniture.py +614 -0
- readanydoc-0.1.0/readanydoc/pipeline/regions/match.py +162 -0
- readanydoc-0.1.0/readanydoc/pipeline/regions/structure.py +264 -0
- readanydoc-0.1.0/readanydoc/pipeline/regions/tables.py +164 -0
- readanydoc-0.1.0/readanydoc/pipeline/request.py +72 -0
- readanydoc-0.1.0/readanydoc/pipeline/shape.py +260 -0
- readanydoc-0.1.0/readanydoc/pipeline/shaping/__init__.py +0 -0
- readanydoc-0.1.0/readanydoc/pipeline/shaping/agentic.py +215 -0
- readanydoc-0.1.0/readanydoc/pipeline/shaping/chunking.py +339 -0
- readanydoc-0.1.0/readanydoc/pipeline/shaping/embed.py +82 -0
- readanydoc-0.1.0/readanydoc/pipeline/shaping/merge.py +89 -0
- readanydoc-0.1.0/readanydoc/pipeline/shaping/options.py +129 -0
- readanydoc-0.1.0/readanydoc/pipeline/shaping/page_range.py +49 -0
- readanydoc-0.1.0/readanydoc/pipeline/shaping/response.py +112 -0
- readanydoc-0.1.0/readanydoc/pipeline/shaping/searchable.py +248 -0
- readanydoc-0.1.0/readanydoc/pipeline/shaping/summarize.py +74 -0
- readanydoc-0.1.0/readanydoc/pipeline/shaping/tables.py +414 -0
- readanydoc-0.1.0/readanydoc/pipeline/tables/__init__.py +145 -0
- readanydoc-0.1.0/readanydoc/pipeline/tables/evidence.py +163 -0
- readanydoc-0.1.0/readanydoc/pipeline/tables/hygiene.py +151 -0
- readanydoc-0.1.0/readanydoc/pipeline/tables/prefetch.py +116 -0
- readanydoc-0.1.0/readanydoc/pipeline/tables/reread.py +462 -0
- readanydoc-0.1.0/readanydoc/pipeline/triage.py +188 -0
- readanydoc-0.1.0/readanydoc/pipeline/typing/__init__.py +13 -0
- readanydoc-0.1.0/readanydoc/pipeline/typing/layout.py +217 -0
- readanydoc-0.1.0/readanydoc/pipeline/typing/markup.py +190 -0
- readanydoc-0.1.0/readanydoc/pipeline/verify.py +287 -0
- readanydoc-0.1.0/readanydoc/profiles.py +115 -0
- readanydoc-0.1.0/readanydoc/readers/__init__.py +177 -0
- readanydoc-0.1.0/readanydoc/readers/anthropic_api.py +165 -0
- readanydoc-0.1.0/readanydoc/readers/anthropic_batch.py +191 -0
- readanydoc-0.1.0/readanydoc/readers/base.py +116 -0
- readanydoc-0.1.0/readanydoc/readers/batch_mode.py +28 -0
- readanydoc-0.1.0/readanydoc/readers/cached.py +109 -0
- readanydoc-0.1.0/readanydoc/readers/claude_cli.py +73 -0
- readanydoc-0.1.0/readanydoc/readers/crop_cache.py +75 -0
- readanydoc-0.1.0/readanydoc/readers/live_cache.py +88 -0
- readanydoc-0.1.0/readanydoc/readers/ocr_words.py +68 -0
- readanydoc-0.1.0/readanydoc/readers/openai_compatible.py +94 -0
- readanydoc-0.1.0/readanydoc/readers/prompts.py +112 -0
- readanydoc-0.1.0/readanydoc/readers/sizing.py +198 -0
- readanydoc-0.1.0/readanydoc/readers/usage.py +111 -0
- readanydoc-0.1.0/readanydoc/serialize/__init__.py +3 -0
- readanydoc-0.1.0/readanydoc/serialize/citations.py +134 -0
- readanydoc-0.1.0/readanydoc/serialize/reducto.py +120 -0
- readanydoc-0.1.0/readanydoc/store/__init__.py +8 -0
- readanydoc-0.1.0/readanydoc/store/cleanup.py +279 -0
- readanydoc-0.1.0/readanydoc/store/db.py +61 -0
- readanydoc-0.1.0/readanydoc/store/files.py +153 -0
- readanydoc-0.1.0/readanydoc/store/jobs.py +223 -0
- readanydoc-0.1.0/readanydoc/tasks/__init__.py +51 -0
- readanydoc-0.1.0/readanydoc/tasks/classify.py +137 -0
- readanydoc-0.1.0/readanydoc/tasks/common.py +223 -0
- readanydoc-0.1.0/readanydoc/tasks/detect.py +274 -0
- readanydoc-0.1.0/readanydoc/tasks/edit.py +1089 -0
- readanydoc-0.1.0/readanydoc/tasks/extract.py +1049 -0
- readanydoc-0.1.0/readanydoc/tasks/extract_extras.py +325 -0
- readanydoc-0.1.0/readanydoc/tasks/llm.py +477 -0
- readanydoc-0.1.0/readanydoc/tasks/schema.py +473 -0
- readanydoc-0.1.0/readanydoc/tasks/split.py +358 -0
- readanydoc-0.1.0/readanydoc/textnorm.py +78 -0
- readanydoc-0.1.0/research/README.md +23 -0
- readanydoc-0.1.0/research/benchmarks/README.md +18 -0
- readanydoc-0.1.0/results/README.md +17 -0
- readanydoc-0.1.0/tests/__init__.py +0 -0
- readanydoc-0.1.0/tests/api/__init__.py +0 -0
- readanydoc-0.1.0/tests/api/conftest.py +190 -0
- readanydoc-0.1.0/tests/api/sdk_check.py +141 -0
- readanydoc-0.1.0/tests/api/test_auth.py +45 -0
- readanydoc-0.1.0/tests/api/test_cleanup.py +237 -0
- readanydoc-0.1.0/tests/api/test_config_defaults.py +17 -0
- readanydoc-0.1.0/tests/api/test_contract.py +239 -0
- readanydoc-0.1.0/tests/api/test_e2e.py +286 -0
- readanydoc-0.1.0/tests/api/test_jobs.py +108 -0
- readanydoc-0.1.0/tests/api/test_sdk.py +73 -0
- readanydoc-0.1.0/tests/api/test_webhooks.py +90 -0
- readanydoc-0.1.0/tests/assembly/__init__.py +0 -0
- readanydoc-0.1.0/tests/assembly/evaluate.py +109 -0
- readanydoc-0.1.0/tests/assembly/synth.py +406 -0
- readanydoc-0.1.0/tests/assembly/test_assembly.py +267 -0
- readanydoc-0.1.0/tests/assembly/test_real_documents.py +171 -0
- readanydoc-0.1.0/tests/checks/__init__.py +0 -0
- readanydoc-0.1.0/tests/checks/test_checks_stage.py +175 -0
- readanydoc-0.1.0/tests/checks/test_complete.py +144 -0
- readanydoc-0.1.0/tests/checks/test_htmlgrid.py +90 -0
- readanydoc-0.1.0/tests/checks/test_numbers.py +72 -0
- readanydoc-0.1.0/tests/conftest.py +32 -0
- readanydoc-0.1.0/tests/cost/__init__.py +0 -0
- readanydoc-0.1.0/tests/cost/test_r3b_cost.py +348 -0
- readanydoc-0.1.0/tests/figures/__init__.py +0 -0
- readanydoc-0.1.0/tests/figures/test_figures.py +350 -0
- readanydoc-0.1.0/tests/forms/__init__.py +0 -0
- readanydoc-0.1.0/tests/forms/test_fillable.py +103 -0
- readanydoc-0.1.0/tests/forms/test_grid.py +73 -0
- readanydoc-0.1.0/tests/forms/test_lines_crops.py +154 -0
- readanydoc-0.1.0/tests/forms/test_rules.py +166 -0
- readanydoc-0.1.0/tests/grounding/__init__.py +0 -0
- readanydoc-0.1.0/tests/grounding/test_grounding.py +285 -0
- readanydoc-0.1.0/tests/intake/__init__.py +0 -0
- readanydoc-0.1.0/tests/intake/test_intake.py +618 -0
- readanydoc-0.1.0/tests/judge/__init__.py +0 -0
- readanydoc-0.1.0/tests/judge/test_judge.py +353 -0
- readanydoc-0.1.0/tests/reading/__init__.py +0 -0
- readanydoc-0.1.0/tests/reading/test_handwriting_route.py +195 -0
- readanydoc-0.1.0/tests/reading/test_live_profile.py +77 -0
- readanydoc-0.1.0/tests/reading/test_reading_pipeline.py +181 -0
- readanydoc-0.1.0/tests/reading/test_reading_units.py +408 -0
- readanydoc-0.1.0/tests/reading/test_robustness.py +149 -0
- readanydoc-0.1.0/tests/regions/__init__.py +0 -0
- readanydoc-0.1.0/tests/regions/test_fields.py +323 -0
- readanydoc-0.1.0/tests/regions/test_furniture.py +223 -0
- readanydoc-0.1.0/tests/regions/test_regions.py +316 -0
- readanydoc-0.1.0/tests/shaping/__init__.py +0 -0
- readanydoc-0.1.0/tests/shaping/test_chunking.py +208 -0
- readanydoc-0.1.0/tests/shaping/test_round2_options.py +293 -0
- readanydoc-0.1.0/tests/shaping/test_tables.py +111 -0
- readanydoc-0.1.0/tests/tables/__init__.py +0 -0
- readanydoc-0.1.0/tests/tables/test_tables_round2.py +333 -0
- readanydoc-0.1.0/tests/tasks/__init__.py +0 -0
- readanydoc-0.1.0/tests/tasks/conftest.py +157 -0
- readanydoc-0.1.0/tests/tasks/live_notes.md +986 -0
- readanydoc-0.1.0/tests/tasks/live_smoke.py +124 -0
- readanydoc-0.1.0/tests/tasks/test_edit.py +529 -0
- readanydoc-0.1.0/tests/tasks/test_extract.py +629 -0
- readanydoc-0.1.0/tests/tasks/test_extract_extras.py +215 -0
- readanydoc-0.1.0/tests/tasks/test_llm.py +199 -0
- readanydoc-0.1.0/tests/tasks/test_schema.py +261 -0
- readanydoc-0.1.0/tests/tasks/test_split_classify.py +302 -0
- readanydoc-0.1.0/tests/test_bench.py +52 -0
- readanydoc-0.1.0/tests/test_engine_final.py +197 -0
- readanydoc-0.1.0/tests/test_library.py +90 -0
- readanydoc-0.1.0/tests/test_localmodels.py +188 -0
- readanydoc-0.1.0/tests/test_model.py +62 -0
- readanydoc-0.1.0/tests/test_pipeline.py +234 -0
- readanydoc-0.1.0/tests/test_readers.py +150 -0
- readanydoc-0.1.0/tests/test_serializer.py +85 -0
- readanydoc-0.1.0/tests/test_ws4_ocr_prep.py +217 -0
- readanydoc-0.1.0/tests/test_ws4_speed_batch.py +214 -0
- readanydoc-0.1.0/tests/test_zoom_vote.py +75 -0
- readanydoc-0.1.0/tests/typing/__init__.py +0 -0
- readanydoc-0.1.0/tests/typing/test_typing.py +268 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (unreleased)
|
|
4
|
+
|
|
5
|
+
First public release.
|
|
6
|
+
|
|
7
|
+
- `readanydoc.parse` and `readanydoc.extract` as a Python library; `extract` takes a pydantic class or JSON Schema and
|
|
8
|
+
returns typed values with citations.
|
|
9
|
+
- Two modes: `engine` (default) and `model-only`, both on Claude Haiku 5.5 at high effort; handwritten pages go to
|
|
10
|
+
Claude Sonnet 5.5.
|
|
11
|
+
- Every model the pipeline uses can be chosen, with its effort and any provider request options. Anthropic, OpenAI
|
|
12
|
+
and OpenAI-compatible endpoints.
|
|
13
|
+
- Reducto-compatible HTTP server: parse, extract, split, classify, edit, async jobs, webhooks, citations.
|
|
14
|
+
- Benchmarks against Reducto r-1 on olmOCR-bench, OmniDocBench, RD-TableBench, FUNSD and long-document extraction
|
|
15
|
+
([BENCHMARKS.md](BENCHMARKS.md)).
|
readanydoc-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: readanydoc
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Document parsing and extraction with vision models: an open engine around Claude (or any model), with a Reducto-compatible API
|
|
5
|
+
Project-URL: Homepage, https://arpitpatel25.github.io/ReadAnyDoc/
|
|
6
|
+
Project-URL: Repository, https://github.com/arpitpatel25/ReadAnyDoc
|
|
7
|
+
Project-URL: Documentation, https://github.com/arpitpatel25/ReadAnyDoc#readme
|
|
8
|
+
Project-URL: Changelog, https://github.com/arpitpatel25/ReadAnyDoc/blob/main/CHANGELOG.md
|
|
9
|
+
Author: readanydoc contributors
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: claude,document-parsing,extraction,llm,ocr,pdf,reducto
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Text Processing
|
|
18
|
+
Requires-Python: <3.13,>=3.12
|
|
19
|
+
Requires-Dist: fastapi>=0.110
|
|
20
|
+
Requires-Dist: httpx>=0.27
|
|
21
|
+
Requires-Dist: jsonschema>=4.21
|
|
22
|
+
Requires-Dist: olefile>=0.47
|
|
23
|
+
Requires-Dist: openpyxl>=3.1
|
|
24
|
+
Requires-Dist: pdfplumber>=0.11
|
|
25
|
+
Requires-Dist: pikepdf>=9
|
|
26
|
+
Requires-Dist: pillow>=10
|
|
27
|
+
Requires-Dist: pydantic>=2.6
|
|
28
|
+
Requires-Dist: pypdfium2>=4.30
|
|
29
|
+
Requires-Dist: python-docx>=1.1
|
|
30
|
+
Requires-Dist: python-multipart>=0.0.9
|
|
31
|
+
Requires-Dist: python-pptx>=1.0
|
|
32
|
+
Requires-Dist: rapidfuzz>=3
|
|
33
|
+
Requires-Dist: uvicorn>=0.29
|
|
34
|
+
Provides-Extra: engine
|
|
35
|
+
Requires-Dist: numpy>=1.26; extra == 'engine'
|
|
36
|
+
Requires-Dist: onnxruntime>=1.18; extra == 'engine'
|
|
37
|
+
Requires-Dist: rapidocr>=3.10; extra == 'engine'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# ReadAnyDoc
|
|
41
|
+
|
|
42
|
+
Parse and extract documents with vision models, on your own machine and your own model account.
|
|
43
|
+
Open source, Reducto-compatible, built by Unmute. Website: https://arpitpatel25.github.io/ReadAnyDoc/
|
|
44
|
+
|
|
45
|
+
ReadAnyDoc reads every page of a PDF, scan, photo or Office file with a vision model (Claude Haiku 5.5 by default)
|
|
46
|
+
and returns typed blocks, tables, Markdown, or the fields of your schema, each with the place on the page it came
|
|
47
|
+
from. Around the model sits an engine that adds what a model alone does not give you: block types and positions,
|
|
48
|
+
form fields, headers and footers, table checks, word-level citations. It runs as a Python library or as a server
|
|
49
|
+
that speaks [Reducto](https://reducto.ai)'s HTTP API, so existing Reducto integrations work by changing one URL.
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import readanydoc
|
|
53
|
+
|
|
54
|
+
result = readanydoc.parse("invoice.pdf")
|
|
55
|
+
print(result.markdown)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Results
|
|
59
|
+
|
|
60
|
+
Five public benchmarks (about 4,250 pages and 10 long documents), each scored with the benchmark's own grader (no AI judge). Same
|
|
61
|
+
documents and same requests for all three systems. Details and caveats: [BENCHMARKS.md](BENCHMARKS.md).
|
|
62
|
+
|
|
63
|
+
| Benchmark | Reducto r-1 | Model only (Haiku 5.5) | ReadAnyDoc engine (Haiku 5.5) |
|
|
64
|
+
|---|---|---|---|
|
|
65
|
+
| olmOCR-bench, overall (1,403 pages) | 80.9 | 82.2 | **84.2** |
|
|
66
|
+
| OmniDocBench, text error, lower is better (1,651 pages) | 0.095 | **0.081** | **0.081** |
|
|
67
|
+
| OmniDocBench, layout: block types right | **84.6%** | 55.6% | 78.3% |
|
|
68
|
+
| RD-TableBench (1,000 tables) | **88.9** | 88.2 | 88.2 |
|
|
69
|
+
| FUNSD, form question/answer pairs (199 forms) | **78.6** | 71.6 | 77.4 |
|
|
70
|
+
| Cost per page | $0.010 | $0.001-0.002 | $0.003-0.005 |
|
|
71
|
+
|
|
72
|
+
Where Reducto is ahead: page layout (by about 6 points), formulas, header and footer removal, and speed
|
|
73
|
+
(about 5 s a page against 20-50 s here).
|
|
74
|
+
|
|
75
|
+
## Install
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install "readanydoc[engine]" # the engine: layout model and OCR run on your CPU
|
|
79
|
+
pip install readanydoc # model-only mode, no local models
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The engine also uses [Tesseract](https://github.com/tesseract-ocr/tesseract) when it is installed
|
|
83
|
+
(`brew install tesseract` / `apt install tesseract-ocr`). The layout and OCR weights (about 200 MB, Apache-2.0)
|
|
84
|
+
are downloaded on first use, so the very first parse takes a few minutes longer; later runs start straight away. Python 3.12.
|
|
85
|
+
|
|
86
|
+
Set your model provider's key: `export ANTHROPIC_API_KEY=...` (or `OPENAI_API_KEY` for OpenAI models).
|
|
87
|
+
|
|
88
|
+
## Use
|
|
89
|
+
|
|
90
|
+
### Parse
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
result = readanydoc.parse("statement.pdf")
|
|
94
|
+
result.blocks # [Block(type="Table", content="<table>...", bbox=BoundingBox(...)), ...]
|
|
95
|
+
result.tables # the Table blocks
|
|
96
|
+
result.markdown # the whole document as Markdown
|
|
97
|
+
result.usage # model calls, tokens, cost in USD, seconds
|
|
98
|
+
result.warnings # anything that went wrong on a page
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Extract into your own types
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from pydantic import BaseModel
|
|
105
|
+
|
|
106
|
+
class Invoice(BaseModel):
|
|
107
|
+
number: str
|
|
108
|
+
issued: str
|
|
109
|
+
total: float
|
|
110
|
+
|
|
111
|
+
out = readanydoc.extract("invoice.pdf", schema=Invoice)
|
|
112
|
+
out.data # Invoice(number="INV-2041", issued="2026-03-01", total=1575.0)
|
|
113
|
+
out.citations["total"] # [Citation(content="1,575.00", bbox=BoundingBox(page=1, left=0.81, ...))]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
A JSON Schema dict works as well as a pydantic class. `instructions=` is the system prompt for the extraction
|
|
117
|
+
model; `array_extract=True` processes long documents in parts and merges their lists.
|
|
118
|
+
|
|
119
|
+
### Choose the mode and the models
|
|
120
|
+
|
|
121
|
+
| Mode | What it does |
|
|
122
|
+
|---|---|
|
|
123
|
+
| `engine` (default) | The model reads each page; the engine adds layout, forms, headers/footers, table checks and citations |
|
|
124
|
+
| `model-only` | One model read per page and nothing else: cheapest, fastest, no structure beyond what the model writes |
|
|
125
|
+
|
|
126
|
+
Every model the pipeline uses can be chosen, with its effort level and any further request options:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
readanydoc.parse(
|
|
130
|
+
"form.pdf",
|
|
131
|
+
mode="engine",
|
|
132
|
+
model="claude-haiku-5-5", effort="high", # page reading (the default)
|
|
133
|
+
model_options={"max_tokens": 32000}, # sent as given to the provider
|
|
134
|
+
handwriting_model="claude-sonnet-5-5", # handwritten pages (the default); None = like any page
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
readanydoc.extract("contract.pdf", schema=Terms,
|
|
138
|
+
model="claude-haiku-5-5", # reads the pages
|
|
139
|
+
extract_model="claude-sonnet-5-5", extract_effort="high") # fills the schema
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Models: any Claude model, OpenAI models (`gpt-...`), or any OpenAI-compatible endpoint written as
|
|
143
|
+
`openai_compatible:<model>@<base_url>`. The benchmark numbers above are for Claude Haiku 5.5; other models work
|
|
144
|
+
but have not been measured here.
|
|
145
|
+
|
|
146
|
+
### Command line
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
readanydoc parse invoice.pdf --markdown
|
|
150
|
+
readanydoc parse scan.pdf --mode model-only --model claude-sonnet-5-5
|
|
151
|
+
readanydoc extract invoice.pdf --schema invoice.schema.json
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Server (Reducto-compatible API)
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
readanydoc serve --port 8000
|
|
158
|
+
# or: docker compose up
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
from reducto import Reducto # Reducto's own SDK, unchanged
|
|
163
|
+
|
|
164
|
+
client = Reducto(api_key="anything", base_url="http://127.0.0.1:8000")
|
|
165
|
+
upload = client.upload(file=Path("invoice.pdf"))
|
|
166
|
+
result = client.parse.run(input=upload.file_id)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Parse, extract, split, classify, edit, async jobs, webhooks and citations are implemented. Configuration,
|
|
170
|
+
security settings and a route-by-route compatibility table: [docs/server.md](docs/server.md).
|
|
171
|
+
|
|
172
|
+
## How it works
|
|
173
|
+
|
|
174
|
+
Each page goes through a fixed sequence of stages (`readanydoc/pipeline/`): intake (file type, pages), triage
|
|
175
|
+
(digital or scanned, rotation), layout (an open layout model on CPU), read (the vision model; zoomed re-reads of
|
|
176
|
+
scanned pages where two reads must agree before a character changes; handwritten pages to a stronger model),
|
|
177
|
+
verify (table grids and printed totals checked without a model), ground (word and cell positions, block types,
|
|
178
|
+
form fields), assemble and shape (the requested output format). Nothing the model wrote is changed without
|
|
179
|
+
independent evidence. Design decisions and their reasons: [docs/decisions.md](docs/decisions.md).
|
|
180
|
+
|
|
181
|
+
## Limits
|
|
182
|
+
|
|
183
|
+
- Slower than Reducto: 20-50 s per page here against about 5 s.
|
|
184
|
+
- About 1.5-3% of pages in large public benchmarks come back empty because the model provider declines to return
|
|
185
|
+
their text (content filtering); the response says so in `warnings`.
|
|
186
|
+
- Confidence values are tiers from how a value was found on the page, not calibrated probabilities.
|
|
187
|
+
|
|
188
|
+
## Documentation
|
|
189
|
+
|
|
190
|
+
| | |
|
|
191
|
+
|---|---|
|
|
192
|
+
| [BENCHMARKS.md](BENCHMARKS.md) | full results against Reducto, cost, method, caveats; per-document scores in [results/](results/) |
|
|
193
|
+
| [docs/story.md](docs/story.md) | why this exists, the bet behind it, what we learned |
|
|
194
|
+
| [docs/research/journey.md](docs/research/journey.md) | the full research record: every stage, every experiment, what was kept and dropped and why |
|
|
195
|
+
| [docs/decisions.md](docs/decisions.md) | every design decision with its reason |
|
|
196
|
+
| [docs/server.md](docs/server.md) | server settings, security, Reducto API compatibility |
|
|
197
|
+
| [examples/](examples/) | runnable scripts |
|
|
198
|
+
| [AGENTS.md](AGENTS.md), [llms.txt](llms.txt) | a map of the repo for AI agents; point your agent at it to ask questions |
|
|
199
|
+
|
|
200
|
+
## Contributing
|
|
201
|
+
|
|
202
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). Security reports: [SECURITY.md](SECURITY.md).
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
Apache-2.0. The layout model (Docling "heron") and the PP-OCR weights are Apache-2.0.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# ReadAnyDoc
|
|
2
|
+
|
|
3
|
+
Parse and extract documents with vision models, on your own machine and your own model account.
|
|
4
|
+
Open source, Reducto-compatible, built by Unmute. Website: https://arpitpatel25.github.io/ReadAnyDoc/
|
|
5
|
+
|
|
6
|
+
ReadAnyDoc reads every page of a PDF, scan, photo or Office file with a vision model (Claude Haiku 5.5 by default)
|
|
7
|
+
and returns typed blocks, tables, Markdown, or the fields of your schema, each with the place on the page it came
|
|
8
|
+
from. Around the model sits an engine that adds what a model alone does not give you: block types and positions,
|
|
9
|
+
form fields, headers and footers, table checks, word-level citations. It runs as a Python library or as a server
|
|
10
|
+
that speaks [Reducto](https://reducto.ai)'s HTTP API, so existing Reducto integrations work by changing one URL.
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
import readanydoc
|
|
14
|
+
|
|
15
|
+
result = readanydoc.parse("invoice.pdf")
|
|
16
|
+
print(result.markdown)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Results
|
|
20
|
+
|
|
21
|
+
Five public benchmarks (about 4,250 pages and 10 long documents), each scored with the benchmark's own grader (no AI judge). Same
|
|
22
|
+
documents and same requests for all three systems. Details and caveats: [BENCHMARKS.md](BENCHMARKS.md).
|
|
23
|
+
|
|
24
|
+
| Benchmark | Reducto r-1 | Model only (Haiku 5.5) | ReadAnyDoc engine (Haiku 5.5) |
|
|
25
|
+
|---|---|---|---|
|
|
26
|
+
| olmOCR-bench, overall (1,403 pages) | 80.9 | 82.2 | **84.2** |
|
|
27
|
+
| OmniDocBench, text error, lower is better (1,651 pages) | 0.095 | **0.081** | **0.081** |
|
|
28
|
+
| OmniDocBench, layout: block types right | **84.6%** | 55.6% | 78.3% |
|
|
29
|
+
| RD-TableBench (1,000 tables) | **88.9** | 88.2 | 88.2 |
|
|
30
|
+
| FUNSD, form question/answer pairs (199 forms) | **78.6** | 71.6 | 77.4 |
|
|
31
|
+
| Cost per page | $0.010 | $0.001-0.002 | $0.003-0.005 |
|
|
32
|
+
|
|
33
|
+
Where Reducto is ahead: page layout (by about 6 points), formulas, header and footer removal, and speed
|
|
34
|
+
(about 5 s a page against 20-50 s here).
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install "readanydoc[engine]" # the engine: layout model and OCR run on your CPU
|
|
40
|
+
pip install readanydoc # model-only mode, no local models
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The engine also uses [Tesseract](https://github.com/tesseract-ocr/tesseract) when it is installed
|
|
44
|
+
(`brew install tesseract` / `apt install tesseract-ocr`). The layout and OCR weights (about 200 MB, Apache-2.0)
|
|
45
|
+
are downloaded on first use, so the very first parse takes a few minutes longer; later runs start straight away. Python 3.12.
|
|
46
|
+
|
|
47
|
+
Set your model provider's key: `export ANTHROPIC_API_KEY=...` (or `OPENAI_API_KEY` for OpenAI models).
|
|
48
|
+
|
|
49
|
+
## Use
|
|
50
|
+
|
|
51
|
+
### Parse
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
result = readanydoc.parse("statement.pdf")
|
|
55
|
+
result.blocks # [Block(type="Table", content="<table>...", bbox=BoundingBox(...)), ...]
|
|
56
|
+
result.tables # the Table blocks
|
|
57
|
+
result.markdown # the whole document as Markdown
|
|
58
|
+
result.usage # model calls, tokens, cost in USD, seconds
|
|
59
|
+
result.warnings # anything that went wrong on a page
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Extract into your own types
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from pydantic import BaseModel
|
|
66
|
+
|
|
67
|
+
class Invoice(BaseModel):
|
|
68
|
+
number: str
|
|
69
|
+
issued: str
|
|
70
|
+
total: float
|
|
71
|
+
|
|
72
|
+
out = readanydoc.extract("invoice.pdf", schema=Invoice)
|
|
73
|
+
out.data # Invoice(number="INV-2041", issued="2026-03-01", total=1575.0)
|
|
74
|
+
out.citations["total"] # [Citation(content="1,575.00", bbox=BoundingBox(page=1, left=0.81, ...))]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
A JSON Schema dict works as well as a pydantic class. `instructions=` is the system prompt for the extraction
|
|
78
|
+
model; `array_extract=True` processes long documents in parts and merges their lists.
|
|
79
|
+
|
|
80
|
+
### Choose the mode and the models
|
|
81
|
+
|
|
82
|
+
| Mode | What it does |
|
|
83
|
+
|---|---|
|
|
84
|
+
| `engine` (default) | The model reads each page; the engine adds layout, forms, headers/footers, table checks and citations |
|
|
85
|
+
| `model-only` | One model read per page and nothing else: cheapest, fastest, no structure beyond what the model writes |
|
|
86
|
+
|
|
87
|
+
Every model the pipeline uses can be chosen, with its effort level and any further request options:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
readanydoc.parse(
|
|
91
|
+
"form.pdf",
|
|
92
|
+
mode="engine",
|
|
93
|
+
model="claude-haiku-5-5", effort="high", # page reading (the default)
|
|
94
|
+
model_options={"max_tokens": 32000}, # sent as given to the provider
|
|
95
|
+
handwriting_model="claude-sonnet-5-5", # handwritten pages (the default); None = like any page
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
readanydoc.extract("contract.pdf", schema=Terms,
|
|
99
|
+
model="claude-haiku-5-5", # reads the pages
|
|
100
|
+
extract_model="claude-sonnet-5-5", extract_effort="high") # fills the schema
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Models: any Claude model, OpenAI models (`gpt-...`), or any OpenAI-compatible endpoint written as
|
|
104
|
+
`openai_compatible:<model>@<base_url>`. The benchmark numbers above are for Claude Haiku 5.5; other models work
|
|
105
|
+
but have not been measured here.
|
|
106
|
+
|
|
107
|
+
### Command line
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
readanydoc parse invoice.pdf --markdown
|
|
111
|
+
readanydoc parse scan.pdf --mode model-only --model claude-sonnet-5-5
|
|
112
|
+
readanydoc extract invoice.pdf --schema invoice.schema.json
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Server (Reducto-compatible API)
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
readanydoc serve --port 8000
|
|
119
|
+
# or: docker compose up
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from reducto import Reducto # Reducto's own SDK, unchanged
|
|
124
|
+
|
|
125
|
+
client = Reducto(api_key="anything", base_url="http://127.0.0.1:8000")
|
|
126
|
+
upload = client.upload(file=Path("invoice.pdf"))
|
|
127
|
+
result = client.parse.run(input=upload.file_id)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Parse, extract, split, classify, edit, async jobs, webhooks and citations are implemented. Configuration,
|
|
131
|
+
security settings and a route-by-route compatibility table: [docs/server.md](docs/server.md).
|
|
132
|
+
|
|
133
|
+
## How it works
|
|
134
|
+
|
|
135
|
+
Each page goes through a fixed sequence of stages (`readanydoc/pipeline/`): intake (file type, pages), triage
|
|
136
|
+
(digital or scanned, rotation), layout (an open layout model on CPU), read (the vision model; zoomed re-reads of
|
|
137
|
+
scanned pages where two reads must agree before a character changes; handwritten pages to a stronger model),
|
|
138
|
+
verify (table grids and printed totals checked without a model), ground (word and cell positions, block types,
|
|
139
|
+
form fields), assemble and shape (the requested output format). Nothing the model wrote is changed without
|
|
140
|
+
independent evidence. Design decisions and their reasons: [docs/decisions.md](docs/decisions.md).
|
|
141
|
+
|
|
142
|
+
## Limits
|
|
143
|
+
|
|
144
|
+
- Slower than Reducto: 20-50 s per page here against about 5 s.
|
|
145
|
+
- About 1.5-3% of pages in large public benchmarks come back empty because the model provider declines to return
|
|
146
|
+
their text (content filtering); the response says so in `warnings`.
|
|
147
|
+
- Confidence values are tiers from how a value was found on the page, not calibrated probabilities.
|
|
148
|
+
|
|
149
|
+
## Documentation
|
|
150
|
+
|
|
151
|
+
| | |
|
|
152
|
+
|---|---|
|
|
153
|
+
| [BENCHMARKS.md](BENCHMARKS.md) | full results against Reducto, cost, method, caveats; per-document scores in [results/](results/) |
|
|
154
|
+
| [docs/story.md](docs/story.md) | why this exists, the bet behind it, what we learned |
|
|
155
|
+
| [docs/research/journey.md](docs/research/journey.md) | the full research record: every stage, every experiment, what was kept and dropped and why |
|
|
156
|
+
| [docs/decisions.md](docs/decisions.md) | every design decision with its reason |
|
|
157
|
+
| [docs/server.md](docs/server.md) | server settings, security, Reducto API compatibility |
|
|
158
|
+
| [examples/](examples/) | runnable scripts |
|
|
159
|
+
| [AGENTS.md](AGENTS.md), [llms.txt](llms.txt) | a map of the repo for AI agents; point your agent at it to ask questions |
|
|
160
|
+
|
|
161
|
+
## Contributing
|
|
162
|
+
|
|
163
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). Security reports: [SECURITY.md](SECURITY.md).
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
Apache-2.0. The layout model (Docling "heron") and the PP-OCR weights are Apache-2.0.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Research
|
|
2
|
+
|
|
3
|
+
How ReadAnyDoc was built and why it looks the way it does.
|
|
4
|
+
|
|
5
|
+
| Page | What it answers |
|
|
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) |
|
|
9
|
+
| [../../BENCHMARKS.md](../../BENCHMARKS.md) | The final results against Reducto r-1, with method and caveats |
|
|
10
|
+
| [../../results/](../../results/) | Per-document scores behind those results |
|
|
11
|
+
| [../decisions.md](../decisions.md) | Every design decision with its reason |
|
|
12
|
+
|
|
13
|
+
Where to look in `journey.md` for common questions:
|
|
14
|
+
|
|
15
|
+
- *Why a layer around a general model and not a trained model?* Sections 1 and 6.
|
|
16
|
+
- *Why no AI judge?* Section 16 and lesson 2.
|
|
17
|
+
- *Why do some early results disagree with the final ones?* Section 23 and Appendix A (every reversal).
|
|
18
|
+
- *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.
|