Repository navigation
fix(train): decode TRL 1.x DPO columns in the tokenized preview - #73
Merged
Merged
Conversation
Neonkraft
requested review from
Ali-Elganzory
and
a balanced review from Copilot
November 12, 2026 10:19
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the tokenized-preview compatibility update.
No open issues 🎉
What changed in this PR
Fixes the training script’s tokenized preview to recognize TRL 1.x DPO column names while preserving support for SFT and older TRL formats.
Changes:
- Adds
_is_token_id_column()to recognize supported token-ID columns explicitly. - Uses the helper when decoding preview samples, avoiding unrelated columns such as
token_type_ids.
| File | Description |
|---|---|
scripts/train.py |
Adds token-ID column detection and updates preview decoding to support TRL 1.x DPO datasets. |
Review effort: Balanced
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.
Problem
The tokenized preview in
scripts/train.pydecoded only columns whose names end ininput_ids. TRL 0.x named the DPO columnsprompt_input_ids/chosen_input_ids/rejected_input_ids, but TRL 1.x renamed them toprompt_ids/chosen_ids/rejected_ids. The DPO preview therefore printed[Sample 0]with nothing under it. SFT (input_ids) was not affected.Fix
Add
_is_token_id_column(), which decodesinput_ids, any*_input_idscolumn (older TRL), andprompt_ids/chosen_ids/rejected_ids/completion_ids. An explicit list is used instead of a_idssuffix match, so columns such astoken_type_idsare not decoded.Testing
--tokenize-onlyon a small CPU config (SmolLM2-135M,olmo3-instruct-sfttemplate), with TRL 1.7.0 and TRL 1.17.1:Sample DPO output (TRL 1.17.1):