Skip to main content

A machine learning model-sharing specification based on STAC MLM and Safetensors.

Project description

MLSTAC logo

MLSTAC

Machine learning model sharing, built on the STAC MLM extension and Safetensors.

PyPI version Python versions Tests License Documentation


Overview

MLSTAC gives you a single, consistent way to publish and consume machine learning models. Each model is described by a STAC Item using the MLM extension, and its weights travel as Safetensors. From that metadata you can load a model from many backends (HTTP, local disk, S3, Google Cloud Storage), download it, inspect it, and turn it into a usable PyTorch model.

Status: experimental. The API may change between minor versions.

Installation

pip install mlstac

Quickstart

import mlstac

# Load only the metadata first (no weights are downloaded yet)
model = mlstac.load("https://example.com/my-model/mlm.json")

# Inspect what you have
print(model.get_model_summary())
model.print_schema()

# Download every file into a local folder; you get back a loader
# pointing at the local copy
local = model.download("./my-model")

# Build a usable model from the local files
net = local.compiled_model()

Loading from different sources

mlstac.load is the main entry point. It accepts a URL, a local path, or a list of .pt2 files for an ad-hoc ensemble.

# Remote metadata
mlstac.load("https://example.com/model/mlm.json")

# A local directory that contains an mlm.json
mlstac.load("./my-model")

# An ensemble built directly from .pt2 files
ensemble = mlstac.load(["model_a.pt2", "model_b.pt2"])
ensemble.is_ensemble  # True

Downloading

You can download from the loader instance, or call the module-level function directly.

# From an existing loader (reuses the source it was created from)
local = model.download("./my-model")

# Or as a one-shot call
local = mlstac.download("https://example.com/model/mlm.json", "./my-model")

Supported backends

Scheme Example
http / https / ftp https://example.com/model/mlm.json
local ./my-model or /abs/path/mlm.json
s3 s3://bucket/key/mlm.json (needs boto3)
gs gs://bucket/key/mlm.json (needs google-cloud-storage)

Documentation

Full docs live at tacofoundation.github.io/mlstac.

Development

# install with dev dependencies
poetry install --with dev

# run the test suite
poetry run pytest tests/ -v

License

See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mlstac-0.4.7.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlstac-0.4.7-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file mlstac-0.4.7.tar.gz.

File metadata

  • Download URL: mlstac-0.4.7.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Windows/11

File hashes

Hashes for mlstac-0.4.7.tar.gz
Algorithm Hash digest
SHA256 6960b92daa3e1680d17ff54e6b21f789db1c847a0f2bc36f713686fca9792e17
MD5 028524f9276167701e211783acd22d71
BLAKE2b-256 46e19a11f6c8e5ce3bb2b20ed6cb1545f4af1c3798d4f4aa217e4f60aebeeba3

See more details on using hashes here.

File details

Details for the file mlstac-0.4.7-py3-none-any.whl.

File metadata

  • Download URL: mlstac-0.4.7-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Windows/11

File hashes

Hashes for mlstac-0.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c0ec62c9ea493465a35e2190f2b64f32c5321d190de8fcccebd28298d4f68012
MD5 124301a354889b304378c840df4d8d63
BLAKE2b-256 6945f3709b0566f84e9f486a68d689edbdb6e2d8c50d5efa10e4b9fc3f68ce2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page