Skip to content

Commit e1339bf

Browse files
authored
Fix Falcon validation (openvinotoolkit#1664)
The issue is not reproduced if using optimum-cli for export but only when cloning the entire model repo from the HF Hub.
1 parent 34d83ef commit e1339bf

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

tools/who_what_benchmark/whowhatbench/model_loaders.py

+25-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ def __init__(self, model, model_dir, model_type):
1919
self.model_type = model_type
2020

2121
if model_type == "text" or model_type == "visual-text":
22-
self.config = AutoConfig.from_pretrained(model_dir, trust_remote_code=True)
22+
try:
23+
self.config = AutoConfig.from_pretrained(model_dir, trust_remote_code=True)
24+
except Exception:
25+
self.config = AutoConfig.from_pretrained(model_dir)
2326
elif model_type == "text-to-image":
2427
self.config = DiffusionPipeline.load_config(
2528
model_dir, trust_remote_code=True)
@@ -101,17 +104,27 @@ def load_text_model(
101104
model = OVModelForCausalLM.from_pretrained(
102105
model_id, trust_remote_code=True, device=device, ov_config=ov_config
103106
)
104-
except ValueError:
105-
config = AutoConfig.from_pretrained(
106-
model_id, trust_remote_code=True)
107-
model = OVModelForCausalLM.from_pretrained(
108-
model_id,
109-
config=config,
110-
trust_remote_code=True,
111-
use_cache=True,
112-
device=device,
113-
ov_config=ov_config,
114-
)
107+
except Exception:
108+
try:
109+
config = AutoConfig.from_pretrained(
110+
model_id, trust_remote_code=True)
111+
model = OVModelForCausalLM.from_pretrained(
112+
model_id,
113+
config=config,
114+
trust_remote_code=True,
115+
use_cache=True,
116+
device=device,
117+
ov_config=ov_config,
118+
)
119+
except Exception:
120+
config = AutoConfig.from_pretrained(model_id)
121+
model = OVModelForCausalLM.from_pretrained(
122+
model_id,
123+
config=config,
124+
use_cache=True,
125+
device=device,
126+
ov_config=ov_config,
127+
)
115128

116129
return model
117130

0 commit comments

Comments
 (0)