Skip to content

Commit dcf8860

Browse files
authored
convert : explicitly disable trust_remote_code for AutoConfig (#13246)
1 parent d24d592 commit dcf8860

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

convert_hf_to_gguf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,9 @@ def get_model_part_names(dir_model: Path, prefix: str, suffix: str) -> list[str]
419419
@staticmethod
420420
def load_hparams(dir_model: Path):
421421
try:
422-
return AutoConfig.from_pretrained(dir_model).to_dict()
422+
# for security reason, we don't allow loading remote code by default
423+
# if a model need remote code, we will fallback to config.json
424+
return AutoConfig.from_pretrained(dir_model, trust_remote_code=False).to_dict()
423425
except Exception as e:
424426
logger.warning(f"Failed to load model config from {dir_model}: {e}")
425427
logger.warning("Trying to load config.json instead")

0 commit comments

Comments
 (0)