vllm.transformers_utils.repo_utils ¶
Utilities for model repo interaction.
Functions:
-
get_hf_file_bytes–Get file contents from HuggingFace repository as bytes.
-
get_hf_file_to_dict–Downloads a file from the Hugging Face Hub and returns
-
hf_api–Return a shared HfApi instance tagged with vLLM's library info.
-
hf_fs–Return a fresh HfFileSystem tagged with vLLM's library info.
-
try_get_local_file–Try to get a local file from the HuggingFace repository.
_try_download_from_hf_hub(model, file_name, revision) ¶
Try to download a file from HuggingFace Hub.
Returns the local path on success, None on failure. Skips download if model is a local directory.
Source code in vllm/transformers_utils/repo_utils.py
get_hf_file_bytes(file_name, model, revision='main') ¶
Get file contents from HuggingFace repository as bytes.
Source code in vllm/transformers_utils/repo_utils.py
get_hf_file_to_dict(file_name, model, revision='main') ¶
Downloads a file from the Hugging Face Hub and returns its contents as a dictionary.
Parameters: - file_name (str): The name of the file to download. - model (str): The name of the model on the Hugging Face Hub. - revision (str): The specific version of the model.
Returns: - config_dict (dict): A dictionary containing the contents of the downloaded file.
Source code in vllm/transformers_utils/repo_utils.py
hf_api() ¶
Return a shared HfApi instance tagged with vLLM's library info.
hf_fs() ¶
Return a fresh HfFileSystem tagged with vLLM's library info.
try_get_local_file(model, file_name, revision='main') ¶
Try to get a local file from the HuggingFace repository.
The possible return values are:
- A
Pathobject if the local file is found - The
huggingface_hub._CACHED_NO_EXISTsentinel if the file is known to not exist Noneif the file is not found and we cannot determine if it exists or not
Callers of this method should handle the _CACHED_NO_EXIST sentinel appropriately. Checking if the return value is not None is not sufficient because it does not distinguish between the file not existing and the file not being found.