Hugging Face

Publish Rebase model versions to Hugging Face model and dataset repositories.

Use the Hugging Face integration when a Rebase model version should also be available in a Hub model or dataset repository. Publications can be public open-source releases or private Hub repos.

The integration records two stable anchors:

AnchorMeaning
Rebase model versionThe immutable model version created by deploy().
Hugging Face commitThe Hub commit returned by huggingface_hub after upload.

GitHub or local Git sync is optional. If the Rebase model version has a clean Git commit, the SDK can record that commit on the publication record. If there is no Git metadata, the model can still be published to Hugging Face.

Install

Install the optional Hugging Face extra in the environment that runs deployment:

uv pip install "rebase-toolkit[huggingface]"

Or, with pip:

pip install "rebase-toolkit[huggingface]"

Authenticate with Hugging Face through Rebase:

rebase connect huggingface

For local API development or a custom Hugging Face OAuth app, pass --client-id or set REBASE_HUGGINGFACE_OAUTH_CLIENT_ID.

You can still pass a token directly in the publish config when you need to override local auth.

Publish a Model

Pass huggingface= to a deployable model:

import rebase


class PriceForecast(rebase.Predictor):
    name = "price-forecast"

    def predict(self, zone: str = "SE3") -> dict:
        return {"zone": zone, "mw": 42.0}


model = PriceForecast()

model.deploy(
    environment="dev",
    huggingface=rebase.HuggingFacePublishConfig(
        repo_id="rebase/price-forecast",
        private=False,
    ),
)

This creates or updates rebase/price-forecast on Hugging Face, uploads Rebase provenance files, and records the Hub commit back on the Rebase model publication.

Publish Artifacts

Use artifact_path when you have a local model file or folder to upload:

model.deploy(
    huggingface=rebase.HuggingFacePublishConfig(
        repo_id="rebase/price-forecast",
        private=True,
        artifact_path="./artifacts/price-forecast",
        path_in_repo="model",
    ),
)

If artifact_path is a file, the SDK uploads that file. If it is a folder, the SDK uploads the folder contents. The SDK also uploads rebase_model.json so the Hub repo points back to the Rebase model version.

Models and Datasets

Use repo_type="model" for model repositories and repo_type="dataset" for dataset repositories:

model.deploy(
    huggingface=rebase.HuggingFacePublishConfig(
        repo_id="rebase/forecast-dataset",
        repo_type="dataset",
        private=False,
        artifact_path="./dataset",
    ),
)

Optional Git Sync

By default, sync_source_git=True. When the model version has clean Git metadata, the SDK sends the matching source_git_commit_sha to Rebase. The backend verifies that the submitted commit matches the immutable model version before marking the publication in_sync.

Disable that link when you want a Hugging Face-only publication:

model.deploy(
    huggingface=rebase.HuggingFacePublishConfig(
        repo_id="rebase/price-forecast",
        sync_source_git=False,
    ),
)

With Git sync disabled, the publication is still valid. Rebase records the model version, Hub repo, Hub revision, Hub commit SHA, visibility, and publication metadata.

Provenance Files

The SDK writes rebase_model.json to the Hub repo. It includes the Rebase model ID, model version ID, version number, fingerprint, source path, source hash, image fingerprint, and any available Git metadata.

When no artifact path is provided, the SDK also uploads a generated README.md and, when available, rebase_source.py.

Reference

See rebase.HuggingFacePublishConfig for the full parameter list.

On this page