transformers
e6347996 - Fix CohereASR training-loss double-shift (same as Moonshine fix #46784) (#46895)

Commit
124 days ago
Fix CohereASR training-loss double-shift (same as Moonshine fix #46784) (#46895) * Fix CohereASR training-loss double-shift (same as Moonshine fix #46784) CohereAsrForConditionalGeneration shifts labels right via shift_tokens_right() to create decoder_input_ids, then calls self.loss_function() which maps to ForCausalLMLoss — that function shifts labels again internally. This causes the model to train against labels[..., 1:] instead of labels. Replace self.loss_function() with plain CrossEntropyLoss, matching the fix applied to Moonshine in #46784. * Use shift_labels parameter instead of CrossEntropyLoss (per reviewer feedback) * Use do_shift_labels flag: only skip shift when shift_tokens_right() was called (per reviewer) * Add test for training loss no double shift * Retrigger CI * Fix test: use ParakeetEncoderModelOutput with attention_mask * Simplify: always pass shift_labels=labels (per reviewer feedback)
Author
Parents
Loading