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!