Skip to content

Commit

Permalink
[Fix] interlm messages2prompt (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
Harold-lkk authored Jan 19, 2024
1 parent 4f910c2 commit d2efef3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lmdeploy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
Expand All @@ -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']
Expand Down

0 comments on commit d2efef3

Please sign in to comment.