Skip to main content

mb.add_model(name, model, ...)

Adds a model to the model registry. The registry is updated with the new model if a an entry with that name already exists.

Multiple models

If you're adding multiple models to the registry, use mb.add_models instead.

Parameters

  • name: str The name of the model in the registry. Models are stored by paths, like files, so you can use forward slashes for organization.
  • model: Optional[Any] The model object to store in the registry. A Python variable, not a path to a .pkl file. Required unless using file=.
  • file: Optional[str] The filepath where the model is stored. Use this for file-based models instead of model=
  • metrics: Optional[Dict[str, Any]] Optional, the metrics to associate with this model. Metrics must be JSON-serializable with str values for keys.
  • serializer: Optional["cloudpickle"] Optional, specify a different serializer to use. Default value is None which uses the pickle module. Learn mode

Returns

No value is returned. A success status message is printed if the command is successful.

Examples

Adding a model

mb.add_model("example_model", my_model)

Adding a model in a "finance" directory

mb.add_model("finance/example_model", my_model)

Adding a model stored as a file

mb.add_model("my_model", file="path/to/model.gguf")

Adding a model with metrics

mb.add_model("example_model", model=my_model, metrics={ "precision": 0.95 })

Storing a model with cloudpickle

mb.add_model("my_model", model=my_model, serializer="cloudpickle")

See also