Separate Deterministic and Probabilistic Concerns
Intent
Motivation
Applicability
Description
Not every problem in an ML system requires a machine learning solution. Using an ML model where a deterministic function would suffice adds cost, fragility, and opacity without benefit.
Apply ML Only Where It Is Warranted
ML is appropriate when the task requires pattern recognition, generalisation from examples, or handling genuine uncertainty in the input. Use deterministic code, such as rules, formulas, look-up tables, and constraint solvers, when:
- the output can be computed exactly from the input by a known procedure,
- correctness can be fully specified and tested without training data,
- the relationship between input and output does not change based on context or distribution.
Concrete examples of logic that should remain deterministic: input validation, currency conversion, date arithmetic, business rule enforcement, configuration-driven routing.
Architect Clean Boundaries
In systems that combine ML and deterministic logic, keep the two separated with explicit interfaces:
- pre-processing and post-processing pipelines that transform data should be deterministic and unit-tested independently of the model,
- the model’s role should be limited to the inference step, producing a score, label, or generation, rather than orchestrating control flow,
- downstream decisions that consume model output (e.g. thresholding, aggregation, business logic) should be implemented as deterministic code with explicit parameters, not embedded in the model.
This separation makes each component independently testable and replaceable, reduces inference cost by avoiding unnecessary model calls, and makes the system’s behaviour easier to explain and audit.
Validate the Choice at Design Time
When selecting an ML model for a new capability, explicitly ask: “Could this requirement be met with a deterministic implementation?” If yes, prefer the deterministic approach. If ML is chosen, document the justification.
Related
- Apply Layered Guardrails to ML System Behaviour
- Use an Independent Verification Layer for ML Outputs
- Use Continuous Integration
- Use the Most Efficient Models and Optimise for Inference
- Track and Govern AI Inference Costs