The interview problem
Design a quality gate for a receipt-capture application handling one million capture journeys per day. Each journey can contain several image attempts. The application extracts merchant, date and total for user confirmation. Decide whether to run extraction, request a specific retake, or offer manual entry. Reduce incorrect records without making users repeatedly photograph receipts that are already usable.
Original ML-design practice, not a reported company interview. Workloads, operating points and cost examples are hypothetical. Primary technical references retrieved September 27, 2026; interview date not applicable.
1. Define quality through the downstream task
The product needs correctly completed records, not attractive photographs. A wrinkled receipt can be readable; a sharp, well-lit image can omit the total. Define which fields must be recoverable and distinguish missing evidence from an extractor that fails on readable evidence. This system prepares records for confirmation; it does not automatically approve reimbursement.
Use a stable journey identifier and separate attempt identifiers. The primary outcome is correct completed records per started journey over an agreed observation window. Also measure abandonment, edits, manual completion and time to finish. Counting only accepted images can make an aggressive gate appear excellent while users give up.
Assume a hypothetical peak of 500 attempts per second and a gate latency objective of 150 milliseconds at p95. Clarify whether this includes upload time; for this design it covers server receipt of the image through the gate decision, excluding client upload and downstream extraction. Track the full user-visible duration separately.
2. Preserve the image evidence that matters
client framing hints
↓
bounded decode, orientation and format validation
↓
receipt region + required-field visibility
↓
global and local quality features
↓
task-usability probability + issue-specific predictions
↓
decision policy
↙ ↓ ↘
extract specific retake manual entry
↓
journey outcome and audited correctnessCheck payload size, format and decoded dimensions before expensive processing. Apply bounded decoding and keep malformed files out of model inference. Client hints can reduce wasted uploads, but server checks remain necessary because client versions and behavior differ.
Inspect local regions as well as the whole image. Glare over the total can be fatal despite high global sharpness. Preserve aspect ratio and enough detail to resolve small characters. A resize that removes blur artifacts can also remove the digits the task needs. Test crops, orientation, compression and preprocessing as part of the model, not as invisible plumbing.
Retain the original evidence under the agreed access and retention policy. Generative enhancement must not be treated as recovery of digits that the source does not contain. If an enhanced image is used experimentally, compare extracted facts against independently checked originals and preserve that transformation's provenance. Do not expose receipt contents in routine telemetry.
3. Separate acquisition defects from model failures
Collect four kinds of labels: observable capture problems such as glare or truncation; human judgments of required-field legibility; correctness of the versioned extractor's output; and what happens after a retake request. These labels answer different questions. An uncertain extractor can receive a readable image, and a confident extractor can produce a wrong total.
Build reference records using independent entry and source inspection, with adjudication for ambiguous fields. Annotators should mark absent or unreadable information rather than guessing. Define partial usability: the merchant may be recoverable while the total is not. Task-usability labels must name both the required fields and the downstream model or human workflow they refer to.
Compare a simple geometry, brightness and blur baseline with a learned encoder using a usability head and multiple issue heads. A multi-scale or regional representation can preserve detail that a single thumbnail loses. Calibrate predicted extraction success on held-out data; a generic image-quality score is not a probability of correct receipt extraction.
NIMA illustrates learning human rating distributions without a reference image. MUSIQ illustrates multi-scale quality assessment with varying image sizes. These are useful technical precedents, but their perceptual objectives do not establish this application's field correctness or the benefit of asking a user to retry.
Use synthetic blur, glare-like corruption and cropping for augmentation, supplemented by real lighting, camera, paper and layout variation. Keep original receipts, retakes and transformed copies in the same split. Hold out later time periods and relevant device or template cohorts. Report errors by script, device, lighting and upload channel; device identity is a diagnostic slice, not a reason to reject every image from that device.
4. Check what the gate's confusion matrix actually says
Suppose 10,000 initial uploads contain 8,000 usable and 2,000 unusable images under the defined reference task. The proposed gate behaves as follows:
| Reference status | Accept for extraction | Request retake | Total |
|---|---|---|---|
| Usable | 7,600 | 400 | 8,000 |
| Unusable | 400 | 1,600 | 2,000 |
| Total | 8,000 | 2,000 | 10,000 |
retake precision = 1,600 / 2,000 = 80% unusable detection recall = 1,600 / 2,000 = 80% usable false-retake rate = 400 / 8,000 = 5% accepted unusable fraction= 400 / 8,000 = 5% initial acceptance rate = 8,000 /10,000 = 80%
The equal percentages arise from this particular table, not an identity between the metrics. A retake precision of 80% means 20% of prompts inconvenience users whose original image was usable. It does not mean 80% of users will recover after retaking, and the accepted unusable fraction is not the false-retake rate despite sharing its numerical value here.
5. Work through recovery and abandonment
For an explicit counterfactual illustration, assume every usable image yields correct extraction and no unusable image does. Without a gate, all users submit once, giving 8,000 correct completions. Assume the gate permits one retake and no manual rescue in this calculation:
- Of 1,600 flagged unusable images, 75% of users retry. Of those 1,200 retakes, 70% become usable: 840 recoveries.
- Of 400 flagged usable images, 90% of users retry. All 360 of those retakes remain usable, but 40 users abandon instead of completing from their original image.
- The 7,600 usable images accepted immediately complete correctly. The 400 accepted unusable images do not.
correct gated completions = 7,600 + 840 + 360 = 8,800 gain over assumed baseline= 8,800 − 8,000 = 800 extra attempts = 1,200 + 360 = 1,560 total image attempts = 10,000 + 1,560 = 11,560 prompted abandonments = 2,000 − 1,560 = 440
Another 360 bad-image retakes remain unusable. The complete failure count is therefore 400 immediately accepted unusable images, 440 abandonments and 360 unsuccessful retakes: 1,200 journeys. This reconciles with the 8,800 successes.
These are assumed potential outcomes, not a causal result inferred from the confusion matrix. Real users may retry without prompting, correct fields manually or abandon for unrelated reasons. A retake-only success metric excludes nonresponders and is selected by the gate's policy. Run a bounded randomized experiment on eligible journeys and compare intention-to-treat completion, correctness and friction with the same observation window. Keep manual-entry availability consistent across variants, or explicitly treat its change as part of the intervention.
6. Choose actions by expected benefit
Consider a simplified two-action policy. Correct completion has utility 10 and failure has utility zero. Accepting the current image succeeds with calibrated probability p. A retake request has response probability 0.8 and conditional success probability 0.9, and incurs friction cost 1 per prompt whether the user responds or not.
accept utility = 10p retake utility = 0.8 × 0.9 × 10 − 1 = 6.2 request retake when p < 0.62
The constants are illustrative. Response probability, recoverability and cost depend on the reason, user context and prior attempts. If the friction cost applies only to responders, the formula changes. Aesthetic scores are not calibrated p, and observational retake success is not automatically the causal effect of a prompt.
The actual product has manual entry as a third action. Offer it when the source lacks required information, repeated capture is unlikely to help or the user cannot improve the conditions. Give one specific instruction, such as moving glare away from the total, only when its issue prediction is reliable. Cap retries and retain progress. An endless sequence of “image quality too low” messages is not a functioning fallback.
7. Budget attempts, not just initial uploads
Suppose representative hardware benchmarks show 20 milliseconds of accelerator service time per attempt, without batching. At 500 attempts per second:
service demand = 500 × 0.020 = 10 accelerator-seconds/second workers at 60% utilization = ceil(10 / 0.60) = 17
This is a planning calculation for identical single-stream worker equivalents. Actual concurrency, batching, preprocessing and failure headroom require measurement. It does not establish the 150-millisecond p95 objective: queueing, decoding and serialization remain, and tail service times matter.
At an average 2 MB per image, one million initial attempts produce 2 TB per day in decimal units. If the illustrative 15.6% extra-attempt rate generalized, traffic would become 2.312 TB per day and 14-day raw retention would require 32.368 TB before replicas and derived data. Measure the production retry rate instead of assuming a small cohort generalizes. Client-rejected captures that never upload need separate counters.
8. Validate and operate the entire journey
Offline evaluation includes task-conditioned precision and recall, calibration, reason accuracy, actionability, subgroup errors and latency. Online evaluation includes correct completions per started journey, user corrections, manual-entry completion, abandonment, attempts per journey, elapsed completion time and compute or upload cost. Accepted-image accuracy alone is an incomplete product metric.
Audit both accepted and rejected images under controlled access. Otherwise rejected cases stop producing extraction outcomes, hiding false retakes and shifting training labels. For a sampled rejected image, an authorized offline run of the extractor can reveal its current-image outcome; it cannot reveal whether that user would have completed after a different prompt. Keep this audit separate from the randomized journey experiment. If audit sampling is stratified, use the sampling design when estimating population rates. Keep the raw slice denominators and uncertainty visible.
| Failure | Evidence to inspect | Response |
|---|---|---|
| Glare hides a critical field | Local region audits and field-level errors | Add regional evidence and targeted advice |
| New camera compression shifts scores | Device/version slices and original captures | Validate preprocessing and recalibrate only after diagnosis |
| Retake advice repeats without benefit | Journey attempt sequence and outcome | Cap prompts and offer manual entry |
| Accepted-only labels conceal mistakes | Independent rejected-case audit | Repair sampling and training selection |
| Extractor upgrade invalidates usability predictions | Versioned end-to-end evaluation | Revalidate gate calibration and policy with the new extractor |
Start in shadow mode, then run a bounded experiment with completion, device/script errors and latency guardrails. Version preprocessing, gate, extractor and decision policy together. Roll back a compatible combination rather than only a weight file. If the gate is unavailable, this receipt workflow may use a documented extraction-with-confirmation or manual-entry path; do not label an unassessed image “quality verified.” Parser and payload protections still apply.
9. Discuss trade-offs and follow-ups
Client checks reduce delay and data transfer but vary with application versions and devices. Server inference is easier to update consistently but adds network and compute cost. Global features are inexpensive; local detail protects critical fields at additional latency. A generic quality model can be reused, while a task-specific gate better reflects the actual completion objective and must be revalidated as the extractor changes.
- Accepted-image accuracy rises while completion falls. Inspect false retakes, abandonment and fallback availability; optimize the journey objective rather than celebrating a selected subset.
- A new script appears. Separate legibility from extractor language support. Rephotographing readable text will not repair unsupported recognition.
- The original receipt is unreadable. Explain the limitation and route to the supported alternative; do not manufacture plausible financial facts.
- The downstream model improves. Some previously unusable inputs may become usable. Reevaluate labels, calibration and thresholds rather than retaining unnecessary rejection.
- Manual entry is unavailable. State the reduced recovery coverage and set a bounded failure outcome. Do not promise that every capture problem can be solved by retrying.
Self-review rubric
A strong answer defines task-specific usability and journey-level success, preserves critical regions, separates capture defects from model failures and uses independent labels. It calculates confusion-matrix denominators and retake utility correctly, accounts for abandonment and extra attempts, and proposes causal evaluation with device-shift monitoring. An excellent answer explains when a retake cannot help and provides a bounded, operational fallback.
Sources and attribution
- NIMA: Neural Image Assessment — Transactions on Image Processing, 2018; reference-free prediction of human quality-rating distributions.
- MUSIQ: Multi-scale Image Quality Transformer — ICCV, 2021; multi-scale image-quality assessment across varying image sizes.
Exact publication days were unstated on the publication pages; retrieved September 27, 2026. The receipt workflow, operating assumptions, calculations, decision policy and failure analysis are original practice material. Neither source establishes company interview attribution or the performance of this proposed system.
Continue your preparation
Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.