Edit on GitHub


MLEM has a number of abstract base classes that anyone can implement to extend to add new capabilities to MLEM.

Each abstract base class in this list is a subclass of mlem.core.base.MlemABC class, which is a subclass of pydantic BaseModel with additional polymorphic magic.

That means that all subclasses are also BaseModels and should be serializable. This way MLEM can save/load them as part of the other objects or dynamically provide options to configure them in CLI.

Transient fields are used to hold some operational object and are not saved when an object is dumped. After opening objects with transient fields they will be empty until you load the object.

Here is the list of all MLEM ABCs.



Represents a MLEM Object

Base class: mlem.core.objects.MlemObject

For more info and list of subtypes look here


Represents different types of requirements for MLEM Object.

Base class: mlem.core.requirements.Requirement


  • installable - a Python requirement typically installed through pip. Can have specific version and alternative package name.
  • custom - a Python requirement in the form of a local .py file or a python package. Contains name and source code for the module/package.
  • unix - unix package typically installed through apt or yum


Represents some file format that MLEM can try to import.

Base class: mlem.core.import_objects.ImportHook


  • pickle - simply unpickle the contens of file and use default MLEM object analyzer. Works with pickled files.
  • pandas - try to read a file into pandas.DataFrame. Works with files saved with Pandas in formats like csv, json, excel, parquet, feather, stata, html, parquet. Some formats require additional dependencies.



This class is basically a wrapper for all Model classes of different libraries. Yes, yet another standard. If you want to add support for your ML Model in MLEM, this is what you implement!

Base class: mlem.core.model.ModelType

This class is polymorphic, which means that it can have more fields depending on implementation.


  • io - an instance of ModelIO, a way to save and load the model
  • method - a string-to-signature mapping which holds information about available model methods
  • model (transient) - will hold the actual model object, if it was loaded

There are implementations of this class for all supported libraries: xgboost, catboost, lightgbm, torch, sklearn.

The one notable implementation is callable: it treats any Python callable object as a model with a single method __call__. That means you can turn functions and class methods into MLEM Models as well!


Represents a way that model can be saved and loaded. A required field of ModelType class. If a ML library has its own way to save and load models, it goes here.

Base class: mlem.core.model.ModelIO

There are implementations for all supported libraries: torch_io, xgboost_io, lightgbm_io, catboost_io

Also, universal simple_pickle is available, which simply pickles the model (used by sklearn, for example).

There is also separate pickle implementation, which can detect other model types inside your object and use their IO's for them. This is very handy when you for example wrap your torch NN with a Python function: the function part will be pickled, and the NN will be saved using torch_io.



Holds metadata about data, like type, dimensions, column names etc.

Base class: mlem.core.data_type.DataType


  • data (transient) - underlying data object, if it was read



  • primitive - any of the Python primitives
  • tuple - a tuple of objects, each can have different type
  • list - a list of objects, but they should be the same type
  • tuple_like_list - a list of objects, each can have different type
  • dict - a dictionary, each key can have different type


  • dataframe - pd.DataFrame. Holds info about columns, their types and indexes
  • series - pd.Series. Holds info about columns, their types and indexes


  • ndarray - np.ndarray. Holds info about type and dimensions
  • number - np.number. Holds info about type

ML Libraries:

  • xgboost_dmatrix - xgboost.DMatrix. Holds info about feature names and their types
  • lightgbm - lightgbm.Dataset. Holds information about inner data object (dataframe or ndarray)
  • torch - torch.Tensor. Holds information about type and dimensions


  • unspecified - Special dataset type when no dataset info was provided


Holds all the information needed to read dataset.

Base class: mlem.core.data_type.DataReader


  • data_type - resulting data type


  • pandas
  • numpy


Writes data to files, producing a list of Artifact and corresponding DataReader

Base class: mlem.core.data_type.DataWriter


  • pandas
  • numpy



Represents a file saved in some storage.

Base class: mlem.core.artifacts.Artifact


  • local - local file
  • fsspec - file in remote file system
  • dvc - file in dvc cache


Defines where the artifacts will be written. Produces corresponding Artifact instances.

Base class: mlem.core.artifacts.Storage


  • local - store files on the local file system
  • fsspec - store files in some remote file system
  • dvc - store files locally, but try to read them from DVC cache if they are absent



Represents an interface for service runtime. Provides a mapping method name to its signature. Also provides executor functions for those methods.

Base class: mlem.runtime.interface.Interface


  • simple - base class for interfaces created manually. Will expose subclass methods marked with @expose decorator.
  • model - dynamically create interface from ModelType


Runs configured interface, exposing its methods as endpoints.

Base class: mlem.runtime.server.Server


  • fastapi - starts FastAPI server
  • rmq - creates a queue in RabbitMQ instance and a consumer for each interface method


Clients for corresponding servers

Base class: mlem.runtime.client.Client


  • http - makes request for http servers like fastapi
  • rmq - client for rmq server



Declaration for creating a build from model. You can learn more about building in this User Guide

Base class: mlem.core.objects.MlemBuilder

Related commands: API, CLI


Python packages:

  • pip - create a directory with Python package from model
  • whl - create a .whl file with Python package


  • docker_dir - create a directory with context for Docker image building
  • docker - build a Docker image from model



Declaration of target environment for deploying models.

Base class: mlem.core.objects.MlemEnv


  • heroku - an account on heroku platform


Declaration and state of deployed model.

Base class: mlem.core.objects.MlemDeployment

Related commands: API, CLI


  • env_link - link to targeted environment
  • env (transient) - loaded targeted environment
  • model_link - link to deployed model object
  • model (transient) - loaded model object
  • state - deployment state


  • heroku - app deployed to Heroku platform


Represents state of the deployment

Base class: mlem.core.objects.DeployState


  • heroku - state of the deployed Heroku app

🐛 Found an issue? Let us know! Or fix it:

Edit on GitHub

Have a question? Join our chat, we will help you:

Discord Chat