Skip to content

Conversation

@cmpatino
Copy link
Contributor

What does this PR do?

Fixes the batchmean reduction in for the JSD loss in the GKDTrainer when no labels are passed to the function. It is supposed to be the seq_len and it was seq_len * vocab_size. The fixed loss now matches PyTorch's implementation of the batchmean reduction for the KLDivLoss.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a GitHub issue? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

The JSD loss in the GKDTrainer had the wrong denominator for the 'batchmean' reduce operation. It is supposed to be the seq_len and it was seq_len * vocab_size.
@HuggingFaceDocBuilderDev

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.

@kashif kashif merged commit 0450f05 into huggingface:main Sep 18, 2025
10 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