How Document Extraction Works
A plain-language walkthrough of what happens from the moment you upload a document to when it's ready for review.
When you upload a document to CargoLint, a pipeline reads it, works out what kind of document it is, extracts its fields, scores how well it read them and checks the result. Here is what happens at each step.
Step 1: Upload
You upload a PDF, PNG, JPEG or TIFF file of up to 20 MB from the dashboard, through the API, or by email to your organization’s intake address. The file is stored and queued for processing. Every fresh upload passes a brief safety scan before processing begins.
Step 2: Reading the text and the language
CargoLint reads the page text from the PDF’s own text layer or, for a scan, with optical character recognition (OCR), and detects the language. A scan is also read from the page image, which helps with tables that OCR breaks apart.
CargoLint reads English documents. A document in another language fails, with the detected language named, once its kind is known and before any fields are read. Forms printed in several languages by design, such as CMR consignment notes and phytosanitary certificates, are judged on what was filled in rather than on their printed labels. A badly degraded scan is not rejected for its language, since garbled text can look like another language.
Step 3: Classification
A language model decides which kind of document it is, among every kind in CargoLint’s registry: from the commercial invoice and the bill of lading to phytosanitary certificates, customs declarations and filing confirmations. Document Types lists them all.
Three outcomes end the pipeline here:
- A pack. When one PDF holds several documents, CargoLint splits it into them and processes each one as its own upload. The pack ends with the status Split.
- A kind CargoLint recognizes but does not read, such as a purchase order, a customs declaration or a CITES permit. The document is kept with its kind as its title and the status Recognized. Nothing is extracted, and it counts as present in its shipment.
- A blank or unreadable file. A document with no readable text, or one the model cannot classify, fails.
A file that matches no kind is kept as Unknown, a recognized kind, except an email attachment, which is skipped.
Step 4: Field extraction
For a kind CargoLint reads, a language model extracts that kind’s fields from the text. For example:
- From an invoice: seller, consignee and buyer, the manufacturer, invoice number and date, Incoterm, currency, line items with HS codes, and totals
- From a packing list: packages, counts, weights, dimensions and marks
- From a bill of lading or an air waybill: parties, ports or airports, vessel and voyage or flight, packages, weight, containers and seals
- From a certificate of origin: exporter, consignee, form, agreement named, origin criterion, country of origin and goods
- From a dangerous goods declaration: the UN number, proper shipping name, class and packing group on every line
- From a phytosanitary or health certificate: the issuing authority, the products with their botanical names or species, and the signature
Document Types & Fields lists every field of every kind.
Documents that share a layout are matched to a template. Once reviewers’ corrections on a template have proved accurate, they are applied to later documents of the same layout; until then, the language model reads the layout on its own.
Step 5: HS codes
On the lines of an invoice or a certificate of origin, CargoLint checks each declared HS code against the line’s description, and for a line without a code it suggests candidates. On a bill of lading, whose cargo lines describe freight rather than products, it checks only that the subheading exists and, past six digits, that the code is a current line of the destination’s tariff schedule. Suggestions are never applied automatically: a person confirms every code. See HS Code Classification.
Step 6: Rating each read
The AI rates how clearly it read each line, each party’s name, address and tax ID, and the key header fields: clearly readable, may have been garbled, or a guess. A value that may be garbled is a warning on its field and a guess is a problem that needs fixing; a clearly read value raises nothing.
Step 7: Reading checks
CargoLint checks the reading against the document itself:
- Can every identifier it returned be found in the document’s own text?
- Do the line quantities, prices and amounts agree, or does a gap suggest a misread digit?
- Is the scan clear enough to be read reliably?
Each problem has one level, and the document’s Quality score starts at 100% and loses 10% for each warning and 20% for each problem that needs fixing, together with the problems the document checks find in Step 9.
Step 8: Review queue routing
After the reading checks, the document is routed:
- Pending Approval (at most one warning from the reading, nothing to confirm): the document is ready for one-click approval. A reviewer signs off before it is marked complete.
- Review (one problem that needs fixing, or two warnings, from the reading, including unclear reads, HS codes to confirm, or a degraded scan): the document goes to your review queue. A team member opens it, checks the extractions, corrects them if needed and marks it complete.
The document checks in the next step count too: once they have run, a document whose problems from every source add up to one problem that needs fixing, or two warnings (a Quality score below 90%) moves to Review. A document can score high and still wait in Review until a person confirms its HS codes.
Step 9: Document and shipment checks
Once the fields are stored, the document checks run: required fields, sanctions screening, protected species, regulated goods, tax, the checks of the document’s own kind and, where the destination has a profile, its requirements. Until they have run, the Documents list shows Checks pending under the document. A sanctions match, a CITES Appendix I species, a check that could not complete, or problems that take its Quality score below 90% move a document from Pending Approval to Review.
If the document belongs to a shipment, the shipment is checked again: its documents are compared with each other, and its expected-documents checklist is rebuilt. See Shipment Consistency Checks.
How long processing takes
Most of the time goes to the language model calls for classification and extraction, so a document with more pages takes longer. If the AI service is unavailable, the document waits as Processing and, after five minutes, shows Waiting for AI until a retry worker picks it up again. See Document Statuses.
Why do some documents need review and others don’t?
Documents that go straight to Pending Approval have clear text, a standard layout, extractions that validate, and no HS codes waiting for confirmation.
Documents that need review have one or more of:
- Low-quality scans or handwriting
- Non-standard layouts or missing fields
- Extracted values that don’t validate (the math doesn’t add up)
- A line without a confirmed HS code, or a declared code CargoLint doubts
- A blocking finding from the document checks
Review isn’t a sign of failure. It is a designed part of the workflow: some documents are genuinely ambiguous and benefit from human judgment.
Monitoring
The dashboard shows shipments that need fixing, shipments that need documents, your review queue and the documents pending approval, with weekly counts of documents processed, cleared and flagged for review, and the average confidence. See Reading the Dashboard.