Extract Fields From Commercial Invoices for Customs Entry
Last updated: November 29, 2026
Quick Overview
Design an ML system that reads commercial invoices and packing lists uploaded by shippers (PDFs, scans, spreadsheets) and extracts the fields a customs entry needs: seller, buyer, line items, quantities, values, currency, country of origin and suggested HS codes, with humans reviewing uncertain results.
Flexport
November 29, 20260
0
0 solved
Design an ML system that reads commercial invoices and packing lists uploaded by shippers (PDFs, scans, spreadsheets) and extracts the fields a customs entry needs: seller, buyer, line items, quantities, values, currency, country of origin and suggested HS codes, with humans reviewing uncertain results.
Customs brokerage at Flexport depends on accurate data from documents that every supplier formats differently, and errors carry penalties. This round checks whether you can design document understanding with calibrated confidence, a human review loop, and metrics tied to broker workload and entry accuracy.
What the Interviewer Expects
- Frame the business metric: broker minutes per entry and post-filing correction rate
- Choose an extraction approach (layout-aware model or LLM with schema) and justify it
- Produce per-field confidence and route low-confidence fields to review
- Use reviewer corrections as training data without leaking customer data across tenants
- Validate extractions with business rules (line totals, currency, quantity units)
- Plan offline and online evaluation and drift monitoring
Key Topics to Cover
How to Approach This
- Start by mapping the business objective to a concrete ML objective and metric.
- Cover the full pipeline: data collection, feature engineering, model selection, training, serving.
- Discuss online vs offline evaluation. Plan an A/B test to validate real-world impact.
- Address the serving latency budget and whether batch or real-time inference is needed.
- Think about the data flywheel: how user feedback improves the model over time.
Possible Follow-up Questions
- How would you suggest HS codes, and why should that be a separate model from field extraction?
- A large supplier changes its invoice template. How do you notice and recover?
- How do you handle multilingual invoices from Vietnam, China and Mexico?
- When would you allow a fully automated entry with no human touch?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice ML System Design ProblemsSample Answer
Requirements
Inputs: PDFs (digital and scanned), images, XLSX. Outputs: a structured invoice with header fields and line items, each with a confidence and a pointer to the source region. Goals: cut broker keying t...
High-Level Design
- Ingestion: file classification (invoice, packing list, bill of lading, other) with a light image or text classifier.
- Text and layout: native PDF text when present, otherwise OCR, produci...