Don't dupe BOS

Ensure completion batching doesn't allow BOS dupes for instruction models with chat models whose tokenizer configurations have ```add_bos_token = True``` (see: 1095)
This commit is contained in:
Chime Ogbuji 2024-11-10 10:08:44 -05:00 committed by Awni Hannun
parent 69282ab7fc
commit 3f08dfc762

View File

@ -166,7 +166,7 @@ def iterate_completion_batches(
for j in batch_idx[i]:
prompt, completion = dataset.get_prompt_and_completion(j)
prompt_lengths.append(input_length(prompt, completion, tokenizer))
full_sequence = tokenizer.encode(dataset[j])
full_sequence = tokenizer.encode(dataset[j], add_special_tokens=False)
if full_sequence[-1] != tokenizer.eos_token_id:
full_sequence.append(tokenizer.eos_token_id)
batch.append(full_sequence)