diff --git a/lmdeploy/model.py b/lmdeploy/model.py index 19043e485e..dbb824b81f 100644 --- a/lmdeploy/model.py +++ b/lmdeploy/model.py @@ -265,9 +265,13 @@ def decorate_prompt(self, prompt, sequence_start=True): assert self.capability == 'chat', \ f'{type(self).__name__} has no capability of {self.capability}' if sequence_start: - return f'{self.system}{self.meta_instruction}{self.eosys}' \ - f'{self.user}{prompt}{self.eoh}' \ + ret = '' + if self.meta_instruction: + ret += f'{self.system}{self.meta_instruction}{self.eosys}' + ret += f'{self.user}{prompt}{self.eoh}' \ f'{self.assistant}' + return ret + else: return f'\n{self.user}{prompt}{self.eoh}' \ f'{self.assistant}' @@ -287,7 +291,7 @@ def messages2prompt(self, messages, sequence_start=True): eox_map = dict(user=self.eoh, assistant=self.eoa, system=self.eosys) ret = '' if self.meta_instruction: - ret += f'{self.system}:{self.meta_instruction}{self.eosys}' + ret += f'{self.system}{self.meta_instruction}{self.eosys}' for message in messages: role = message['role']