Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pdf binary
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ venv/
demos/grounded-extraction/
demos/parse-citations/
outputs/
scripts/
demos/*/provisional/output/
scripts/*
!scripts/build_lighthouse_fixtures.py
65 changes: 46 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<h1 align="center">Nutrient Extraction Samples</h1>

<p align="center">
<strong>Most document AI returns values.<br>This returns values <em>and proof</em>.</strong>
<strong>Extract structured values.<br>Inspect the returned source regions.</strong>
</p>

<p align="center">
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-1a1a1a"></a>
<img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10%2B-1a1a1a">
<img alt="5 demos" src="https://img.shields.io/badge/demos-5-1a1a1a">
<img alt="8 demos" src="https://img.shields.io/badge/demos-8-1a1a1a">
<a href="https://www.nutrient.io/guides/dws-data-extraction/getting-started/"><img alt="Nutrient Data Extraction API" src="https://img.shields.io/badge/Nutrient-Data%20Extraction%20API-1a1a1a"></a>
</p>

<p align="center">
<img src="docs/screenshots/hover-demo.gif" alt="Hovering an extracted field card highlights the exact region of the source document the value came from" width="100%">
<img src="docs/screenshots/hover-demo.gif" alt="Hovering a field highlights the source region returned for that result" width="100%">
</p>

<p align="center"><em>Hover any extracted field. The highlight lands on the exact pixels it came from.</em></p>
<p align="center"><em>Hover a field. The demo highlights the source region returned for that result.</em></p>

Every extracted value carries a **bounding box**, a **confidence score**, and a **page index**. When a value looks wrong you don't go hunting through the document — you hover the field and see precisely where the model looked. A highlight in the wrong place is a visible audit trail.
When the API returns grounding metadata, an extracted field can carry a **bounding box**, a **recognition signal**, and a **page index**. In these reviewed demos, hovering a grounded field shows the source region used for that result. A highlight in the wrong place makes a grounding problem visible; it does not prove the extracted value is correct.

```jsonc
// Send a schema. Get back values with provenance.
"procedure_code": "99213", // the value
"bbox": { "x": 412, "y": 288, "width": 74, "height": 18 }, // where it came from
"confidence": 0.95, // how sure the model was
"confidence": 0.95, // recognition signal; not correctness probability
"pageIndex": 0 // which page
```

Expand All @@ -32,12 +32,36 @@ Every extracted value carries a **bounding box**, a **confidence score**, and a
&nbsp;·&nbsp;
<a href="#run-it-yourself"><strong>Run it yourself</strong></a>
&nbsp;·&nbsp;
<a href="docs/reproducible-proof.md"><strong>Reproduce the proof</strong></a>
&nbsp;·&nbsp;
<a href="docs/lighthouse/index.html"><strong>Browse the hub source</strong></a>
&nbsp;·&nbsp;
<a href="#install-the-agent-skill"><strong>Give it to an agent</strong></a>
</p>

---

## Five documents, five hard problems
## Three authentic-form evidence packages

On three selected one-page authentic public forms populated with privacy-safe demo values, one live Nutrient Data Extraction API response per form exactly matched **26 of 30 predeclared fields**: mortgage **6/8**, insurance **11/11**, and healthcare **9/11**. All **30/30** returned fields included valid page-bounded primary source regions, and **four mismatches** were retained for review.

| Package | Selected public form | Exact values | Primary regions returned | Verdict |
|---|---|---:|---:|---|
| [`mortgage_verification`](demos/mortgage_verification/) | U.S. Treasury Request for Mortgage Assistance | 6/8 | 8/8 | Review blocked |
| [`insurance_claim_intake`](demos/insurance_claim_intake/) | GSA Standard Form 91 crash report | 11/11 | 11/11 | 11/11 exact → Continue |
| [`prior_authorization`](demos/prior_authorization/) | CMS GLP-1 Bridge prior-authorization form | 9/11 | 11/11 | Review blocked |

**[Browse the lighthouse hub source →](docs/lighthouse/index.html)**

**[Open the reviewed proof hub on GitHub Pages →](https://pspdfkit.github.io/nutrient-extraction-samples/docs/lighthouse/?utm_campaign=de_lighthouse_pilot_v1&utm_source=github&utm_medium=repository&utm_content=cross_vertical.github_sample.v01.proof)**

This is a three-document demonstration, not an accuracy, production, or performance benchmark. “Reviewed” means that an independent field-by-field evidence audit was recorded; it is not user approval or publication approval. Three of the four mismatches are exposed by returned metadata. The mortgage servicer primary and nested regions clip the decisive final period, so the fourth issue remains visible in the expected-versus-actual ledger beside the returned region. The forms contain privacy-safe demo values—not real people, real claims, PHI, lending decisions, adjudication, coverage decisions, or clinical determinations.

Pricing and credit usage can change. Check the current official pricing before making a live request. The retained evidence does not independently reconcile account usage or billing.

---

## Five additional documents, five hard problems

Each demo is a Python script that calls the API and generates a self-contained HTML file. The generated output is committed — open any of them in a browser with no signup, no key, and no install.

Expand All @@ -48,7 +72,7 @@ Each demo is a Python script that calls the API and generates a self-contained H
### CMS-1500 Health Insurance Claim
`demos/grounded_extraction/` · Data Extraction

Table row extraction across a dense printed grid. The form uses a dropout-red ink grid that scanners typically destroy — procedure codes, diagnosis codes, billing amounts, and provider fields come back correct, each highlighted in the exact table cell it came from.
Table row extraction across a dense printed grid. The reviewed output includes service dates, procedure codes, billing amounts, and provider fields, with displayed grounded values linked to their returned source regions. The source checker also exposes two incorrect service dates in the committed response.

**[Open demo →](https://pspdfkit.github.io/nutrient-extraction-samples/demos/grounded_extraction/output/index.html)**

Expand All @@ -58,7 +82,7 @@ Table row extraction across a dense printed grid. The form uses a dropout-red in
### Indiana State Birth Record
`demos/birth_record_extraction/` · Data Extraction

Signature block detection on a mixed handwritten/printed document. The schema separates the *printed name* from the adjacent *cursive signature* — two visually adjacent fields that trip up most models. Includes a before/after tuning comparison showing how schema description specificity fixes extraction errors.
Signature block detection on a mixed handwritten/printed document. The schema separates the *printed name* from the adjacent *cursive signature*. The tuning notes document one observed mismatch and a later reviewed response after the schema description was clarified.

**[Open demo →](https://pspdfkit.github.io/nutrient-extraction-samples/demos/birth_record_extraction/output/index.html)**

Expand All @@ -70,7 +94,7 @@ Signature block detection on a mixed handwritten/printed document. The schema se
### Making Home Affordable — RMA
`demos/rma_extraction/` · Data Extraction

Value isolation in a dense 3-column financial table. Monthly Income, Total Assets, and Total Expenses sit side by side with nearly identical labels. The tuning story shows a vague schema description pulling the wrong column, and a precise one fixing it — with the highlight visually confirming the correction.
Value isolation in a dense 3-column financial table. Monthly Income, Total Assets, and Total Expenses sit side by side with similar labels. The tuning notes compare one wrong cached result with a later reviewed result after the schema description was clarified; the highlights show the regions returned for each response.

**[Open demo →](https://pspdfkit.github.io/nutrient-extraction-samples/demos/rma_extraction/output/index.html)**

Expand All @@ -92,7 +116,7 @@ Full narrative extraction from a free-text legal field. `incident_reason` captur
### Small Residential Income Property Appraisal Report
`demos/parse_citations/` · Parse API

The document decomposed into semantic blocks — paragraphs, section headers, tables — each with spatial coordinates. This is the RAG citation case: every block in the sidebar links back to its exact location, so a retrieval pipeline can cite its source precisely. Reach for Parse when you need structure-aware chunking rather than field-level extraction.
The document decomposed into semantic blocks — paragraphs, section headers, and tables — with spatial coordinates. In this reviewed response, each rendered block links to its returned source region. Reach for Parse when you need structure-aware chunking rather than field-level extraction.

**[Open demo →](https://pspdfkit.github.io/nutrient-extraction-samples/demos/parse_citations/output/index.html)**

Expand Down Expand Up @@ -166,29 +190,32 @@ Parse credits are charged by mode and page. **Extract requests add 6 credits per
| `understand` | 9 |
| `agentic` | 18 |

All five demos use `agentic` mode.
All eight demos use `agentic` mode.

| Demo | Pages | Normal run | If run live |
|---|---:|---:|---:|
| CMS-1500 | 1 | 0 | 24 |
| Indiana Birth Record | 1 | 0 | 24 |
| Request for Modification | 4 | 0 | 96 |
| CA SC-100 | 4 | 0 | 96 |
| **Extraction subtotal** | **10** | **0** | **240** |
| Authentic-form mortgage verification | 1 | 0 | 24 |
| Authentic-form insurance claim intake | 1 | 0 | 24 |
| Authentic-form prior authorization | 1 | 0 | 24 |
| **Extraction subtotal** | **13** | **0** | **312** |
| Appraisal Report (Parse) | 4 | 0 | 72 |
| **Total** | **14** | **0** | **312** |
| **Total** | **17** | **0** | **384** |

Every normal generator run replays its committed cache and costs **0 credits**. Network access is opt-in through `--refresh`: refreshing the four extraction demos costs 240 credits, and refreshing all five costs 312 credits.
Every normal generator run replays its committed cache and costs **0 credits**. Network access is opt-in through `--refresh`: refreshing all seven extraction demos costs 312 credits, and refreshing all eight demos costs 384 credits.

The free tier includes 5,000 credits per month, enough for about **16 live all-five refreshes**.
The free tier includes 5,000 credits per month, enough for about **13 live all-eight refreshes**.

---

## Privacy and PII before you commit

Extraction lifts document values into every derivative, so review more than the PDFs. Before committing a document swap, check:

- `demos/*/data/*.pdf` — public-source or synthetic only
- `demos/*/data/*.pdf` — public-source, synthetic, or authentic public forms with privacy-safe demo values only
- `demos/*/output/metadata.json` — document values and non-billing response metadata
- `demos/parse_citations/data/*_parse_results.json` — document text
- `demos/*/cache/*.json` — the full `output` payload
Expand Down Expand Up @@ -227,7 +254,7 @@ The pin is deliberate: install resolves against upstream `main`, so record the r

## Sample code disclaimer

All documents, names, identifiers, and records in this repository are public-source or synthetic. Extraction results are illustrative only.
Documents in this repository are public-source, synthetic, or authentic public forms populated with privacy-safe demo values. Extraction results are illustrative only.

This repository is sample code, not a production-ready workflow. Before processing real documents:

Expand All @@ -241,7 +268,7 @@ This repository is sample code, not a production-ready workflow. Before processi

To suggest a new document type, open an issue with the document name and the fields to extract. To add one yourself, copy an existing demo folder, swap the PDF and `docs.json`, and run the generator — then run the PII review above before committing.

Shared helpers live in `common/` (cache, escaping, rendering), and all five demo generators use them.
Shared helpers live in `common/` (cache, escaping, rendering), and all eight demo generators use them.

## License

Expand Down
4 changes: 4 additions & 0 deletions common/assets/logotype/nutrient-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading