The interview problem

Practice prompt

Build a service that converts tables in enterprise PDFs into structured records. Inputs include scanned pages, merged cells and tables continuing across pages. The customer cares about correct quantities, units and row associations, not just readable text. Design extraction, validation, human review and correction propagation for 100,000 pages per day.

Original ML-design practice, not a reported company interview. Workload and table examples are hypothetical. Primary references retrieved September 27, 2026.

1. Define the output before choosing a model

Return a table graph or grid with cell text, row/column spans, header relationships, page coordinates and source-document version. Derived business records reference those cells and include parsed values, units, confidence and validation status. Preserve raw text separately from normalized values.

Distinguish blank, unreadable, not applicable and numeric zero. Define whether a merged value applies once to a group or independently to each detail row; that interpretation may require a document-specific schema. Do not silently fill missing cells from nearby rows.

Keep extraction separate from downstream execution. A parsed purchasing table is evidence for a proposed record, not authorization to place an order. Restrict document access, review and exported records to the customer's existing permission boundary.

2. Split layout, text and semantics

Use upload validation, document storage, page rendering, table detection, structure recognition, text alignment, schema mapping and a validation/review stage. Native PDF text can retain coordinates but may have broken reading order; scans require OCR. Detect rotation and suspicious text layers rather than assuming either path is always superior.

A structure model predicts rows, columns, spanning cells and headers. Assign text tokens using geometry and reading order, retaining ambiguous assignments. Multi-page continuation needs evidence such as consistent column structure and explicit continuation markers; proximity alone can join unrelated tables.

A language model may help map headers to a known schema, but constrain its output to extracted cells and require source references. Treat document content as data, not instructions to alter the pipeline. A fluent generated JSON object without grounded cell evidence should not bypass validation.

Version every stage. Job identity includes document hash/version and extraction configuration. A retry writes a new attempt or reuses a completed identical result; it must not create duplicate downstream business rows.

3. Trace a merged-cell mistake

Consider a table with columns for group, delivery date, quantity, unit price and group amount. Group G spans two detail rows. Its quantity cell “12” also spans both rows and represents the total quantity for the group. The detail descriptions identify two delivery dates, not two separate quantities. Unit price is 5, and an explicit group amount is 60.

A naive flattener copies the merged quantity into both rows and sums 12 × 5 + 12 × 5 = 120. OCR can be perfect while the downstream total doubles. The error is the interpretation of the span, not recognition of the digits.

Preserve the merged quantity as one cell linked to its two-row scope. Under the agreed schema, emit one group-level quantity of 12 and two delivery-date records with unknown allocations. Do not invent a six/six allocation just because it balances. If the schema requires quantities per delivery date, abstain on those fields and request review.

The displayed amount of 60 helps detect the doubled result, but a successful arithmetic check is not proof of correct extraction. A wrong quantity and wrong unit price can cancel, or the amount itself can be extracted from the wrong row. Validate source alignment as well as numeric consistency.

4. Layer checks and abstention

Validate syntax, types, allowed units, required fields, header scope and row spans. Normalize locale-dependent numbers only when the locale is established: “1,234” can mean different values under different conventions. Currency symbols and measurement units require explicit schema context.

For documents with subtotal or total fields, compare derived values using declared rounding and tolerance rules. Tax, discounts, shipping and rounding can explain apparent mismatches; do not alter extracted values until the sum happens to agree. A mismatch creates a review reason with the relevant cells highlighted.

Use separate confidence signals for detection, structure, OCR and schema mapping. Calibrate acceptance decisions on end-to-end field correctness rather than multiplying arbitrary model scores as though they were independent probabilities. High OCR confidence cannot compensate for an unresolved header or span.

Permit partial acceptance only when downstream semantics support it. A correct organization name may be usable while an ambiguous quantity remains blocked. If a critical field changes the meaning of the whole row, withhold that record rather than exporting a superficially complete one.

5. Build labels that match deployment

Annotate table bounds, cell spans, text, headers and business-schema mappings. Provide examples of blank and continuation cells to keep annotators consistent. Adjudicate ambiguity rather than forcing inconsistent labels into training data.

Public table datasets can initialize structure recognition, but scientific-page performance does not establish accuracy on the customer's forms. Evaluate on representative templates, scans, languages, page breaks and unusual layouts. Split by document family or template and time to avoid nearly identical forms leaking across training and test sets.

Report table detection recall, structure correctness, text errors, critical-field accuracy and whole-record accuracy. Also measure accepted-record precision and acceptance coverage: rejecting everything achieves no useful automation. Keep failed and missing tables in the end-to-end denominator.

6. Budget inference and review

At 100,000 pages/day, average arrival rate is about 1.16 pages/s. Assume a tenfold peak and measured throughput of two pages/s per worker for the complete extraction path. Peak demand is about 11.57 pages/s, requiring six workers at theoretical full utilization. This rounds up a 5.79-worker demand; six workers would still run at about 96.5% utilization at that peak. Capacity for retries, variance and failures requires additional headroom.

If 20% of pages contain tables and 10% of those pages need review, that is 2,000 reviewed pages/day. At two minutes per page, review requires 4,000 minutes or 66.67 staff-hours/day. Pages can contain several tables; measure actual review units and rework rather than assuming one page equals one easy task.

At an assumed 1 MB per rendered page, one day's images occupy 100 GB and thirty days occupy 3 TB before replication and source PDFs. Retention, thumbnail generation and access controls affect storage design. Avoid keeping sensitive rendered pages indefinitely merely because they are useful for debugging.

7. Make corrections reproducible

The review console shows the source crop, predicted structure and proposed record side by side. A reviewer can change cell boundaries, spans or semantic scope, not just edit a final number. Record the reason, source version and corrected structure so a future extraction can learn from the actual failure.

Publish corrected results as a new extraction version. Require a conditional update against the reviewed source and extraction versions; a stale reviewer or reprocessing job cannot overwrite a newer correction. Conflicts return to review with both versions visible. Use stable document/table identities plus explicit split/merge lineage when table boundaries change. Downstream consumers replace or supersede prior records by version; corrections must not append another payable line or inventory adjustment.

Monitor error reasons and review load by template and source. A sudden increase in merged-cell errors can justify holding that template while unaffected traffic continues. Roll back the model or parser configuration, reprocess affected documents and reconcile already exported records. Model rollback alone does not undo downstream actions.

8. Failure tests and self-review

Test a missing table, repeated page header, rotated scan, merged quantity, unreadable minus sign, conflicting total, duplicated upload and reviewer correction arriving during reprocessing. Verify lineage and acceptance status survive retries and that unresolved critical fields never silently become zero.

Follow-ups: Can perfect OCR still yield a wrong total? When should two page fragments be joined? What does accepted-record precision omit? How do corrected cell spans propagate downstream? What happens when review capacity is exhausted?

Score 0–2 each for the output contract, layout/text separation, worked semantic failure, representative evaluation and versioned correction flow. Strong answers preserve uncertainty instead of manufacturing a complete table.

Sources and next steps

The merged-quantity example, application architecture, validation contract and capacity calculations are original.

Continue your preparation

Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.