scanquorum 0.2.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.
- scanquorum-0.2.0/LICENSE +21 -0
- scanquorum-0.2.0/PKG-INFO +419 -0
- scanquorum-0.2.0/README.md +381 -0
- scanquorum-0.2.0/pyproject.toml +87 -0
- scanquorum-0.2.0/scanquorum/__init__.py +24 -0
- scanquorum-0.2.0/scanquorum/__main__.py +38 -0
- scanquorum-0.2.0/scanquorum/build.py +463 -0
- scanquorum-0.2.0/scanquorum/doctor.py +285 -0
- scanquorum-0.2.0/scanquorum/engines/__init__.py +8 -0
- scanquorum-0.2.0/scanquorum/engines/rapidocr_en.py +64 -0
- scanquorum-0.2.0/scanquorum/engines/rapidocr_multi.py +64 -0
- scanquorum-0.2.0/scanquorum/engines/tesseract.py +70 -0
- scanquorum-0.2.0/scanquorum/layout.py +106 -0
- scanquorum-0.2.0/scanquorum/verify_ai.py +265 -0
- scanquorum-0.2.0/scanquorum/vote.py +295 -0
- scanquorum-0.2.0/scanquorum.egg-info/PKG-INFO +419 -0
- scanquorum-0.2.0/scanquorum.egg-info/SOURCES.txt +24 -0
- scanquorum-0.2.0/scanquorum.egg-info/dependency_links.txt +1 -0
- scanquorum-0.2.0/scanquorum.egg-info/entry_points.txt +2 -0
- scanquorum-0.2.0/scanquorum.egg-info/requires.txt +12 -0
- scanquorum-0.2.0/scanquorum.egg-info/top_level.txt +1 -0
- scanquorum-0.2.0/setup.cfg +4 -0
- scanquorum-0.2.0/tests/test_doctor.py +162 -0
- scanquorum-0.2.0/tests/test_goldset.py +187 -0
- scanquorum-0.2.0/tests/test_safety.py +82 -0
- scanquorum-0.2.0/tests/test_vote_parity.py +139 -0
scanquorum-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Igor Saevets
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scanquorum
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Read a scanned page with several independent OCR engines and accept a word only when they agree. No language model in the transcription path.
|
|
5
|
+
Author: Igor Saevets
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/igorsaevets/scanquorum
|
|
8
|
+
Project-URL: Source, https://github.com/igorsaevets/scanquorum
|
|
9
|
+
Project-URL: Issues, https://github.com/igorsaevets/scanquorum/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/igorsaevets/scanquorum/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: ocr,pdf,scanned-documents,rag,consensus,hallucination,document-ai
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Legal Industry
|
|
15
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
21
|
+
Classifier: Topic :: Text Processing
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: pymupdf<2,>=1.24
|
|
27
|
+
Requires-Dist: rapidocr<4,>=3.9
|
|
28
|
+
Requires-Dist: onnxruntime<2,>=1.17
|
|
29
|
+
Requires-Dist: numpy<3,>=1.24
|
|
30
|
+
Requires-Dist: pillow<13,>=10
|
|
31
|
+
Provides-Extra: measured
|
|
32
|
+
Requires-Dist: pymupdf==1.28.0; extra == "measured"
|
|
33
|
+
Requires-Dist: rapidocr==3.9.2; extra == "measured"
|
|
34
|
+
Requires-Dist: onnxruntime==1.28.0; extra == "measured"
|
|
35
|
+
Requires-Dist: numpy==2.4.6; extra == "measured"
|
|
36
|
+
Requires-Dist: pillow==12.3.0; extra == "measured"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# ScanQuorum
|
|
40
|
+
|
|
41
|
+
**Your scanned PDF contains invisible text. Your AI reads that, not the paper.**
|
|
42
|
+
|
|
43
|
+
Every scanned document you own — a contract, a filed decision, a bank statement, a deed —
|
|
44
|
+
carries a hidden layer of text that some OCR program guessed at, sometimes decades ago. You
|
|
45
|
+
never see it. Your search tool reads it. Your AI quotes it. Nobody ever checked whether it
|
|
46
|
+
matches the page.
|
|
47
|
+
|
|
48
|
+
**ScanQuorum reads the same page with several independent OCR engines and accepts a word only
|
|
49
|
+
when they agree.** Where they disagree it does not pick a winner quietly — it tells you which
|
|
50
|
+
words to look at, and shows you the picture.
|
|
51
|
+
|
|
52
|
+
No language model is allowed anywhere near the transcription. That is the point, and it is
|
|
53
|
+
enforced in code rather than promised in a prompt.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Why this exists
|
|
58
|
+
|
|
59
|
+
A page of a 1974 immigration decision has this in its text layer:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
Decided by Regional Commissioner May 1, .1974
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
That stray full stop was put there by an OCR program in the year 2000 and has been sitting in
|
|
66
|
+
the file ever since. It is harmless. Four lines away, in the same class of document, the
|
|
67
|
+
citation `12-855` had been recorded as `12369`.
|
|
68
|
+
|
|
69
|
+
That one is not harmless. It is a pointer to a different decision — and it looks exactly as
|
|
70
|
+
authoritative as the correct one, because a text layer carries no confidence, no provenance
|
|
71
|
+
and no warning. It is just text.
|
|
72
|
+
|
|
73
|
+
Now put a modern AI in front of that file. Ask it to quote the decision. It will quote it
|
|
74
|
+
perfectly — perfectly reproducing the wrong citation, and adding a fluent explanation of what
|
|
75
|
+
that decision held. Every hallucination check you run will pass, because the model did not
|
|
76
|
+
hallucinate. It read what was in the file.
|
|
77
|
+
|
|
78
|
+
> **The document was corrupted twenty-five years before the AI ever saw it.**
|
|
79
|
+
|
|
80
|
+
That is the failure this tool exists to catch, and it is invisible to every tool that checks
|
|
81
|
+
whether an AI made something up.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## What it actually does
|
|
86
|
+
|
|
87
|
+
**1. Reads the page several times, independently.** Four engines by default: the text layer
|
|
88
|
+
already in your PDF, two neural OCR models, and a classical one. They fail differently, which
|
|
89
|
+
is the entire reason to run more than one.
|
|
90
|
+
|
|
91
|
+
**2. Accepts a word only on a quorum.** A word is marked as confirmed when at least two
|
|
92
|
+
independent engines read it **identically**. On a 41-page government index that is **86.55 %
|
|
93
|
+
of 29,853 words**.
|
|
94
|
+
|
|
95
|
+
**3. Says exactly what happened to the other 13.45 %,** because a tool that refuses to guess
|
|
96
|
+
has to account for every word it did not vote on. It is not one bucket, it is three, and they
|
|
97
|
+
are not the same strength of evidence:
|
|
98
|
+
|
|
99
|
+
| what happened | words | share |
|
|
100
|
+
|---|---:|---:|
|
|
101
|
+
| read identically by two or more independent engines | 25,838 | 86.55 % |
|
|
102
|
+
| same digits, different punctuation (`12-869` against `12 869`) | 3,211 | 10.76 % |
|
|
103
|
+
| chosen by dictionary or pattern, **no second engine agreed** | 111 | 0.37 % |
|
|
104
|
+
| not confirmed at all: disputed, or seen by only one engine | 693 | 2.32 % |
|
|
105
|
+
|
|
106
|
+
Those four sum to 29,853, and `build.py` asserts it on every run rather than trusting it. The
|
|
107
|
+
last row is written to a side file with page and coordinates for each word.
|
|
108
|
+
|
|
109
|
+
> An earlier version of this README reported one number, `accepted_by_quorum: 97.68 %`, that
|
|
110
|
+
> folded the first three rows together. That counted a dictionary lookup as though it were a
|
|
111
|
+
> second engine agreeing, and overstated the only claim this project makes by eleven points.
|
|
112
|
+
> It was found by an outside reviewer. See [CHANGELOG.md](CHANGELOG.md).
|
|
113
|
+
|
|
114
|
+
**4. Never invents a character.** Every rule in the decision engine returns a candidate that
|
|
115
|
+
some engine actually proposed, or nothing. There is no code path that composes text. This is
|
|
116
|
+
the property that makes the output safe to paste into a filing, and it is verified by a test
|
|
117
|
+
you can run yourself.
|
|
118
|
+
|
|
119
|
+
**5. Writes a Markdown file next to the PDF.** Because your search tool cannot read a PDF and
|
|
120
|
+
never told you, and because an AI given a `.md` file with a provenance header behaves very
|
|
121
|
+
differently from one handed a PDF.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Measured
|
|
126
|
+
|
|
127
|
+
On the EOIR Cumulative Index (41 pages, U.S. Department of Justice), reference standard =
|
|
128
|
+
the page rendered at 900 dpi and read by a human:
|
|
129
|
+
|
|
130
|
+
| | existing text layer | ScanQuorum |
|
|
131
|
+
|---|---:|---:|
|
|
132
|
+
| words | 29,829 | 29,845 |
|
|
133
|
+
| citations of the form `12-855` found | 2,583 | **3,182** |
|
|
134
|
+
| distinct citations found | 1,629 | **1,825** |
|
|
135
|
+
|
|
136
|
+
**Nearly 200 citations that were in the document could not be found in its own text layer.**
|
|
137
|
+
Not misspelled — unfindable. Every search for them returned nothing, and returned it
|
|
138
|
+
confidently.
|
|
139
|
+
|
|
140
|
+
### Every voter against the pixels, on the same crops
|
|
141
|
+
|
|
142
|
+
Sixty crops were labelled by a human from the page rendered at 900 dpi. Four of them turned
|
|
143
|
+
out to have an unusable frame (see below), leaving **56** scored. This table is produced by
|
|
144
|
+
`python tests/test_goldset.py`, from a fixture that ships in this repository, so you can
|
|
145
|
+
recompute every cell:
|
|
146
|
+
|
|
147
|
+
| voter | agrees with the page | 95 % interval |
|
|
148
|
+
|---|---:|---|
|
|
149
|
+
| the PDF's own text layer | 46.4 % | [34.0, 59.3] |
|
|
150
|
+
| `rapidocr_multi` | 78.6 % | [66.2, 87.3] |
|
|
151
|
+
| `rapidocr_en` | 60.4 % | [46.9, 72.4] |
|
|
152
|
+
| **the ensemble** | **94.6 %** | **[85.4, 98.2]** |
|
|
153
|
+
|
|
154
|
+
> **These are not document accuracy and must not be quoted as such.** The sample is
|
|
155
|
+
> *stratified*: contested decisions are deliberately over-represented, because in a document
|
|
156
|
+
> where 96 % of tokens are unanimous a random sample spends nearly all its labelling effort
|
|
157
|
+
> confirming easy words. The table says the ensemble is right on **hard** cases far more often
|
|
158
|
+
> than any single voter, which is what it is for. It does not say the document is 94.6 %
|
|
159
|
+
> correct.
|
|
160
|
+
|
|
161
|
+
Extrapolated to the whole document with a Horvitz–Thompson estimator, the figure is **98.65 %
|
|
162
|
+
with three engines and 99.15 % with four**. Read the two warnings below before using either.
|
|
163
|
+
|
|
164
|
+
> 🔴 **Read that as an UPPER BOUND, not as the accuracy.** The reference standard was
|
|
165
|
+
> built by rendering each token's own box and reading it, so when the box itself is
|
|
166
|
+
> wrong the standard is wrong in exactly the same way. Truncation — the largest known
|
|
167
|
+
> residual error class, and 7 of 7 observed mistakes — is invisible to it by
|
|
168
|
+
> construction. Page-level accuracy is necessarily lower and has not been measured.
|
|
169
|
+
>
|
|
170
|
+
> This is not hypothetical: **4 of the 60 labelled crops are exactly this failure.** The word
|
|
171
|
+
> box inherited from the PDF cut a glyph or framed typographic debris, every engine read
|
|
172
|
+
> inside the same wrong box, and all of them agreed. `tests/test_goldset.py` prints those four
|
|
173
|
+
> and excludes them. Unanimity there is not evidence, it *is* the error.
|
|
174
|
+
|
|
175
|
+
> 🔴 **The whole measurement is one document, in English legal print, from 2002.** Nothing
|
|
176
|
+
> here establishes that any of it transfers to another genre, another language, or a worse
|
|
177
|
+
> scan. See `testing/TO-TEST.md`, gap G1.
|
|
178
|
+
|
|
179
|
+
> 🔴 **And that improvement is not statistically significant.** Exact McNemar on the 4
|
|
180
|
+
> discordant pairs gives **p = 0.125**. Four engines beat three on this document, by a margin
|
|
181
|
+
> this sample cannot distinguish from luck. It is reported because it was measured, not
|
|
182
|
+
> because it is proven.
|
|
183
|
+
|
|
184
|
+
Everything above is reproducible from this repository: `samples/` contains all five documents,
|
|
185
|
+
`testing/` records what was tried and what was rejected.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## The .md sidecar, and why it has a header
|
|
190
|
+
|
|
191
|
+
This is real output, copied from a run of `samples/02-...pdf`, not an illustration:
|
|
192
|
+
|
|
193
|
+
```markdown
|
|
194
|
+
---
|
|
195
|
+
source_pdf: 02-matter-of-gaglioti-14-IN-Dec-677.pdf
|
|
196
|
+
source_sha256: 12ed016f49855cfce9561ae6214eb7baa395113c778b228c4ea75b3bd306b705
|
|
197
|
+
pages: 2
|
|
198
|
+
engines: ["pdf_layer", "rapidocr_en", "rapidocr_multi", "tesseract"]
|
|
199
|
+
engines_unavailable: []
|
|
200
|
+
frame_engine: rapidocr_en
|
|
201
|
+
words: 885
|
|
202
|
+
agreed_exactly: 856
|
|
203
|
+
agreed_on_digits_not_punctuation: 1
|
|
204
|
+
chosen_by_rule_no_second_engine: 0
|
|
205
|
+
unconfirmed: 28
|
|
206
|
+
agreed_exactly_from_correlated_voters_only: 4
|
|
207
|
+
unconfirmed_index: 02-matter-of-gaglioti-14-IN-Dec-677.unconfirmed.json
|
|
208
|
+
existing_layer_producer: Acrobat PDFWriter 4.0 for Windows NT
|
|
209
|
+
generated_by: scanquorum 0.1.0 (build.py v1.1)
|
|
210
|
+
warning: >
|
|
211
|
+
Of the 885 words in this file, 856 were read IDENTICALLY by at least two
|
|
212
|
+
independent OCR engines. A further 1 were read with the same digits but
|
|
213
|
+
different punctuation ... Another 0 were chosen by dictionary or by pattern
|
|
214
|
+
with NO second engine agreeing. The remaining 28 are not confirmed at all and
|
|
215
|
+
are listed in ...unconfirmed.json with page and coordinates. ...
|
|
216
|
+
---
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Three fields there are worth more than the rest.
|
|
220
|
+
|
|
221
|
+
`agreed_exactly_from_correlated_voters_only: 4` says that four of the confirmed words were
|
|
222
|
+
carried **only** by `rapidocr_multi` and `rapidocr_en`, which share a text detector. That is
|
|
223
|
+
one opinion agreeing with itself, and the header says so instead of counting it as two.
|
|
224
|
+
|
|
225
|
+
`engines_unavailable` is empty here. If an engine had failed to load, the run would still have
|
|
226
|
+
produced this file, complete and confident, with fewer voters. That field and the console
|
|
227
|
+
warning are the only places it would show.
|
|
228
|
+
|
|
229
|
+
The four count fields **sum to `words`**, and the code asserts it. `unconfirmed` is also
|
|
230
|
+
asserted to equal the number of entries in the file it names, so the sentence "listed in X" is
|
|
231
|
+
a fact rather than a caption.
|
|
232
|
+
|
|
233
|
+
Note what the header does **not** do: unconfirmed words are **not marked inline** in the body.
|
|
234
|
+
That is deliberate, because inline markers would break the byte-for-byte quotation this tool
|
|
235
|
+
exists to make possible, but it means the index is not optional.
|
|
236
|
+
|
|
237
|
+
That last field is addressed to the AI that will read the file. It is the cheapest useful
|
|
238
|
+
thing in this project: a model handed a document that states its own uncertainty stops
|
|
239
|
+
presenting guesses as quotations. The body below the header is clean text — greppable,
|
|
240
|
+
quotable byte-for-byte, with `<!-- page 12 -->` markers so any quotation can be traced back to
|
|
241
|
+
a page.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Install
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
git clone https://github.com/igorsaevets/scanquorum
|
|
249
|
+
cd scanquorum
|
|
250
|
+
python -m pip install -r requirements.txt
|
|
251
|
+
python -m scanquorum doctor # <- run this before anything else
|
|
252
|
+
python -m scanquorum build samples/02-matter-of-gaglioti-14-IN-Dec-677.pdf
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
`doctor` exits **0** when the tool can do what it claims, **1** when it will run but with
|
|
256
|
+
fewer independent opinions than it needs, and **2** when it cannot run. Every failing check
|
|
257
|
+
prints the exact command that fixes it. It exists because a run with a missing engine produces
|
|
258
|
+
a complete, well-formed file that looks exactly like a good one.
|
|
259
|
+
|
|
260
|
+
**Tesseract is a native binary and `pip` cannot install it.** Full platform instructions are
|
|
261
|
+
in [INSTALL.md](INSTALL.md). Without it you are left with one independent OCR opinion, because
|
|
262
|
+
the two RapidOCR voters share a detector.
|
|
263
|
+
|
|
264
|
+
**If you are handing this to an AI coding agent,** point it at [AGENTS.md](AGENTS.md). It is
|
|
265
|
+
written to be executed and it lists the five things that will otherwise mislead it.
|
|
266
|
+
|
|
267
|
+
No account and no API key: `build`, the vote engine and both test suites run entirely
|
|
268
|
+
offline. (One optional command, `verify-ai`, does send a crop to a model API — it refuses to
|
|
269
|
+
run without a key, and you never need it. See [SECURITY.md](SECURITY.md).) Tesseract is optional — it is the fourth
|
|
270
|
+
engine, and the tool says so when it runs with three.
|
|
271
|
+
|
|
272
|
+
**Check that the code here is the code that was measured** — one second, no dependencies:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
python tests/test_vote_parity.py
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
It replays 11,780 real decisions recorded from the measured run and requires this repository to
|
|
279
|
+
reproduce every one of them.
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## The five test documents, and where they came from
|
|
284
|
+
|
|
285
|
+
All five are U.S. federal government publications, in the public domain under 17 U.S.C. § 105.
|
|
286
|
+
**Each is byte-for-byte identical to the copy on the government's own server** — verified by
|
|
287
|
+
SHA-256, not asserted. The URLs and hashes are in [`samples/MANIFEST.json`](samples/MANIFEST.json).
|
|
288
|
+
|
|
289
|
+
They deliberately span three unrelated OCR vendors across 25 years:
|
|
290
|
+
|
|
291
|
+
| document | pp | who made its text layer |
|
|
292
|
+
|---|---:|---|
|
|
293
|
+
| Matter of Arai, 13 I&N Dec. 494 (BIA 1970) | 3 | Visioneer PaperPort LE → Acrobat PDFWriter 4.0, 2004 |
|
|
294
|
+
| Matter of Gaglioti, 14 I&N Dec. 677 (1974) | 2 | Visioneer PaperPort LE → Acrobat PDFWriter 4.0, 2000 |
|
|
295
|
+
| Matter of Vindman, 16 I&N Dec. 131 (1977) | 3 | Visioneer PaperPort LE → Acrobat PDFWriter 4.0, 2000 |
|
|
296
|
+
| INS v. Bagamasbad, 429 U.S. 24 (1976) | 4 | LuraTech PDF Compressor, 2009 |
|
|
297
|
+
| EOIR Cumulative Index, Vols. 1–15, A–E | 41 | Acrobat PDFWriter 4.0 for Windows NT |
|
|
298
|
+
|
|
299
|
+
The defects each one exhibits are catalogued in [`artifacts/ARTIFACTS.md`](artifacts/ARTIFACTS.md)
|
|
300
|
+
— what goes wrong, why, and which ones this tool does *not* catch.
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## Who this is for
|
|
305
|
+
|
|
306
|
+
- **Legal departments and firms.** A quotation of authority is either the words in the source
|
|
307
|
+
or it is not. This tells you which words in your source are guesses.
|
|
308
|
+
- **Finance, audit and compliance.** Scanned statements, invoices and contracts feeding a
|
|
309
|
+
reconciliation or an LLM pipeline. A digit read wrong by a 2003 scanner does not announce
|
|
310
|
+
itself.
|
|
311
|
+
- **Founders and small teams** building anything that reads documents with AI. The expensive
|
|
312
|
+
failure is not the model inventing text; it is the model faithfully repeating text that was
|
|
313
|
+
already wrong.
|
|
314
|
+
- **Anyone assembling a corpus for RAG.** Retrieval cannot find what OCR did not record. The
|
|
315
|
+
200 missing citations above were a 12 % recall loss nobody would ever have noticed.
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## What it does not do, said plainly
|
|
320
|
+
|
|
321
|
+
- **It does not tell you the truth about the page.** It tells you where independent engines
|
|
322
|
+
agree. Engines can agree and be wrong together — most often when the word is inside a box
|
|
323
|
+
that was cut off before any of them saw it. Measured on this corpus: of 24 disagreements
|
|
324
|
+
checked by eye, the tool was right on 17 and wrong on 7, and **all 7 were truncations**. A
|
|
325
|
+
crop-relative reference standard cannot see that class by construction, so the headline
|
|
326
|
+
accuracy above does not cover it.
|
|
327
|
+
- **It is not a reader for handwriting, tables or forms.** It votes on words in running text.
|
|
328
|
+
- **It does not know what your document means.** It answers one question: which words on this
|
|
329
|
+
page can be relied on.
|
|
330
|
+
- **Four engines are not four independent opinions.** Two of the default engines share a text
|
|
331
|
+
detector — 2,921 of 3,006 boxes identical — so "four voices" is nearer three. This is why the
|
|
332
|
+
fourth engine helped at all: it was added for independence, not for strength, and it is the
|
|
333
|
+
weakest of the four.
|
|
334
|
+
- **A flag can mean the tool is wrong.** Before correcting a document because ScanQuorum
|
|
335
|
+
flagged it, look at the page yourself. Every entry in the unconfirmed index carries the page
|
|
336
|
+
number and the bounding box, so the place is one lookup away.
|
|
337
|
+
|
|
338
|
+
> An earlier version of this README said the tool "will render each one as a cropped image
|
|
339
|
+
> so a person can look at it in three seconds." **It does not.** No code path in `build`
|
|
340
|
+
> renders a crop. The claim was written for a feature that exists only in the unpublished
|
|
341
|
+
> lab tooling. It is listed in `testing/PLANNED.md` as P8; until it ships, the coordinates
|
|
342
|
+
> are what you get.
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## Prior art
|
|
347
|
+
|
|
348
|
+
**Almost nothing here is new, and the parts that are, are small.** An earlier version of this
|
|
349
|
+
section claimed novelty on the basis of not having found prior work, which is exactly the
|
|
350
|
+
reasoning this project rejects everywhere else. Six independent reviewers were then asked to
|
|
351
|
+
find the prior art. They found a great deal.
|
|
352
|
+
|
|
353
|
+
**Voting across recognisers is thirty years old.** ROVER (Fiscus, *IEEE ASRU* 1997) aligns
|
|
354
|
+
several recognisers into a word transition network and votes with confidence weighting. The
|
|
355
|
+
ISRI/UNLV toolkit (Rice, Kanai and Nartker, 1994 onward; Nartker, Rice and Lumos, *DRR XII*
|
|
356
|
+
2005) shipped `synctext` and `vote` — and `vote` already broke ties with heuristics, which is
|
|
357
|
+
the very place our own bug lived. Lund and Ringger (*JCDL* 2009) align multiple engines into a
|
|
358
|
+
lattice with an A\* heuristic; Lund, Walker and Ringger (*ICDAR* 2011) add discriminative
|
|
359
|
+
selection and report a 24.6 % relative improvement over the best single engine. Handley's
|
|
360
|
+
survey (*IEEE SMC* 1998) had already laid out the taxonomy.
|
|
361
|
+
|
|
362
|
+
**Abstention is older still, and better formalised elsewhere.** Chow (1957, and *IEEE Trans.
|
|
363
|
+
Inf. Theory* 1970) is the reject option, with an optimal threshold derived from a cost model.
|
|
364
|
+
Modern selective prediction (El-Yaniv and Wiener, *JMLR* 2010; Geifman and El-Yaniv, *NeurIPS*
|
|
365
|
+
2017) reports a **risk-coverage curve**. We report one point on that curve and we have no
|
|
366
|
+
calibrated confidence at all. Conformal prediction would give distribution-free coverage
|
|
367
|
+
guarantees for the set of readings we already produce; we do not currently make that claim.
|
|
368
|
+
|
|
369
|
+
**Voting inside one engine is a live alternative.** Calamari (Wick, Reul and Puppe, 2018) votes
|
|
370
|
+
across cross-fold-trained models of one architecture and reaches far lower character error
|
|
371
|
+
rates than anything here, on cleaner corpora. Our argument for *architecture* diversity rather
|
|
372
|
+
than model-instance diversity is the 2,921-of-3,006 measurement below, not a general claim.
|
|
373
|
+
|
|
374
|
+
**Ensemble OCR as working software also exists**: OCR-D's `ocrd-cor-asv-ann-align` does n-ary
|
|
375
|
+
alignment with majority or confidence voting, and is the most direct baseline we should be
|
|
376
|
+
compared against. We have not yet run that comparison.
|
|
377
|
+
|
|
378
|
+
So what is actually left:
|
|
379
|
+
|
|
380
|
+
1. **Refusal as the primary output.** Prior systems align and vote in order to emit one best
|
|
381
|
+
string. Here the disagreements are the deliverable, enumerated with page and coordinates,
|
|
382
|
+
and the accepted text carries a header saying how much of it is unverified. Reviewers split
|
|
383
|
+
on whether this is a contribution or a packaging decision; two called it real, one said a
|
|
384
|
+
competent engineer could add it to an existing voter in an evening. Both are fair.
|
|
385
|
+
2. **A determinism audit of the tie-breaks.** We replayed 11,780 recorded decisions under every
|
|
386
|
+
permutation of engine ordering and found **1.40 % order-dependent, 29 of them changing a
|
|
387
|
+
digit**. Six reviewers looked for prior work doing this to an OCR ensemble; three documented
|
|
388
|
+
their search terms and all six came back empty. That is evidence of absence of *found*
|
|
389
|
+
work, not proof of absence. The narrow, defensible claim: the literature has always known
|
|
390
|
+
ties need breaking, and we found no work that measures what it costs to leave the tie-break
|
|
391
|
+
order-dependent.
|
|
392
|
+
|
|
393
|
+
If you know of prior work we have misread or missed, please open an issue. Using an existing
|
|
394
|
+
tool would be less work than maintaining this one.
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## Found a bug? Want a feature?
|
|
399
|
+
|
|
400
|
+
| what | where |
|
|
401
|
+
|---|---|
|
|
402
|
+
| a word was decided wrongly | [open an issue](../../issues) — include the crop, the candidates and the verdict you expected |
|
|
403
|
+
| an idea, a question, a document class you want supported | [discussions](../../discussions) |
|
|
404
|
+
| a security problem | [private advisory](../../security/advisories/new) — **not** a public issue |
|
|
405
|
+
| collaboration or consulting | [LinkedIn](https://www.linkedin.com/in/igorsaevets/) · [GitHub](https://github.com/igorsaevets) |
|
|
406
|
+
|
|
407
|
+
**There is deliberately no contact email.** The address on this repository's commits is
|
|
408
|
+
GitHub's no-reply relay: it attributes commits correctly and has no mail exchanger at all, so
|
|
409
|
+
mail sent to it is discarded without a bounce. A channel that silently swallows a bug report is
|
|
410
|
+
worse than an absent one.
|
|
411
|
+
|
|
412
|
+
Related tool, same author, the step after this one:
|
|
413
|
+
[**krokai-law**](https://github.com/igorsaevets/krokai-law) checks that quotations in your
|
|
414
|
+
documents really appear in your sources. ScanQuorum is what makes those sources trustworthy in
|
|
415
|
+
the first place — `krokai` verifies against the copy on your disk, and this is how you find out
|
|
416
|
+
whether that copy says what the paper says.
|
|
417
|
+
|
|
418
|
+
Maintained by **Igor Saevets** ([@igorsaevets](https://github.com/igorsaevets)), Los Angeles.
|
|
419
|
+
Licence: MIT. Nothing here contacts a vendor, and no test needs a key.
|