fix template

This commit is contained in:
hiyouga 2023-08-09 23:10:20 +08:00
parent d86ea314a1
commit ac29f4d5f0
1 changed files with 3 additions and 3 deletions

View File

@ -97,10 +97,10 @@ class Template:
sep_ids = self._convert_inputs_to_ids(tokenizer, context=self.sep)
encoded_pairs = []
for turn_idx, (query, resp) in enumerate(history):
if turn_idx == 0 and prefix:
prefix_ids = self._convert_inputs_to_ids(tokenizer, context=prefix) + eos_ids + sep_ids
else:
if turn_idx != 0:
prefix_ids = sep_ids
elif prefix:
prefix_ids = self._convert_inputs_to_ids(tokenizer, context=prefix) + eos_ids + sep_ids
query_ids = self._convert_inputs_to_ids(tokenizer, context=self.prompt, query=query)
resp_ids = self._convert_inputs_to_ids(tokenizer, context=[resp])
encoded_pairs.append((bos_ids + prefix_ids + query_ids, resp_ids + eos_ids))