Skip to content

Remove dead token attributes from experimental trainers#5565

Merged
albertvillanova merged 2 commits into
huggingface:mainfrom
albertvillanova:rm-dead-self-tokens-exp
Apr 17, 2026
Merged

Remove dead token attributes from experimental trainers#5565
albertvillanova merged 2 commits into
huggingface:mainfrom
albertvillanova:rm-dead-self-tokens-exp

Conversation

@albertvillanova
Copy link
Copy Markdown
Member

@albertvillanova albertvillanova commented Apr 16, 2026

Remove dead token attributes from experimental trainers.

This PR refactors the initialization logic across several experimental trainer classes by removing redundant assignments of the pad_token attribute. The changes ensure that only the necessary token ID attributes are set, leading to a cleaner and more consistent codebase.

Follow-up to:

Changes

  • Removed unnecessary assignment of self.pad_token = tokenizer.pad_token in the OnlineDPOTrainer, SDFTTrainer, and SSDTrainer classes, as only the token IDs are required for downstream processing. [
  • In the BaseSelfDistillationTrainer, removed assignments for self.pad_token, self.pad_token_id, and self.eos_token_id, streamlining the initialization to only include relevant attributes.

Note

Low Risk
Small refactor removing an unused attribute; behavior should be unchanged as padding continues to use pad_token_id/eos_token_id.

Overview
Removes redundant self.pad_token = tokenizer.pad_token assignments from several experimental trainers (OnlineDPOTrainer, SDFTTrainer, BaseSelfDistillationTrainer, SSDTrainer), standardizing on storing only pad_token_id/eos_token_id after ensuring a pad token is set on the tokenizer.

This is a small cleanup to eliminate dead attributes and keep trainer initialization consistent without changing generation/padding behavior.

Reviewed by Cursor Bugbot for commit 9e432f2. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit af504f5. Configure here.

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

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.

@albertvillanova albertvillanova merged commit 21cf71d into huggingface:main Apr 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants