You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DataCollatorForCompletionOnlyLM(DataCollatorForLanguageModeling):
def torch_call(self, examples):
batch = super().torch_call(examples)
# The prompt ends with the response key plus a newline
response_token_ids = self.tokenizer.encode(RESPONSE_KEY_NL)
labels = batch["labels"].clone()
for i in range(len(examples)):
response_token_ids_start_idx = None
for idx in np.where(batch["labels"][i] == response_token_ids[0])[0]:
response_token_ids_start_idx = idx
break
if response_token_ids_start_idx is None:
raise RuntimeError(
f'Could not find response key {response_token_ids} in token IDs {batch["labels"][i]}'
)
response_token_ids_end_idx = response_token_ids_start_idx + 1
# loss function ignore all tokens up through the end of the response key
labels[i, :response_token_ids_end_idx] = -100
batch["labels"] = labels
return batch
data_collator = DataCollatorForCompletionOnlyLM(
tokenizer=tokenizer, mlm=False, return_tensors="pt", pad_to_multiple_of=8
)
I am assumig they are also needed? Or Am I missing something?
The text was updated successfully, but these errors were encountered:
In your finetuning code at:
https://colab.research.google.com/drive/1n5U13L0Bzhs32QO_bls5jwuZR62GPSwE?usp=sharing
As per dolly code, special tokens needs to be loaded to tokenizer
Also, you have not modified data_collator
I am assumig they are also needed? Or Am I missing something?
The text was updated successfully, but these errors were encountered: