Skip to content

Deprecate keep_end truncation mode#5465

Merged
albertvillanova merged 6 commits intohuggingface:mainfrom
albertvillanova:fu-5372-deprecate-keep-end
Apr 7, 2026
Merged

Deprecate keep_end truncation mode#5465
albertvillanova merged 6 commits intohuggingface:mainfrom
albertvillanova:fu-5372-deprecate-keep-end

Conversation

@albertvillanova
Copy link
Copy Markdown
Member

@albertvillanova albertvillanova commented Apr 7, 2026

Deprecate "keep_end" truncation mode.

See related discussion:

This PR deprecates the "keep_end" truncation mode in the DPOConfig and SFTConfig classes, warning users that it will be removed in version 2.0.0. The changes update documentation, add a deprecation warning at runtime, and adjust tests to expect this warning.

Changes

Deprecation of "keep_end" truncation mode:

  • Updated the docstring and help metadata for the truncation_mode parameter in DPOConfig and SFTConfig to state that only "keep_start" is supported, and that "keep_end" is deprecated and will be removed in v2.0.0.
  • Added a runtime warning in __post_init__ to emit a FutureWarning if "keep_end" is used, guiding users to switch to "keep_start".

Test updates:

  • Modified the regression tests test_train_vlm_keep_end_raises and test_skip_prepare_dataset_passes_truncation_to_text_collator to expect a FutureWarning when "keep_end" is used, ensuring the deprecation warning is tested.

Note

Medium Risk
Behavior is backwards-compatible but introduces a new FutureWarning that can fail user pipelines configured to treat warnings as errors; otherwise the change is localized to config initialization and tests.

Overview
DPOConfig now deprecates truncation_mode="keep_end": docs/help text were updated to state keep_start is the only supported mode, and using keep_end emits a FutureWarning indicating it will be removed in v2.0.0.

Tests were updated to assert the new deprecation warning is raised when initializing DPOConfig with keep_end (while still expecting the existing VLM ValueError guard).

Reviewed by Cursor Bugbot for commit 0361a1e. Bugbot is set up for automated code reviews on this repo. 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.

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 0361a1e. Configure here.

@albertvillanova albertvillanova merged commit 9bacce7 into huggingface:main Apr 7, 2026
23 of 24 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