Skip to content

Hugging Face

The huggingface kind stores metadata for a Hugging Face model. Create the model entity by registering a source that already exists in storage or by creating a reference with new_model().

Create

Register

register_huggingface

Register a Hugging Face model entity for an existing source.

Parameters:

Name Type Description Default
project str

Project name.

required
source SourcesOrListOfSources

Hugging Face URI of the existing model.

required
name str

Entity name. If omitted, it is inferred from source.

None
uuid str

Entity identifier.

None
version str

Entity version.

None
description str

Human-readable entity description.

None
labels list[str]

Entity labels.

None
embedded bool

Whether to embed the entity specification in the project specification.

False
extensions list[dict]

Entity extensions.

None
framework str

Model framework.

None
algorithm str

Model algorithm.

None
parameters dict

Model parameters.

None
base_model str

Base model identifier.

None
model_id str

Hugging Face model identifier.

None
model_revision str

Hugging Face model revision.

None
**kwargs dict

Additional model specification parameters.

{}

Returns:

Type Description
ModelHuggingface

Registered Hugging Face model entity.

Examples:

Register a Hugging Face model that already exists in remote storage:

import digitalhub as dh

model = dh.register_huggingface(
    project="my-project",
    name="registered-text-classifier",
    source="hf://my-org/text-classifier",
    base_model="distilbert-base-uncased",
    model_id="my-org/text-classifier",
    model_revision="main",
)

New

new_model

Create a new model entity in the backend.

Parameters:

Name Type Description Default
project str

Project name.

required
name str

Entity name.

required
kind str

Entity kind.

required
uuid str

Entity identifier.

None
version str

Entity version.

None
description str

Human-readable entity description.

None
labels list[str]

Entity labels.

None
embedded bool

Whether to embed the entity specification in the project specification.

False
path str

Entity path on the local file system or remote storage. It is also the destination path for uploads.

None
extensions list[dict]

Entity extensions.

None
**kwargs dict

Additional entity specification parameters.

{}

Returns:

Type Description
Model

Created model entity.

import digitalhub as dh

model = dh.new_model(
    project="my-project",
    name="text-classifier",
    kind="huggingface",
    path="s3://my-bucket/models/text-classifier",
    base_model="distilbert-base-uncased",
    model_id="my-org/text-classifier",
    model_revision="main",
)

Retrieve and manage

Use the shared Model management reference to retrieve, update, or delete a Hugging Face Model.