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, repo_type=None, subfolder=None, _hub_repo_id=None)
Bases: object
Handle for interacting with a Hugging Face repository (remote or local).
-
Parameters:
config_repo_id
property config_repo_id: str
Identifier to pass to transformers *.from_pretrained.
For repos resolved from the offline HF cache, repo_id was rewritten
to a local snapshot directory; this returns the original hub id instead,
keeping transformers on its hub/cache code path. transformers 5.12’s
trust_remote_code loader otherwise resolves the snapshot symlink into
blobs/ and fails to find sibling relative imports. For all other
repos this is just repo_id.
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).
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.