For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Python class
HuggingFaceRepo
HuggingFaceRepo
class max.pipelines.weights.HuggingFaceRepo(repo_id, revision='main', trust_remote_code=False, subfolder=None)
Bases: object
Handle for interacting with a Hugging Face repository (remote or local).
encoding_for_file()
encoding_for_file(file, preferred_encoding=None)
Infers the supported encoding for a given weight file path.
-
Parameters:
-
- file (str | Path) – The weight file path.
- preferred_encoding (SupportedEncoding | None) – If set and present in the repo’s supported encodings, return it directly. Useful for multi-encoding safetensors repos (e.g. FP4 repos that also contain BF16 norm weights).
-
Return type:
file_exists()
file_exists(filename)
Returns whether the given file exists in the repo.
files_for_encoding()
files_for_encoding(encoding, weights_format=None)
Returns paths to weight files for the given encoding (and optionally format).
-
Parameters:
-
- encoding (max.pipelines.lib.config.SupportedEncoding)
- weights_format (WeightsFormat | None)
-
Return type:
-
dict[WeightsFormat, list[Path]]
formats_available
property formats_available: list[WeightsFormat]
Returns the weight formats available in this repo.
info
property info: ModelInfo
Returns Hugging Face model info (online repos only).
local_path
property local_path: str
Returns the filesystem directory backing this local repo.
For a hub id resolved under HF_HUB_OFFLINE this is the local
cache snapshot directory; otherwise it is the on-disk path itself.
-
Raises:
-
ValueError – If the repo is online.
repo_id
repo_id: str
The Hugging Face repo id. While it’s called repo_id, it can be a HF remote or local path altogether.
repo_type
repo_type: Literal['online', 'local']
The type of repo, inferred from repo_id.
revision
revision: str = 'main'
The revision to use for the repo.
size_of()
size_of(filename)
Returns file size in bytes for online repos, or None.
subfolder
Optional subdirectory within the repo to scope weight discovery to.
supported_encodings
property supported_encodings: list[max.pipelines.lib.config.SupportedEncoding]
Returns encodings supported by this repo’s weight files.
trust_remote_code
trust_remote_code: bool = False
Whether to trust remote code.
weight_files
property weight_files: dict[WeightsFormat, list[str]]
Returns weight file paths grouped by format (safetensors, gguf).
When subfolder is set, only files within that subdirectory are
returned. The returned paths are relative to the repo root (i.e. they
include the subfolder prefix) so that they can be passed directly to
hf_hub_download and local file resolution without further
adjustment.