Python class
HuggingFaceRepo
HuggingFaceRepoβ
class max.pipelines.lib.HuggingFaceRepo(repo_id, revision='main', trust_remote_code=False, repo_type=None, subfolder=None)
Bases: object
Handle for interacting with a Hugging Face repository (remote or local).
-
Parameters:
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:
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).
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β
The type of repo. This is inferred from the 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.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!