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’, ā€˜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_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