ocr-demo-documents / README.md
jswhitworth's picture
Add structured case JSON (cases/): grounded caption facts, dispositions, citations
e909d39 verified
|
Raw
History Blame Contribute Delete
5.23 kB
---
license: other
license_name: us-government-edict-public-domain
task_categories:
- image-to-text
language:
- en
tags:
- ocr
- document-parsing
- legal
- unlimited-ocr
---
# OCR Demo Documents — state court opinions
Public state appellate opinions parsed with
[baidu/Unlimited-OCR](https://huggingface.co/baidu/Unlimited-OCR), served on
vLLM. Each document is published as the original PDF, the raw model output,
the converted HTML, and the PDF's own text layer.
## Layout
| Path | Contents |
|---|---|
| `pdf/` | Source PDFs, exactly as downloaded from the court |
| `pages/` | Page images fed to the model (PNG, 300 dpi) |
| `raw/` | Unmodified model output, including `<\|det\|>` layout markers |
| `html/` | Converted HTML — the deliverable |
| `text/` | The PDF's embedded text layer, used as ground truth |
| `layout/` | One JSON record per block: text plus its position on the page |
| `cases/` | Structured case JSON: caption facts, panel, disposition, grounded citations |
| `manifest.jsonl` | One row per document: provenance, parameters, scores |
## Documents
| id | Case | Court | Pages | Text-layer match |
|---|---|---|---|---|
| `2968s18` | Evans v. Jean-Charles, No. 2968 | Maryland Court of Special Appeals | 4 | 91.95% |
| `0260s20` | Johnson v. Secretary of Public Safety, No. 260 | Maryland Court of Special Appeals | 3 | 89.10% |
| `CAAP-11-0000713conada` | CAAP-11-0000713 (concurring opinion) | Hawaii Intermediate Court of Appeals | 3 | 99.65% |
## Method
Pages are rendered at 300 dpi with PyMuPDF, then all pages of a document
are sent in a **single** `Multi page parsing.` request — the long-horizon
capability the model is named for. Multi-image input puts the model in base
mode; `window_size` is 1024 (rather than the single-image 128) and
`skip_special_tokens` is false so the layout markers survive.
The `<|det|>` markers are parsed rather than stripped: block categories drive
the HTML structure (titles become headings, tables stay tables) and bounding
boxes are preserved as `data-bbox` attributes.
## Text with coordinates
The model grounds every block it emits, so each piece of text can be traced
back to where it sits on the page. `layout/<doc_id>.jsonl` carries one record
per block with the text, its category, its page number, and its bounding box
in four coordinate spaces:
| Field | Space | Matches |
|---|---|---|
| `bbox_norm` | 0-1000, origin top-left | the model's own output |
| `bbox_pt` | PDF points, origin top-left | PyMuPDF, pdfplumber |
| `bbox_pt_pdf` | PDF points, origin bottom-left | the PDF specification |
| `bbox_px` | pixels at 300 dpi | the rendered page images |
The normalized origin was verified against the PDF text layer rather than
assumed: a heading the model reports at 0.306/0.085 of the page is measured
by PyMuPDF at 0.312/0.086.
Two limits worth knowing. Granularity is block level — paragraphs, headings,
footnotes — not per word or per character. And coverage is not exhaustive:
occasional blocks have boxes that stop short of all the text they
transcribed, so the text is more complete than the geometry.
## Structured case data
`cases/<doc_id>.json` is a layout-aware reading of each opinion. Caption
facts are taken from the page *geometry* — on a Maryland caption page the
left column carries the originating court, the right column carries docket,
term, the parties around the standalone "V." block, the panel between the
appellee and "JJ.", and the filed date. The extraction covers:
* court, docket number, term, publication status, parties, panel (with
senior-judge annotations), opinion type/author, filed date, originating
court and case number;
* the disposition, found as an indented mostly-uppercase block with an
outcome keyword, classified into outcomes and cost allocation;
* every case citation, parsed into name / volume / reporter / first page /
pinpoint / year, with parallel citations grouped, signals (See, Cf.) and
trailing parentheticals captured;
* rule and statute citations (Md. Rules, HRS §§, Code articles).
Every extracted property carries a `grounding` object — page, block index,
and bounding box (plus character offsets for citations) — so each fact can
be traced to the exact place on the page it was read from.
This extraction is **heuristic**: it was built and verified against state
appellate opinions of this shape. On the three documents here it recovers
12/12 case citations with names and years; fields it cannot find are null
rather than guessed. OCR misreads pass through verbatim by design (e.g. a
reporter rendered as `Hawaii'`), so the JSON reflects what the model read,
not a cleaned-up ideal.
## On the accuracy numbers
These opinions are **born-digital** PDFs with real embedded text, which is
why a text-layer match score is available at all — it is a genuine
character-level comparison, not an estimate. It also means they are an easy
OCR target: they validate the pipeline end to end, but they do not
demonstrate performance on scanned or degraded documents.
## Licensing
US state court opinions are government edicts and are not subject to
copyright. The pipeline that produced the derived files lives in the
accompanying demo repository.