From 734628a61effdd8d2d2239e81aac58d0bccd4bab Mon Sep 17 00:00:00 2001 From: ssbuild <462304@qq.com> Date: Wed, 12 Jun 2024 23:21:44 +0800 Subject: [PATCH] glm4 --- README.md | 5 +++-- src/deep_training/zoo/model_zoo/glm4v/llm_model.py | 10 ++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f55ad69..68e9d47 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,11 @@ pip install -U git+https://github.com/ssbuild/deep_training.git --no-deps --forc ## update - 2024-06-10 - - 0.3.1 support glm4,glm4v + - 0.3.1 support glm4 https://github.com/ssbuild/glm4_finetuning + glm4v https://github.com/ssbuild/glm4v_finetuning - 2024-02-15 - - 0.2.11 support internlm2 + - 0.2.11 support internlm2 https://github.com/ssbuild/internlm2_finetuning - 2023-12-02 - 0.2.10 update qwen model for 1.8b 7b 14b 72b diff --git a/src/deep_training/zoo/model_zoo/glm4v/llm_model.py b/src/deep_training/zoo/model_zoo/glm4v/llm_model.py index b4b896a..189f9fd 100644 --- a/src/deep_training/zoo/model_zoo/glm4v/llm_model.py +++ b/src/deep_training/zoo/model_zoo/glm4v/llm_model.py @@ -64,15 +64,14 @@ def process_response(self, output, history): @torch.inference_mode() def chat(self, tokenizer, query: str, history: List[Dict] = None, role: str = "user", image=None, - max_length: int = 8192, num_beams=1, do_sample=True, top_p=0.8, temperature=0.8, logits_processor=None, + logits_processor=None, **kwargs): if history is None: history = [] if logits_processor is None: logits_processor = LogitsProcessorList() logits_processor.append(InvalidScoreLogitsProcessor()) - gen_kwargs = {"max_length": max_length, "num_beams": num_beams, "do_sample": do_sample, "top_p": top_p, - "temperature": temperature, "logits_processor": logits_processor, **kwargs} + gen_kwargs = {"logits_processor": logits_processor, **kwargs} message = {"role": role, "content": query} if image is not None: message["image"] = image @@ -90,7 +89,7 @@ def chat(self, tokenizer, query: str, history: List[Dict] = None, role: str = "u @torch.inference_mode() def stream_chat(self, tokenizer, query: str, history: List[Dict] = None, role: str = "user", image=None, - past_key_values=None, max_length: int = 8192, do_sample=True, top_p=0.8, temperature=0.8, + past_key_values=None, logits_processor=None, return_past_key_values=False, **kwargs): if history is None: history = [] @@ -99,8 +98,7 @@ def stream_chat(self, tokenizer, query: str, history: List[Dict] = None, role: s logits_processor.append(InvalidScoreLogitsProcessor()) eos_token_id = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|user|>"), tokenizer.convert_tokens_to_ids("<|observation|>")] - gen_kwargs = {"max_length": max_length, "do_sample": do_sample, "top_p": top_p, - "temperature": temperature, "logits_processor": logits_processor, **kwargs} + gen_kwargs = {"logits_processor": logits_processor, **kwargs} message = {"role": role, "content": "query"} if image is not None: message["image"] = image