diff --git a/examples/pytorch/chatglm6b/finetune.py b/examples/pytorch/chatglm6b/finetune.py index bf3953e8..6d04924c 100644 --- a/examples/pytorch/chatglm6b/finetune.py +++ b/examples/pytorch/chatglm6b/finetune.py @@ -196,7 +196,7 @@ tokenizer = ChatGLMTokenizer.from_pretrained(model_dir, trust_remote_code=True) device_map_kwargs = {} device_kwargs = {} if args.use_lora != 0: - device_kwargs['device_map'] = 'auto' + device_map_kwargs['device_map'] = 'auto' # No placement for model, leave the model to `device_map` device_kwargs['device'] = 'cpu' model = Model.from_pretrained( diff --git a/modelscope/models/nlp/chatglm/text_generation.py b/modelscope/models/nlp/chatglm/text_generation.py index 53f8f105..64b82862 100644 --- a/modelscope/models/nlp/chatglm/text_generation.py +++ b/modelscope/models/nlp/chatglm/text_generation.py @@ -931,7 +931,6 @@ class ChatGLMModel(ChatGLMPreTrainedModel): self.num_attention_heads, self.hidden_size // self.num_attention_heads) # seq_len, b, nh, hidden_size - print('#########################:', past_key_values.device) past_key_values = self.dropout(past_key_values) past_key_values = past_key_values.permute([2, 1, 0, 3, 4]).split(2) # past_key_values = [(v[0], v[1]) for v in past_key_values] diff --git a/modelscope/pipelines/nlp/text_generation_pipeline.py b/modelscope/pipelines/nlp/text_generation_pipeline.py index a7806702..cb9c89db 100644 --- a/modelscope/pipelines/nlp/text_generation_pipeline.py +++ b/modelscope/pipelines/nlp/text_generation_pipeline.py @@ -197,8 +197,8 @@ class ChatGLM6bTextGenerationPipeline(Pipeline): if isinstance(model, str): model_dir = snapshot_download( model) if not os.path.exists(model) else model - config = ChatGLMConfig.from_pretrained(model_dir) - model = ChatGLMForConditionalGeneration(config).half() + model = ChatGLMForConditionalGeneration.from_pretrained( + model_dir).half() if torch.cuda.is_available(): model = model.cuda() if quantization_bit is not None: @@ -235,8 +235,7 @@ class ChatGLM6bV2TextGenerationPipeline(Pipeline): if isinstance(model, str): model_dir = snapshot_download( model) if not os.path.exists(model) else model - config = ChatGLM2Config.from_pretrained(model_dir) - model = ChatGLM2ForConditionalGeneration(config) + model = ChatGLM2ForConditionalGeneration.from_pretrained(model_dir) if torch.cuda.is_available(): model = model.cuda() if quantization_bit is not None: