@@ -497,7 +497,7 @@ class OVModelForCausalLMIntegrationTest(unittest.TestCase):
497
497
)
498
498
GENERATION_LENGTH = 100
499
499
IS_SUPPORT_STATEFUL = is_openvino_version (">=" , "2023.3" )
500
- REMOTE_CODE_MODELS = ("chatglm" , )
500
+ REMOTE_CODE_MODELS = ("chatglm" ,)
501
501
502
502
@parameterized .expand (SUPPORTED_ARCHITECTURES )
503
503
def test_compare_to_transformers (self , model_arch ):
@@ -513,13 +513,16 @@ def test_compare_to_transformers(self, model_arch):
513
513
514
514
model_kwargs = {}
515
515
if model_arch in self .REMOTE_CODE_MODELS :
516
- model_kwargs = {"config" : AutoConfig .from_pretrained (model_id , trust_remote_code = True ), "trust_remote_code" : True }
516
+ model_kwargs = {
517
+ "config" : AutoConfig .from_pretrained (model_id , trust_remote_code = True ),
518
+ "trust_remote_code" : True ,
519
+ }
517
520
ov_model = OVModelForCausalLM .from_pretrained (model_id , export = True , ov_config = F32_CONFIG , ** model_kwargs )
518
521
self .assertIsInstance (ov_model .config , PretrainedConfig )
519
522
self .assertTrue (ov_model .use_cache )
520
- self .assertEqual (ov_model .stateful , self .IS_SUPPORT_STATEFUL and model_arch not in not_stateful )
523
+ self .assertEqual (ov_model .stateful , self .IS_SUPPORT_STATEFUL and ov_model . config . model_type not in not_stateful )
521
524
transformers_model = AutoModelForCausalLM .from_pretrained (model_id , ** model_kwargs )
522
- tokenizer = AutoTokenizer .from_pretrained (model_id , trust_remote_code = model_arch in remote_code )
525
+ tokenizer = AutoTokenizer .from_pretrained (model_id , trust_remote_code = model_arch in self . REMOTE_CODE_MODELS )
523
526
tokens = tokenizer (
524
527
"This is a sample" , return_tensors = "pt" , return_token_type_ids = False if model_arch == "llama" else None
525
528
)
@@ -552,9 +555,14 @@ def test_pipeline(self, model_arch):
552
555
model_kwargs = {}
553
556
model_id = MODEL_NAMES [model_arch ]
554
557
if model_arch in self .REMOTE_CODE_MODELS :
555
- model_kwargs = {"config" : AutoConfig .from_pretrained (model_id , trust_remote_code = True ), "trust_remote_code" : True }
558
+ model_kwargs = {
559
+ "config" : AutoConfig .from_pretrained (model_id , trust_remote_code = True ),
560
+ "trust_remote_code" : True ,
561
+ }
556
562
tokenizer = AutoTokenizer .from_pretrained (model_id , trust_remote_code = model_arch in self .REMOTE_CODE_MODELS )
557
- model = OVModelForCausalLM .from_pretrained (model_id , export = True , use_cache = False , compile = False , ** model_kwargs )
563
+ model = OVModelForCausalLM .from_pretrained (
564
+ model_id , export = True , use_cache = False , compile = False , ** model_kwargs
565
+ )
558
566
model .config .encoder_no_repeat_ngram_size = 0
559
567
model .to ("cpu" )
560
568
model .half ()
@@ -573,7 +581,10 @@ def test_multiple_inputs(self, model_arch):
573
581
set_seed (SEED )
574
582
model_kwargs = {}
575
583
if model_arch in self .REMOTE_CODE_MODELS :
576
- model_kwargs = {"config" : AutoConfig .from_pretrained (model_id , trust_remote_code = True ), "trust_remote_code" : True }
584
+ model_kwargs = {
585
+ "config" : AutoConfig .from_pretrained (model_id , trust_remote_code = True ),
586
+ "trust_remote_code" : True ,
587
+ }
577
588
model = OVModelForCausalLM .from_pretrained (model_id , export = True , compile = False , ** model_kwargs )
578
589
tokenizer = AutoTokenizer .from_pretrained (model_id , trust_remote_code = model_arch in self .REMOTE_CODE_MODELS )
579
590
tokenizer .pad_token = tokenizer .eos_token
0 commit comments