02 / 16 · ML Systems
Designing an ML system
How to turn a product requirement into an ML system: deciding whether ML is needed and beating a heuristic baseline, qualities beyond accuracy, offline, online and proxy metrics, planning for mistakes, latency and cost budgets as arithmetic, and a design document.
What MLOps is · Classification metrics · SLOs, error budgets and alerting
On this page 7
A preview service receives scanned study cards. Some previews are unreadable, and an editor can repair them before publication. Reviewing every upload is expensive; publishing a bad preview creates another support task. We need a decision about which cards to review, and a record of what happened after that decision.
The following counts and timing requirements define an original fictional service. They are assumptions for design arithmetic, not observations from an operating product.
Start with the decision#
The service may place a card in the editor’s queue or publish its preview. A score alone does neither. We must specify the threshold, the destination of a flagged item, the person who can release it, and what the user sees while waiting. Otherwise a classifier can improve while the product remains unchanged.
An editor’s repair is also a future label. Store the prediction before the repair, with its document ID and release ID. Evaluating the repaired preview as though it were the original would answer a different question. This is a concrete reason to separate event time, prediction time and label time.
Does learning earn its complexity?#
Start with a rule that flags a low contrast score. On a fictional labelled sample of 1,000 previews, 80 need repair. The table specifies two possible decision sets; it does not claim that a model was trained to produce them.
| Decision set | Bad previews flagged | Good previews flagged | Bad previews missed | Editor queue |
|---|---|---|---|---|
| Contrast rule | 48 | 92 | 32 | 140 |
| Candidate classifier | 68 | 52 | 12 | 120 |
For the candidate, recall is : it finds 85% of bad previews. Precision is : only about 57% of its review queue needs repair. These answer different operational questions. Recall measures missed damage; precision determines how much review time is spent on good cards. The definitions are developed in Classification metrics.
Suppose a review costs two minutes and an undetected bad preview creates twelve minutes of later work. The total burden is
Every flagged item consumes a review, including a false alarm. Only missed bad previews incur the second term. The rule costs minutes; the candidate costs . Reviewing everything costs 2,000 minutes. The candidate is worth investigating under these assumptions. If later support work costs much less, the conclusion can change without any change in accuracy.
Quality includes the surrounding service#
If daily arrivals reproduce this 1,000-preview mix and these error rates, a queue with capacity for 130 daily reviews can accept the candidate’s 120 items but not the rule’s 140. A useful requirement therefore combines missed defects, queue capacity and delay. It also specifies retention, access to uploaded documents, and recovery when the scorer is unavailable. These requirements belong to the whole application.
An always-publish rule obtains 92% accuracy because 920 previews are good. It misses every defect. Accuracy alone would hide the reason for building the service. Conversely, a model with excellent recall may overwhelm the editor and delay all uploads. Keep the confusion matrix alongside the operational consequence of each cell.
Measure the outcome at the right time#
An offline sample lets us compare decision sets on the same cards. An online measure asks whether users actually obtain usable previews and how long they wait. A proxy, such as the model’s score or the number of alerts, is useful only after checking its relationship to that outcome.
Label coverage matters. If editors assess only flagged cards, we can estimate precision in the queue, but we cannot count false negatives among unflagged cards. Randomly audit a small, explicitly sampled portion of those cards, preserve sampling probabilities, and report which population the estimate covers. Do not treat an unreviewed card as a known success.
Choose a threshold on a development sample. Keep a separate evaluation sample for the decision to ship. Repeatedly adjusting the threshold against the evaluation results turns that sample into development data. Group near-duplicate scans and respect time boundaries when those dependencies would otherwise leak information.
Give mistakes a recovery path#
A false positive must be releasable without asking the learner to upload again. A false negative should create a repair task attached to the original prediction. If the scorer times out, preserve the upload and offer a plain preview with a visible pending state. This service does not need to discard content or make an irreversible decision.
Assign ownership to each action: the product owner chooses acceptable delay, the editor owns repair labels, and the service operator owns queue overload and rollback. One person may hold several roles. The important boundary is who can change a decision rule and who checks its consequences.
Allocate a budget to a complete request#
The latency budget#
For a sequential path, total latency is the sum of the stages. A fictional 100 ms bound can be allocated as follows:
| Stage | Bound, ms |
|---|---|
| Decode input | 18 |
| Compute features | 12 |
| Wait in queue | 25 |
| Score | 35 |
| Prepare response | 10 |
The sum is 100 ms. These are proposed per-request bounds. Adding separately measured p95 values would not establish a p95 for the whole path: different requests can occupy each stage’s slow tail. Measure end-to-end latency as well. Parallel branches require the maximum branch duration plus joining overhead, rather than the sum of all branch durations.
The cost budget#
Let be daily fixed cost, the cost per scored card and daily volume. Serving cost is before review and support costs. A cache reduces scored volume only for requests where reuse is correct. A retry increases it. Put review capacity and expected damage in the same decision, but keep their units explicit; minutes and currency cannot be added without a conversion assumption.
Record a decision that can be reversed#
A release record connects the artifact to the evidence: feature definition, model version, threshold, evaluation cohort, queue limit and rollback target. MLflow’s registry provides model versions and movable aliases; an alias is convenient for deployment but does not replace the immutable version in the release record (MLflow).
The design decision here is to evaluate the candidate under a 130-review limit and a 100 ms request bound. It is conditional on the stated workload and cost of missed defects. The table is not a universal template for another application.
When the calculation stops being useful#
The sample is small and fictional. Real error rates have uncertainty and can differ by scanner, language or document type. Review duration may increase for difficult cards, so a fixed two-minute cost can understate the tail. User behaviour may change when review is introduced. A capacity estimate based on a daily average also misses bursts. These are measurements to collect before using the design in production.
What to retain#
Define the action, its consequence and the population being evaluated. Compare against a rule and an always-accept baseline. Budget review work and complete-request delay. Make labels traceable to the prediction that preceded them. Keep a reversible release record.
Reproduce the arithmetic#
The original fixture is implemented in Python source, function design. It uses only the Python standard library; no uploaded cards, external dataset or trained model is needed. Its saved result records the confusion matrices, 664 versus 384 minutes, and the 100 ms allocation. Change a cost assumption before interpreting a different decision.
Next#
A design depends on the meaning and timing of its inputs. Data and feature pipelines follows those inputs from their source to the training and serving paths.
References#
- MLflow contributors. Model Registry Workflows, checked 13 November 2026; model versions, aliases and the deployment record. Reference for API concepts only; no example code or screenshots reproduced.
- D. Sculley, Gary Holt, Daniel Golovin, Eugene Davydov, Todd Phillips, Dietmar Ebner, Vinay Chaudhary, Michael Young, Jean-François Crespo and Dan Dennison. Hidden Technical Debt in Machine Learning Systems. NeurIPS, 2015. Background on dependencies around a deployed model; the preview-service requirements and arithmetic above are independently specified.