Case study · AI document extraction
Freight ReaderTeaching a Document Pipeline to Read What It Had Never Seen
A cargo booking platform priced each shipment from an uploaded document. When a supplier sent a quotation, its AI pipeline returned zeros. We rebuilt it so the model reads and the code computes.
- Client
- International cargo booking platform
- Reads
- Packing lists and supplier quotations
- Pulls out
- Packages, weight and volume (CBM)
- Tested on
- 34 scenarios, five file formats
Product renamed. We do not name the client or its platform. Screens are illustrations, not screenshots.
01The problem
What Broke, and Why
The pipeline worked well on packing lists. One quotation showed where it would break.
- 01
Numbers that set the price
Package count, weight and volume decide what a shipment costs.
- 02
A quotation, not a packing list
No weight or CBM column, just one free-text cell per row.
- 03
Zeros, and different zeros
Each run returned different zeros. One invented 113 packages.
- 04
Confident and wrong
A prompt fix gave 1.76 CBM against a true 19.33, and passed validation.
02What we built
Five Stages, Each One Testable
One long prompt became five stages, each tested on its own.
Structure-Preserving Parsing
Spreadsheets keep their real grid: merged cells, columns and blanks.
Archetype Classification
A cheap call identifies the document shape first.
Specialist Extraction
A short prompt per shape reads facts only. No arithmetic.
Calculation in Code
Unit conversion and every multiplication, in unit-tested code.
Verification
Density checks and cross-checks, so the numbers agree with each other.
Unknown Means a Person
A document that matches no known shape goes to a person.
03How it works
From Upload to Priced Booking
What happens between a customer uploading a document and the booking getting its numbers, and what happens when a document matches nothing the system knows.
- Document uploaded with a bookingPacking list or supplier quotation
- Structure keptReal grid: merged cells, columns and blanks
- Document shape identifiedOne cheap routing call
- Facts read, nothing calculatedOnly values it can literally see
- Totals calculatedUnit conversion and every multiplication, unit tested
- Numbers checkedDensity, cross-checks, omissions flagged
- Packages, weight and volumeReady to price the shipment
Workflow from a real project, simplified
04Inside the product
Inside the Pipeline
The document that broke the old pipeline, and what each stage does with it.
Packing column, as sent
1pc/opp 60pcs/inner box 120pcs/ctn 28*26*16CM G.W.:11kgs
No weight column. No CBM column. Three units in one cell.
Before and after. The quotation that broke the old pipeline: one free-text cell per row, and the numbers before and after the rebuild. Illustration.
05Challenges and solutions
What Was Hard, and How We Solved It
Three things that had to be true before the numbers could price a booking.
- 01
Values That Have to Be Worked Out
ChallengeCartons, volume and weight had to be derived from one free-text cell.
SolutionThe model reads “120pcs/ctn” and “28*26*16CM”. Code does the maths.
- 02
A Prompt Too Long to Pay Attention
ChallengeOne 5,000 word prompt read and calculated, and got worse with every new document type.
SolutionA routing call picks the shape and a short prompt reads it. Tokens fell from 5,729 to 1,422.
- 03
Right Numbers for the Right Reasons
ChallengeA figure can be well formed and still ten times off.
SolutionVerification found 18 items at 250 g in a 5.5 kg carton: the extra kilogram is packaging.
06How we delivered
How We Got There
From a pipeline that worked on what it knew to one built for the next document it has never seen.
- Baseline
One prompt across 34 scenarios and five file formats, until a quotation returned zeros.
- Diagnosis
Prompt fixes gave confident wrong answers. The arithmetic had to leave the model.
- Rebuild
Five stages. Exact on the quotation and identical across three runs.
07Proof
Exact, Stable and 75% Cheaper
On the document that broke the old pipeline.
- 205packages, exact
- 19.33CBM total volume, exact
- 1,463.5 kgtotal weight, exact
- 75%fewer tokens per call
- Identical results on 3 of 3 runs.
- The model reads; code does every calculation.
- Documents that match no known shape go to a person.
Tell Us What You Want to Grow. We Will Show You How to Build It.
Book a free 30 minute consultation with our team. No cost and no obligation.