Safetensors

Mantis: Lightweight Calibrated Foundation Model for User-Friendly Time Series Classification

Logo

Overview

MANTIS is an open-source python package with a pre-trained time series classification foundation model implemented by Huawei Noah's Ark Lab.

This is a repository the model checkpoint. Please refer to the GitHub repository of the package and the technical report on arXiv for more details.

Installation

Pip installation

It can be installed via pip by running:

pip install mantis-tsfm

The requirements can be verified at pyproject.toml

Editable mode using Poetry

First, install Poetry and add the path to the binary file to your shell configuration file. For example, on Linux systems, you can do this by running:

curl -sSL https://install.python-poetry.org | python3 -
export PATH="/home/username/.local/bin:$PATH"

Now you can create a virtual environment that is based on one of your already installed Python interpreters. For example, if your default Python is 3.9, then create the environment by running:

poetry env use 3.9

Alternatively, you can specify a path to the interpreter. For example, to use an Anaconda Python interpreter:

poetry env use /path/to/anaconda3/envs/my_env/bin/python

If you want to run any command within the environment, instead of activating the environment manually, you can use poetry run:

poetry run <command>

For example, to install the dependencies and run tests:

poetry install
poetry run pytest

If dependencies are not resolving correctly, try re-generating the lock file:

poetry lock
poetry install

Getting started

Please refer to getting_started/ to see reproducible examples of how the package can be used.

Below we summarize the basic commands needed to use the package.

Initialization.

To load our pre-trained model from the HuggingFace, it is sufficient to run:

from mantis.architecture import Mantis8M

network = Mantis8M(device='cuda')
network = network.from_pretrained("paris-noah/Mantis-8M")

Feature Extraction.

We provide a scikit-learn-like wrapper MantisTrainer that allows to use Mantis as a feature extractor by running the following commands:

from mantis.trainer import MantisTrainer

model = MantisTrainer(device='cuda', network=network)
Z = model.transform(X) # X is your time series dataset

Fine-tuning.

If you want to fine-tune the model on your supervised dataset, you can use fit method of MantisTrainer:

from mantis.trainer import MantisTrainer

model = MantisTrainer(device='cuda', network=network)
model.fit(X, y) # y is a vector with class labels
probs = model.predict_proba(X)
y_pred = model.predict(X)

Adapters.

We have integrated into the framework the possibility to pass the input to an adapter before sending it to the foundation model. This may be useful for time series data sets with a large number of channels. More specifically, large number of channels may induce the curse of dimensionality or make model's fine-tuning unfeasible.

A straightforward way to overcome these issues is to use a dimension reduction approach like PCA:

from mantis.adapters import MultichannelProjector

adapter = MultichannelProjector(new_num_channels=5, base_projector='pca')
adapter.fit(X)
X_transformed = adapter.transform(X)

model = MantisTrainer(device='cuda', network=network)
Z = model.transform(X_transformed)

Another wat is to add learnable layers before the foundation model and fine-tune them with the prediction head:

from mantis.adapters import LinearChannelCombiner

model = MantisTrainer(device='cuda', network=network)
adapter = LinearChannelCombiner(num_channels=X.shape[1], new_num_channels=5)
model.fit(X, y, adapter=adapter, fine_tuning_type='adapter_head')

Citing Mantis πŸ“š

If you use Mantis in your work, please cite this technical report:

@article{feofanov2025mantis,
  title={Mantis: Lightweight Calibrated Foundation Model for User-Friendly Time Series Classification},
  author={Vasilii Feofanov and Songkang Wen and Marius Alonso and Romain Ilbert and Hongbo Guo and Malik Tiomoko and Lujia Pan and Jianfeng Zhang and Ievgen Redko},
  journal={arXiv preprint arXiv:2502.15637},
  year={2025},
}
Downloads last month
7,704
Safetensors
Model size
8.11M params
Tensor type
F32
Β·
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.