Model Settings

In MLServer, each loaded model can be configured separately. This configuration will include model information (e.g. metadata about the accepted inputs), but also model-specific settings (e.g. number of parallel workers to run inference).

This configuration will usually be provided through a model-settings.json file which sits next to the model artifacts. However, it’s also possible to provide this through environment variables prefixed with MLSERVER_MODEL_ (e.g. MLSERVER_MODEL_IMPLEMENTATION). Note that, in the latter case, this environment variables will be shared across all loaded models (unless they get overriden by a model-settings.json file). Additionally, if no model-settings.json file is found, MLServer will also try to load a “default” model from these environment variables.

Settings

pydantic settings mlserver.settings.ModelSettings
Config
  • env_file: str = .env

  • env_prefix: str = MLSERVER_MODEL_

  • underscore_attrs_are_private: bool = True

Fields
field implementation: pydantic.types.PyObject = 'mlserver.model.MLModel'

Python path to the inference runtime to use to serve this model (e.g. mlserver_sklearn.SKLearnModel).

field inputs: List[mlserver.types.dataplane.MetadataTensor] = []

Metadata about the inputs accepted by the model.

field max_batch_size: int = 0

When adaptive batching is enabled, maximum number of requests to group together in a single batch.

field max_batch_time: float = 0.0

When adaptive batching is enabled, maximum amount of time (in seconds) to wait for enough requests to build a full batch.

field name: str = ''

Name of the model.

field outputs: List[mlserver.types.dataplane.MetadataTensor] = []

Metadata about the outputs returned by the model.

field parallel_workers: Optional[int] = None

Use the parallel_workers field the server wide settings instead.

field parameters: Optional[mlserver.settings.ModelParameters] = None

Extra parameters for each instance of this model.

field platform: str = ''

Framework used to train and serialise the model (e.g. sklearn).

field versions: List[str] = []

Versions of dependencies used to train the model (e.g. sklearn/0.20.1).

field warm_workers: bool = False

Inference workers will now always be warmed up at start time.

Extra Model Parameters

pydantic settings mlserver.settings.ModelParameters

Parameters that apply only to a particular instance of a model. This can include things like model weights, or arbitrary extra parameters particular to the underlying inference runtime. The main difference with respect to ModelSettings is that parameters can change on each instance (e.g. each version) of the model.

Config
  • env_file: str = .env

  • env_prefix: str = MLSERVER_MODEL_

Fields
field content_type: Optional[str] = None

Default content type to use for requests and responses.

field extra: Optional[dict] = {}

Arbitrary settings, dependent on the inference runtime implementation.

field format: Optional[str] = None

Format of the model (only available on certain runtimes).

field uri: Optional[str] = None

URI where the model artifacts can be found. This path must be either absolute or relative to where MLServer is running.

field version: Optional[str] = None

Version of the model.