@@ -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,18 @@ 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 (
524
+ ov_model .stateful , self .IS_SUPPORT_STATEFUL and ov_model .config .model_type not in not_stateful
525
+ )
521
526
transformers_model = AutoModelForCausalLM .from_pretrained (model_id , ** model_kwargs )
522
- tokenizer = AutoTokenizer .from_pretrained (model_id , trust_remote_code = model_arch in remote_code )
527
+ tokenizer = AutoTokenizer .from_pretrained (model_id , trust_remote_code = model_arch in self . REMOTE_CODE_MODELS )
523
528
tokens = tokenizer (
524
529
"This is a sample" , return_tensors = "pt" , return_token_type_ids = False if model_arch == "llama" else None
525
530
)
@@ -552,9 +557,14 @@ def test_pipeline(self, model_arch):
552
557
model_kwargs = {}
553
558
model_id = MODEL_NAMES [model_arch ]
554
559
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 }
560
+ model_kwargs = {
561
+ "config" : AutoConfig .from_pretrained (model_id , trust_remote_code = True ),
562
+ "trust_remote_code" : True ,
563
+ }
556
564
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 )
565
+ model = OVModelForCausalLM .from_pretrained (
566
+ model_id , export = True , use_cache = False , compile = False , ** model_kwargs
567
+ )
558
568
model .config .encoder_no_repeat_ngram_size = 0
559
569
model .to ("cpu" )
560
570
model .half ()
@@ -573,7 +583,10 @@ def test_multiple_inputs(self, model_arch):
573
583
set_seed (SEED )
574
584
model_kwargs = {}
575
585
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 }
586
+ model_kwargs = {
587
+ "config" : AutoConfig .from_pretrained (model_id , trust_remote_code = True ),
588
+ "trust_remote_code" : True ,
589
+ }
577
590
model = OVModelForCausalLM .from_pretrained (model_id , export = True , compile = False , ** model_kwargs )
578
591
tokenizer = AutoTokenizer .from_pretrained (model_id , trust_remote_code = model_arch in self .REMOTE_CODE_MODELS )
579
592
tokenizer .pad_token = tokenizer .eos_token
0 commit comments