trl.DataCollatorForCompletionOnlyLM
Data collator used for completion tasks.
It ensures that all the tokens of the labels are set to an 'ignore_index' when they do not come from the assistant.
This ensure that the loss is only calculated on the completion made by the assistant.
「assistantによって補完されたテキストのみについてロスを計算することを保証する」
response_template(とinstruction_template)を渡す
一部のtokenizer(例:Llama 2)はコンテキストによってencodeが異なるらしい
response_token_ids_start_idxが見つからない場合
This instance will be ignored in loss calculation.
「ロスの計算では無視する」
batch["labels"][i, :] = self.ignore_index(全部無視するindexに設定している)
IMO:サンプルに含まれるが、ロスの計算では無視ということ?
data collatorが返したbatchをもとにロスを計算しているっぽい