Fix training-loss double-shift in Florence2 and CohereASR#46916
Closed
muhamedfazalps wants to merge 4 commits into
Closed
Fix training-loss double-shift in Florence2 and CohereASR#46916muhamedfazalps wants to merge 4 commits into
muhamedfazalps wants to merge 4 commits into
Conversation
…ch_device, ordered model/inputs)
Replace self.loss_function (ForCausalLMLoss) with plain CrossEntropyLoss to prevent double-shifting of labels. The forward method already shifts labels into decoder_input_ids, so the loss must be computed against the original labels without a second shift. Same pattern as the Moonshine fix in huggingface#46784. Fixes huggingface#46897 (Florence2) and huggingface#46894 (CohereASR)
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: cohere_asr, florence2 |
Contributor
|
CI Dashboard: View test results in Grafana |
Member
|
Duplicate of #46898! |
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.
self.loss_functionin Florence2 and CohereASR usesForCausalLMLosswhich shifts labels again internally, causing the model to train againstlabels[..., 1:]instead of the actual labels (since the forward method already shifts labels intodecoder_input_ids).Same pattern as the Moonshine fix in #46784. Replacing with plain
CrossEntropyLossso the loss is computed against the original labels without a second shift.Fixes #46897 (Florence2) and #46894 (CohereASR).