Co-authored-by: zhulin1 <zhulin1@pjlab.org.cn>
This commit is contained in:
zhulinJulia24 2024-09-12 15:00:52 +08:00 committed by GitHub
parent 7c7fa36235
commit 3754dc1b67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -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]

View File

@ -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: