mixle.inference.production.serving module

Production scoring with activity + computation logging and health/problem reporting.

A Service wraps a fitted model (loaded directly or from a Registry alias) and scores production batches, recording every computation – record count, wall time, mean log-likelihood, and how many records were unscorable (outside the model’s support) – to an in-memory activity log (and optionally a JSONL file). health() summarizes recent activity so problems (rising unscorable rate, falling log-likelihood, slow batches) are visible; with a reference sample set it can also flag drift.

class Service(model, *, name=None, reference=None, log_path=None, keep=1000)[source]

Bases: object

A deployed model that scores batches and logs each computation for monitoring.

Parameters:
  • model (Any)

  • name (str | None)

  • reference (Any)

  • log_path (str | None)

  • keep (int)

classmethod from_registry(registry, name, *, alias='production', **kw)[source]

Load the model an alias points at in registry and serve it (carrying its provenance header).

Parameters:
Return type:

Service

score(records)[source]

Return per-record log-densities and log the computation (timing, mean log-lik, unscorable count).

Parameters:

records (Any)

Return type:

ndarray

check_drift(records)[source]

Drift of records versus the service’s reference sample (requires a reference).

Parameters:

records (Any)

Return type:

Any

health(*, window=100)[source]

Summary of the most recent window scoring events – throughput, mean log-likelihood, and the unscorable rate (the production problem signal).

Parameters:

window (int)

Return type:

dict