bridge.models.hf_pretrained.utils#
Module Contents#
Functions#
Decide whether remote code execution should be enabled for a Hugging Face model or dataset repository. |
Data#
API#
- bridge.models.hf_pretrained.utils.logger#
āgetLogger(ā¦)ā
- bridge.models.hf_pretrained.utils.SAFE_REPOS: list[str]#
[ādeepseek-aiā, āgpt2ā, āgoogleā, āllava-hfā, āmeta-llamaā, āmistralaiā, āmoonshotaiā, ānvidiaā, āopā¦
- bridge.models.hf_pretrained.utils.is_safe_repo(hf_path: str, trust_remote_code: bool | None) bool#
Decide whether remote code execution should be enabled for a Hugging Face model or dataset repository.
This function follows three rules: 1. If
trust_remote_codeis explicitly provided (True/False), its value takes precedence. 2. Iftrust_remote_codeis None, the function checks whether the repo belongs to a predefined list of trusted repositories (SAFE_REPOS). 3. Otherwise, remote code execution is disabled.- Parameters:
hf_path (str) ā The Hugging Face repository identifier (e.g., āorg/model_nameā).
trust_remote_code (bool | None) ā If True, always allow remote code execution. If False, always disable it. If None, fall back to internal safety rules and trusted repo list.
- Returns:
Whether remote code execution should be enabled.
- Return type:
bool