Align data collators across DPO / SFT / Reward / KTO#6178
Open
qgallouedec wants to merge 3 commits into
Open
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consistency pass over the data collators so the same thing is written the same way everywhere. No behavior change.
max_length,truncation_mode,return_tensors) and the# special case for Qwen2.5-VLcomment. Added the missingExamplesblocks to the KTO collators.batch→output,ex→example,torch.int64→torch.long."token_type_ids" in processed_promptschecks (dropping thehas_tti/has_mm_ttilocals) so its flush-left / truncate / output blocks match DPO/SFT word-for-word; simplifiedmm_token_type_idshandling to match.Deeper output-key naming/semantics (e.g. KTO's
completion_input_idsholds prompt+completion) is left for a follow-up PR.Note
Low Risk
Collator-only refactor with stated no behavior change; the mm_token_type_ids merge simplification could affect edge-case VLMs if completion tensors previously carried non-zero mm types.
Overview
Consistency pass across DPO, SFT, and KTO data collators so docstrings, naming, and vision collator control flow match; the PR description states no intended behavior change.
Documentation: Unified
max_length,truncation_mode, andreturn_tensorswording; expanded KTO text and vision collator docs with Examples blocks; reordered DPO vision output key list; clarified SFTmax_lengthas truncate-before-pad for text collators.KTO text collator: Renames
batch→output,ex→example; usestorch.longinstead of explicitint64on tensors; adds inline Truncate / Pad comments aligned with DPO.Vision collators (KTO, DPO, SFT): Replaces
has_tti/has_mm_ttilocals with inline"token_type_ids" in processed_promptschecks; aligns flush-left, truncate, and output blocks with DPO/SFT; sets completion-sidemm_token_type_idsviatorch.zeros_like(completion_ids)instead of merging processor completionmm_token_type_ids(KTO KL path similarly); fixes BOS comment typo (BOS, twice→BOS twice); DPO adds a Truncate if necessary comment before the vision truncation block.Reviewed by Cursor Bugbot for commit 640f53b. Bugbot is set up for automated code reviews on this repo. Configure here.