From 234ad874af678d471e385e08824f1e17ecb4591a Mon Sep 17 00:00:00 2001 From: Ekaterina Aidova Date: Tue, 14 May 2024 13:43:39 +0400 Subject: [PATCH] fix phi3 conversion (#440) --- llm_bench/python/convert.py | 9 ++++----- llm_bench/python/utils/ov_utils.py | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/llm_bench/python/convert.py b/llm_bench/python/convert.py index 01312b4ebe..221752bcfc 100644 --- a/llm_bench/python/convert.py +++ b/llm_bench/python/convert.py @@ -972,7 +972,7 @@ def ts_patched_forward( remote_code = False pt_model = None try: - config = AutoConfig.from_pretrained(args.model_id) + config = AutoConfig.from_pretrained(args.model_id, trust_remote_code=False) except Exception: config = AutoConfig.from_pretrained(args.model_id, trust_remote_code=True) remote_code = True @@ -1215,14 +1215,13 @@ def convert_falcon(args): def convert_phi(args): trust_remote_code = False try: - config = AutoConfig.from_pretrained(args.model_id) + config = AutoConfig.from_pretrained(args.model_id, trust_remote_code=False) except Exception: config = AutoConfig.from_pretrained(args.model_id, trust_remote_code=True) trust_remote_code = True cuda, post_init = patch_gptq(config) model_kwargs = {} - if trust_remote_code: - model_kwargs["trust_remote_code"] = trust_remote_code + model_kwargs["trust_remote_code"] = trust_remote_code precision = args.precision compression_only = ( args.compress_weights @@ -1238,7 +1237,7 @@ def convert_phi(args): if not compression_only: pt_model = AutoModelForCausalLM.from_pretrained( args.model_id, - config=AutoConfig.from_pretrained(args.model_id), + config=config, **model_kwargs, ) pt_model.config.use_cache = True diff --git a/llm_bench/python/utils/ov_utils.py b/llm_bench/python/utils/ov_utils.py index ed62498fc6..a2416ccb92 100644 --- a/llm_bench/python/utils/ov_utils.py +++ b/llm_bench/python/utils/ov_utils.py @@ -143,7 +143,7 @@ def create_text_gen_model(model_path, device, **kwargs): else: remote_code = False try: - model_config = AutoConfig.from_pretrained(model_path) + model_config = AutoConfig.from_pretrained(model_path, trust_remote_code=False) except Exception: model_config = AutoConfig.from_pretrained(model_path, trust_remote_code=True) remote_code = True