The goal: estimating my capital gains
I'm building a personal finance app to estimate my capital gains and losses, work out how much my losses could offset my gains, and plan for what I might owe the IRS. I also want to see what selling a particular lot would mean before I sell it.
That depends on getting the purchase history right. One extraction listed only the first lot in a stock sale. The other lots were in the extracted text, but the result didn't connect them to the sale. A lot is a group of shares bought together, with its own purchase price. Leaving one out changes the gain calculation.
Our investments are spread across my wife's accounts and mine. I want to check for possible wash sales across those accounts. SoFi and Wealthfront show gains and losses I can compare against, though their current totals and my downloaded statements don't always cover the same period.
Some results were off by several hundred dollars. Checking the statements revealed missing lots, wrong fractional-share quantities and wrong prices. I need to catch those mistakes before using the estimate.
My Plaid connection hasn't provided the lot information I need. CSV exports vary by brokerage, and some accounts only offer PDFs. I've been extracting the statements and checking the results by eye. It's frustrating work, and I can miss things too.
I compared PDF readers as a first step toward fixing this. The test measures how well they recover numbers from statements. I still need to check complete lots and their links to sales before I can trust the app's gain estimates.
The test: eight readers, 78 PDFs
I'd tried several PDF readers, and each missed different things. This was my first time trying an LLM for the problem. I compared eight ways of reading the same 78 financial PDFs to see which numbers each could recover.
- financial PDFs
- 78
- physical pages
- 531
- institution groups
- 18
- decimals to find
- 10,358
- ways to read them
- 8
The set included account statements, trade confirmations, credit cards, loans and retirement documents. Most were digital PDFs, though some had regions that contained only images. This wasn't a test of damaged scans or handwriting.
I checked whether each reader found the decimal numbers on each page. I didn't check whether it put those numbers into the right transactions or calculated the right gain. Most of my answer key came from the PDFs' embedded text, so a match means agreement with that list. The scores below measure number recovery; the row-swap example shows what they miss.
How I scored the results
I used two scores. The first counts how many decimal numbers a reader found, including repeated values. For each PDF, I also checked whether every page matched the answer key's values and counts, with no extras. The output had to pass my format checks too. I call that a full match. It still says nothing about which row a number belongs to.
The number-recovery score treats every decimal equally. A wrong number in a disclosure might not affect my gains; a missing lot can. I haven't measured the dollar effect of those errors.
What the score misses
My checker counts numbers without knowing which transaction they belong to. Here's an invented example with two sales and four numbers. Moving a cost-basis value to the wrong sale changes the gain breakdown, but the checker still passes it.
- AlphaLong termproceeds 120basis 100gain 20
- BetaShort termproceeds 80basis 60gain 20
- Numbers found
- all 4 match the answer key
- Total gain
- 40
- Long-term gain
- 20
- Short-term gain
- 20
- AlphaLong termproceeds 120basis 60gain 60
- BetaShort termproceeds 80basis 100gain −20
- Numbers found
- all 4 match the answer key
- Total gain
- 40
- Long-term gain
- 60
- Short-term gain
- −20
These are invented transactions. My checker matched all four numbers in both versions because it ignores which sale they belong to.
Swap the two cost-basis values and the total gain stays at 40. But the long-term gain rises from 20 to 60, and the short-term gain becomes a loss of 20. All four numbers are still there. My checker can't tell that two are attached to the wrong sale.
This is a demonstration of the checker's blind spot, not a mistake I measured from a reader. To test the app, I need to check every lot and the sale it belongs to. Even a matching total won't catch all the errors.
Results: number recovery and processing time
Number recovery
- Embedded text layer
- Classic OCR
- Layout pipeline
- Vision model
Hover or tap a row for its numbers.
All readers processed the same 78 PDFs once. Embedded text supplied most of the answer key, so its own score is not an independent accuracy check.
Tesseract in its default mode found 98.4% of the decimal numbers, but only 38 of 78 PDFs were full matches. Finding nearly all the numbers still left errors spread across many documents.
Codex had 67 full matches and Docling's text reader had 65. That's a difference of two PDFs. To compare them properly, I need to know which documents each passed and failed, not just the totals. The published data doesn't contain those pairs, and several statements may share the same institution's template. These counts aren't enough to establish a winner.
Embedded text supplied most of the answer key. That favors readers using the same text, and a mistake in the key could look like a reader's mistake. I haven't checked every page against its image.
Processing time
I gave Codex images of the pages. It took 43.2 minutes to process the set and had 67 full matches. Docling read the embedded text in 10.7 minutes and had 65. Docling with RapidOCR took 38.8 minutes and had 56 full matches.
- Embedded PDF text
- Docling native text
- Tesseract PSM 3
- Tesseract PSM 6
- OCRmyPDF force OCR
- Docling + Tesseract
- Docling + RapidOCR
- Codex Sol
- Embedded text layer
- Classic OCR
- Layout pipeline
- Vision model
Point values and exact plot coordinates
- Embedded PDF text: 0.10 minutes for 78 PDFs, 73 full matches (93.6%). Raw plot values: 0.10244150201712425 minutes; full-match ratio 0.9358974358974359.
- Docling native text: 10.7 minutes for 78 PDFs, 65 full matches (83.3%). Raw plot values: 10.719254440998581 minutes; full-match ratio 0.8333333333333334.
- Tesseract PSM 3: 14.9 minutes for 78 PDFs, 38 full matches (48.7%). Raw plot values: 14.891557443142908 minutes; full-match ratio 0.48717948717948717.
- Tesseract PSM 6: 13.6 minutes for 78 PDFs, 33 full matches (42.3%). Raw plot values: 13.638123257105084 minutes; full-match ratio 0.4230769230769231.
- OCRmyPDF force OCR: 10.5 minutes for 78 PDFs, 39 full matches (50.0%). Raw plot values: 10.543020153489003 minutes; full-match ratio 0.5.
- Docling + Tesseract: 18.8 minutes for 78 PDFs, 49 full matches (62.8%). Raw plot values: 18.79519032841393 minutes; full-match ratio 0.6282051282051282.
- Docling + RapidOCR: 38.8 minutes for 78 PDFs, 56 full matches (71.8%). Raw plot values: 38.82563369992034 minutes; full-match ratio 0.717948717948718.
- Codex Sol: 43.2 minutes for 78 PDFs, 67 full matches (85.9%). Raw plot values: 43.16912138829066 minutes; full-match ratio 0.8589743589743589.
Hover or tap a point for its numbers.
Log scale on the horizontal axis. One run per reader, including rendering and failed attempts. Local tools ran on an M3 laptop; Codex used a remote model. Docling model warmup is excluded.
Those are the times for these particular runs. The readers used different resolutions and processing steps. Docling's model warmup is excluded, the local tools shared my laptop with other desktop activity, and Codex used a remote model. I also didn't time the manual corrections. A faster extraction could still leave me with more work afterward.
Results by statement type
The results change when I group the PDFs by document type. Embedded text matched 6 of 10 loan documents; Codex matched all 10. On brokerage statements, embedded text matched all 26, while Codex matched 20.
- Embedded text layer
- Classic OCR
- Layout pipeline
- Vision model
Hover or tap a cell for its counts.
The groups with the lowest average full-match rate appear first. Acorns, Fidelity, Stockpile and retirement each have just one PDF; those rows cannot establish a trend.
Rocket Mortgage's PDFs had a text layer, but it left out some numbers visible on the page. Codex matched all five documents. On the five Comenity and five Discover documents, Docling's text reader matched all ten, while Tesseract's default mode matched none. Reading the page image helped in one case and hurt in the other.
OCRmyPDF found only 14.5% of the decimal numbers in the Robinhood documents. A 73-page statement failed during rendering, before OCR could start. Rendering pages separately got that statement through, but the result still matched only 1,130 of 1,142 numbers.
I'd like to try comparing the text layer with a reader using page images and flagging disagreements for review. I haven't tested that approach. Agreement wouldn't prove either result correct, but a disagreement would give me somewhere to look.
Open a family below for full-match, recall and precision counts. The retirement group contains only one PDF.
Bank: 17 PDFs, 79 pages
| Reader | Full-match PDFs | Decimal recall | Decimal precision |
|---|---|---|---|
| PDF text* | 100.00%17 / 17 | 100.00%735 / 735 | 100.00%735 / 735 |
| Docling text | 82.35%14 / 17 | 99.59%732 / 735 | 99.73%732 / 734 |
| Tess PSM 3 | 52.94%9 / 17 | 97.41%716 / 735 | 99.44%716 / 720 |
| Tess PSM 6 | 47.06%8 / 17 | 96.05%706 / 735 | 98.74%706 / 715 |
| OCRmyPDF | 64.71%11 / 17 | 98.37%723 / 735 | 99.72%723 / 725 |
| Docling + Tess | 82.35%14 / 17 | 99.59%732 / 735 | 100.00%732 / 732 |
| Docling + Rapid | 82.35%14 / 17 | 99.86%734 / 735 | 99.73%734 / 736 |
| Codex Sol | 100.00%17 / 17 | 100.00%735 / 735 | 100.00%735 / 735 |
Brokerage: 26 PDFs, 312 pages
| Reader | Full-match PDFs | Decimal recall | Decimal precision |
|---|---|---|---|
| PDF text* | 100.00%26 / 26 | 100.00%8,259 / 8,259 | 100.00%8,259 / 8,259 |
| Docling text | 88.46%23 / 26 | 99.92%8,252 / 8,259 | 99.92%8,252 / 8,259 |
| Tess PSM 3 | 46.15%12 / 26 | 98.68%8,150 / 8,259 | 99.71%8,150 / 8,174 |
| Tess PSM 6 | 50.00%13 / 26 | 97.43%8,047 / 8,259 | 99.73%8,047 / 8,069 |
| OCRmyPDF | 50.00%13 / 26 | 82.71%6,831 / 8,259 | 99.48%6,831 / 6,867 |
| Docling + Tess | 50.00%13 / 26 | 99.77%8,240 / 8,259 | 99.90%8,240 / 8,248 |
| Docling + Rapid | 69.23%18 / 26 | 99.88%8,249 / 8,259 | 99.57%8,249 / 8,285 |
| Codex Sol | 76.92%20 / 26 | 99.93%8,253 / 8,259 | 99.89%8,253 / 8,262 |
Card: 19 PDFs, 78 pages
| Reader | Full-match PDFs | Decimal recall | Decimal precision |
|---|---|---|---|
| PDF text* | 100.00%19 / 19 | 100.00%696 / 696 | 100.00%696 / 696 |
| Docling text | 89.47%17 / 19 | 99.14%690 / 696 | 100.00%690 / 690 |
| Tess PSM 3 | 52.63%10 / 19 | 97.41%678 / 696 | 99.56%678 / 681 |
| Tess PSM 6 | 26.32%5 / 19 | 93.82%653 / 696 | 98.64%653 / 662 |
| OCRmyPDF | 36.84%7 / 19 | 95.98%668 / 696 | 99.11%668 / 674 |
| Docling + Tess | 63.16%12 / 19 | 97.84%681 / 696 | 99.56%681 / 684 |
| Docling + Rapid | 68.42%13 / 19 | 98.71%687 / 696 | 99.85%687 / 688 |
| Codex Sol | 73.68%14 / 19 | 100.00%696 / 696 | 99.29%696 / 701 |
Education savings: 5 PDFs, 18 pages
| Reader | Full-match PDFs | Decimal recall | Decimal precision |
|---|---|---|---|
| PDF text* | 100.00%5 / 5 | 100.00%132 / 132 | 100.00%132 / 132 |
| Docling text | 100.00%5 / 5 | 100.00%132 / 132 | 100.00%132 / 132 |
| Tess PSM 3 | 100.00%5 / 5 | 100.00%132 / 132 | 100.00%132 / 132 |
| Tess PSM 6 | 100.00%5 / 5 | 100.00%132 / 132 | 100.00%132 / 132 |
| OCRmyPDF | 100.00%5 / 5 | 100.00%132 / 132 | 100.00%132 / 132 |
| Docling + Tess | 100.00%5 / 5 | 100.00%132 / 132 | 100.00%132 / 132 |
| Docling + Rapid | 100.00%5 / 5 | 100.00%132 / 132 | 100.00%132 / 132 |
| Codex Sol | 100.00%5 / 5 | 100.00%132 / 132 | 100.00%132 / 132 |
Loan: 10 PDFs, 40 pages
| Reader | Full-match PDFs | Decimal recall | Decimal precision |
|---|---|---|---|
| PDF text* | 60.00%6 / 10 | 98.87%351 / 355 | 100.00%351 / 351 |
| Docling text | 60.00%6 / 10 | 98.87%351 / 355 | 96.96%351 / 362 |
| Tess PSM 3 | 20.00%2 / 10 | 94.37%335 / 355 | 99.41%335 / 337 |
| Tess PSM 6 | 10.00%1 / 10 | 85.92%305 / 355 | 97.13%305 / 314 |
| OCRmyPDF | 30.00%3 / 10 | 95.21%338 / 355 | 100.00%338 / 338 |
| Docling + Tess | 40.00%4 / 10 | 97.75%347 / 355 | 97.47%347 / 356 |
| Docling + Rapid | 60.00%6 / 10 | 98.87%351 / 355 | 96.96%351 / 362 |
| Codex Sol | 100.00%10 / 10 | 100.00%355 / 355 | 100.00%355 / 355 |
Retirement: 1 PDF, 4 pages — single-document group
| Reader | Full-match PDFs | Decimal recall | Decimal precision |
|---|---|---|---|
| PDF text* | 0.00%0 / 1 | 96.69%175 / 181 | 100.00%175 / 175 |
| Docling text | 0.00%0 / 1 | 96.69%175 / 181 | 100.00%175 / 175 |
| Tess PSM 3 | 0.00%0 / 1 | 99.45%180 / 181 | 100.00%180 / 180 |
| Tess PSM 6 | 100.00%1 / 1 | 100.00%181 / 181 | 100.00%181 / 181 |
| OCRmyPDF | 0.00%0 / 1 | 96.13%174 / 181 | 98.31%174 / 177 |
| Docling + Tess | 100.00%1 / 1 | 100.00%181 / 181 | 100.00%181 / 181 |
| Docling + Rapid | 0.00%0 / 1 | 99.45%180 / 181 | 100.00%180 / 180 |
| Codex Sol | 100.00%1 / 1 | 100.00%181 / 181 | 100.00%181 / 181 |
Metric definitions and source
- Full-match PDFs
- PDFs with matching decimal inventories on every page, no extras, and valid output / attempted PDFs.
- Decimal recall
- Matching signed decimal occurrences / expected decimal occurrences. Repeated values count separately.
- Decimal precision
- Matching signed decimal occurrences / emitted decimal occurrences. Extra values lower precision.
Zero denominators are unavailable, not zero-percent results. Failed attempts stay in the PDF/expected-value denominators. Benchmark date: . Published aggregate JSON, fullCorpusResults.byDocumentFamily. * PDF text is the reference baseline. No private PDFs are loaded.
Focus the chart and use arrow keys, or tap a method, for its exact count.
Number agreement does not establish financial correctness or transaction relationships. PDF text supplied most reference values, so its agreement is circular; its dot is hollow. These are selected personal documents, not a representative sample.
Checking the extracted values
Before I use an extracted value in the app, I need to check both the output format and the value itself. I tried format checks, arithmetic checks and a few retries on the errors I found.
Output-format checks
Codex found 99.942% of the expected decimal numbers, the highest recovery rate in this test. But the result for one PDF failed my format check.
I had asked for a list containing only decimal numbers. That result included a whole number. My basic JSON check let it through; a stricter check caught it. Under the benchmark's rule, I excluded the entire PDF's result, including 770 numbers that matched the answer key.
- Embedded text layer
- Classic OCR
- Layout pipeline
- Vision model
Hover or tap a row for its numbers.
A failed output check excludes the whole PDF result. The percentage at right counts matching numbers from results that passed. These checks do not verify the transactions.
The rule changed Codex's score from 99.94% to 92.5%. It hadn't misread another 770 numbers; I had stopped counting them because their result failed the format check. I could try repairing the output, retrying it or rejecting only the affected page. I haven't tested those options on this PDF.
Codex passed the output checks on 77 of 78 PDFs, and OCRmyPDF passed on 76. The other six passed on all 78. Passing those checks only means I can process the output. It doesn't mean the numbers or transactions are right.
Checks for wrong values
Other Codex mistakes passed the format check. One purchase price had a wrong digit, and the same cash amount was misread in two places. The values looked plausible. I tried several checks to see which would catch them.
- Missed itCompare repeated valuesBoth copies of the cash amount had the same wrong value.
- Missed itCompare two model configurationsBoth returned the same wrong purchase price.
- Missed itAsk the model to flag uncertaintyIt reported no uncertainty, even where I confirmed mistakes.
- Missed itCheck the basic JSON structureThe list passed, even with a whole number where I required a decimal.
- Caught itMultiply quantity by price and compare with cashCaught the cash error after allowing for rounding and printed precision.
- Not checkedCompare the list of numbersDoesn't check which sale a number belongs to. The swap in Figure 1 still passes.
I also ran a second Codex configuration on eight PDFs. Both configurations fully matched the five short documents I had chosen in advance. On three harder documents I chose after seeing a failure, the first matched 1 and the second matched 2. The second corrected the cash amount but repeated the wrong purchase price. Their agreement wouldn't have caught that price error.
Retrying a misread page
I then retried one misread page three times at each of three image settings: the full page at 180 dpi, the full page at 300 dpi, and a row crop at 600 dpi.
- Full page at 180 dpi2/3
- Full page at 300 dpi3/3
- Row crop at 600 dpi3/3
I chose this page after it failed. These single-page retries differ from the four-page chunks in the main run; nine attempts cannot establish a general success rate.
All three attempts at 300 dpi and all three row crops matched the decimal list. Two of the three attempts at 180 dpi matched. That's only nine calls on one page I already knew was troublesome. The image settings and page context differed from the main run, so I need more cases before deciding how to retry failures.
Related research
I looked for published benchmarks to compare with mine. These four cover related problems, but none checks whether bank or brokerage values end up in the right transaction.
- Table layout and cell text. Nunes and colleagues compared a table-structure model plus OCR with multimodal LLMs on PubTables-1M, a set of scientific tables. They report that the structure-plus-OCR approach still has a slight edge on table layout, while the LLMs are far better at the text inside cells. Reading a value doesn't establish which cell it belongs to. Paper (XLLM 2025).
- Correct JSON can contain wrong values. The Structured Output Benchmark tested 21 models. Its outputs almost always followed the required format, but the best value accuracy was 83.0% on text and 67.2% on images. A format check can reject my whole-number error. It cannot tell that a correctly formatted price is wrong. Paper (April 2026).
- Larger schemas were harder to follow. ExtractBench pairs 35 PDFs with JSON Schemas. Its authors report that performance drops as schemas grow, down to 0% valid output on a 369-field financial reporting schema across all six models they tested. That gives me a reason to try a small schema for each statement type. Paper (February 2026).
- OCR followed by a smaller model. A team at a financial company reports that OCR followed by a compact vision-language model got 8.8 times the field-level accuracy of feeding whole documents to large vision-language models, at 0.7% of the GPU cost. They used an internal set of scanned financial documents. I'd need to test the approach on my statements. Paper (October 2025).
OmniDocBench covers nine document types and compares PDF-reading tools with vision-language models. I haven't used it to draw conclusions about financial statements. For my next test, I need examples where the numbers can be right and the transaction still wrong.
Test limitations
- Most of the answer key came from embedded text. I added ten values from page images and corrected the checker after inspecting disagreements. I haven't independently checked all 531 pages.
- Each workflow ran once, on one laptop with desktop activity running. The times are observed, not estimated.
- I chose recent documents I had available, rather than a random sample. Statements from an institution may share a template. Acorns, Fidelity and Stockpile contribute only one PDF each.
- I checked decimal numbers only. Whole numbers, dates, reading order and transaction relationships are outside the score.
- Parenthesized decimals count as negative, including explanatory disclosures where the meaning isn't negative.
- The PDFs and raw evidence are private. The aggregate results are in a JSON file.
How the scores are calculated
- Recall
- The share of decimal values in the answer key that the reader found. Repeated values count separately; missing values lower the score.
- Precision
- The share of the reader's decimal values that match the answer key. Extra or wrong values lower the score.
- Full-match rate (exact PDF rate in the data)
- The share of attempted PDFs with the same decimal values and counts on every page, no extra values, and output that passes the format checks.
- How documents count
- I compare numbers within each page, then add the counts across all documents. Longer documents weigh more in recall and precision. Each PDF counts once in the full-match rate.
- An example
- If the answer key lists 100 numbers and a reader returns 95, with 90 matching, recall is 90% and precision is 94.74%. A wrong digit lowers both scores: the expected value is missing, and the wrong value is extra.
Versions and settings
- Machine
- Apple M3, 16 GiB RAM, CPU only. Desktop activity and swap were not isolated.
- Poppler
- 26.09.0, pdftotext -layout. Embedded text, not OCR.
- Tesseract
- 5.5.3, English, 300 dpi grayscale, PSM 3 and PSM 6 as separate runs, two threads.
- OCRmyPDF
- 17.13.0, force OCR, two jobs, PSM 3, optimization off. Wraps Tesseract.
- Docling
- 2.135.0, native text, full-page Tesseract and full-page RapidOCR as three workflows. Tables on, remote services off, about 216 dpi for full-page OCR.
- RapidOCR
- 3.9.1 on ONNX Runtime 1.31.0, local PP-OCRv6 detection and recognition.
- Codex
- CLI 0.162.0, existing ChatGPT login, 180 dpi color pages, up to four pages per chunk, 152 sequential calls. Requested gpt-6.1-sol at medium reasoning. The CLI did not expose a resolved model snapshot.
These are the versions installed on October 9, 2026, not claims about the latest releases.
Next steps for my finance app
The app needs complete, correctly linked lots, not just a list of matching numbers. I'd test the following workflow against independently labeled statements.
I'd start with a small JSON Schema for each statement type, asking for accounts, transactions and every lot in a sale. A required field can catch a missing price in a lot I've extracted. It won't catch an entire lot that was left out. I haven't built this test yet.
I also want to look into Jev, whose announcement describes defining output types in advance. I've only read the announcement, so I don't yet know whether it would help with these statements.
- Read the text layer first. Docling was fast and had 65 full matches in this set. Flag missing fields and parts of a page that contain only images.
- Ask a vision model to read the flagged pages. Codex is the one I tested, using gpt-6.1-sol at medium reasoning. I'd give it the required fields and compare it with OCR configured for the same task.
- Keep the source for every lot. Save the statement, page and row behind each value so I can check a mistake without searching the PDF again. Save progress per document so a failed attempt can be retried.
- Check that every lot is present. Use independently labeled statements to count missing lots, wrong values and lots attached to the wrong sale. Compare the quantities, proceeds and cost basis with any totals on the statement. Check the individual lots too, since a row swap can leave the total unchanged.
- Check the arithmetic and brokerage totals. Compare quantity times price with cash, allowing for rounding, printed precision and applicable adjustments. Compare gains with brokerage totals for the same period. Show unresolved values so I can correct them. Never let the model invent a missing cost basis.
This benchmark didn't change my app's extractor. For the next test, I need statements with independently labeled lots, including missing-lot cases and deliberately swapped rows like the example above.
I'd measure how many complete lots each reader recovers, how often it attaches a lot to the wrong sale, how much those mistakes change the gain estimate, and how long I spend correcting them. I'd keep each reader's result for each document so I can compare the same failures. I still need that test before relying on this app for tax planning.
Was this useful?
Thanks for the feedback.