lmflow.pipeline.utils.dpov2_dataprocessor#
Attributes#
Classes#
Module Contents#
- class lmflow.pipeline.utils.dpov2_dataprocessor.PreferenceDataCollatorWithPadding[source]#
-
- tokenize_batch_element(prompt: str, chosen: str, rejected: str) Dict [source]#
Tokenize a single batch element.
- At this stage, we don’t convert to PyTorch tensors yet; we just handle the truncation
in case the prompt + chosen or prompt + rejected responses is/are too long. First we truncate the prompt; if we’re still too long, we truncate the chosen/rejected.
- We also create the labels for the chosen/rejected responses, which are of length equal to
the sum of the length of the prompt and the chosen/rejected response, with label_pad_token_id for the prompt tokens.