bridge.models.hf_pretrained.utils#

Module Contents#

Functions#

is_safe_repo

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’, ‘MiniMaxAI’, ‘mistralai’, ‘moonshotai’, …

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_code is explicitly provided (True/False), its value takes precedence. 2. If trust_remote_code is 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