Skip to content

Commit 234ad87

Browse files
authored
fix phi3 conversion (openvinotoolkit#440)
1 parent 2bc9a7f commit 234ad87

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

llm_bench/python/convert.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ def ts_patched_forward(
972972
remote_code = False
973973
pt_model = None
974974
try:
975-
config = AutoConfig.from_pretrained(args.model_id)
975+
config = AutoConfig.from_pretrained(args.model_id, trust_remote_code=False)
976976
except Exception:
977977
config = AutoConfig.from_pretrained(args.model_id, trust_remote_code=True)
978978
remote_code = True
@@ -1215,14 +1215,13 @@ def convert_falcon(args):
12151215
def convert_phi(args):
12161216
trust_remote_code = False
12171217
try:
1218-
config = AutoConfig.from_pretrained(args.model_id)
1218+
config = AutoConfig.from_pretrained(args.model_id, trust_remote_code=False)
12191219
except Exception:
12201220
config = AutoConfig.from_pretrained(args.model_id, trust_remote_code=True)
12211221
trust_remote_code = True
12221222
cuda, post_init = patch_gptq(config)
12231223
model_kwargs = {}
1224-
if trust_remote_code:
1225-
model_kwargs["trust_remote_code"] = trust_remote_code
1224+
model_kwargs["trust_remote_code"] = trust_remote_code
12261225
precision = args.precision
12271226
compression_only = (
12281227
args.compress_weights
@@ -1238,7 +1237,7 @@ def convert_phi(args):
12381237
if not compression_only:
12391238
pt_model = AutoModelForCausalLM.from_pretrained(
12401239
args.model_id,
1241-
config=AutoConfig.from_pretrained(args.model_id),
1240+
config=config,
12421241
**model_kwargs,
12431242
)
12441243
pt_model.config.use_cache = True

llm_bench/python/utils/ov_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def create_text_gen_model(model_path, device, **kwargs):
143143
else:
144144
remote_code = False
145145
try:
146-
model_config = AutoConfig.from_pretrained(model_path)
146+
model_config = AutoConfig.from_pretrained(model_path, trust_remote_code=False)
147147
except Exception:
148148
model_config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)
149149
remote_code = True

0 commit comments

Comments
 (0)