get_models
Retrieves multiple models from the model registry.
info
Calls to get_models
are automatically cached. Additional calls to fetch the same models from get_models
will be instant.
Parameters
mb.get_models(...)
prefix
:Optional[str]
A search prefix to use when looking for models to fetch. Similar tomb.models(prefix=...)
.names
:Optional[List[str]]
A list of model names to fetch from the registry.files
:Optional[Dict[str, str]]
A dict of model names to fetch from the registry, and their corresponding local files paths for storage.branch
:Optional[str]
The branch to use when fetching models from the registry. By default, the current branch is used.
Returns
Optional[Dict[str, Any]]
- A dict of model names to model instances, when using prefix=
or names=
. Or None
when using files=
.
Examples
Get several models by name
Pass a list of model names to names=
to fetch many models. The response will be a dict of those models:
models = mb.get_models(names=["model1", "model2"])
# returns { "model1": ..., "model2": ... }
Get several models by prefix
To get all of the models in the project_foo
directory of the registry, use prefix=
:
models = mb.get_models(prefix="project_foo/")
# returns { "project_foo/model1": ..., "project_foo/model2": ..., ... }
Download several models to files
To fetch file-based models from the registry and store them as local files, use files=
with the key as the model name and the value as the filepath for storing the file locally:
mb.get_models(files={"model1": "path/to/model1.pkl", "model2": "path/to/model2.gguf"})