From 3754dc1b677f5d1a46253c9bda7e6f013ad21dd6 Mon Sep 17 00:00:00 2001 From: zhulinJulia24 <145004780+zhulinJulia24@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:00:52 +0800 Subject: [PATCH] update (#1522) Co-authored-by: zhulin1 --- opencompass/models/lmdeploy_pytorch.py | 2 ++ opencompass/models/turbomind_with_tf_above_v4_33.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/opencompass/models/lmdeploy_pytorch.py b/opencompass/models/lmdeploy_pytorch.py index bb195b64..80924c27 100644 --- a/opencompass/models/lmdeploy_pytorch.py +++ b/opencompass/models/lmdeploy_pytorch.py @@ -86,6 +86,8 @@ class LmdeployPytorchModel(BaseModel): for token_id in generation_config.eos_token_id: stop_words.append(token_id) gen_config.stop_words = stop_words + if version_info >= (0, 6, 0): + gen_config.stop_token_ids = stop_words self.gen_config = gen_config self.end_str = end_str self.major_version, self.minor_version = version_info[:2] diff --git a/opencompass/models/turbomind_with_tf_above_v4_33.py b/opencompass/models/turbomind_with_tf_above_v4_33.py index ccda31f6..48706671 100644 --- a/opencompass/models/turbomind_with_tf_above_v4_33.py +++ b/opencompass/models/turbomind_with_tf_above_v4_33.py @@ -126,6 +126,7 @@ class TurboMindModelwithChatTemplate(BaseModel): 'top_k': 1, 'stop_words': encode_stop_words, } + gen_config = copy.deepcopy(DEFAULT_GEN_CONFIG) gen_config.update(self.gen_config) if do_sample: @@ -134,6 +135,9 @@ class TurboMindModelwithChatTemplate(BaseModel): from lmdeploy.messages import GenerationConfig gen_config = GenerationConfig(**gen_config) + if self.version_info >= (0, 6, 0): + gen_config.stop_words = stop_words + gen_config.convert_stop_bad_words_to_ids(self.tokenizer) results = [] for batch_message in batch_messages: