Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed nll with label_smoothing to just nll #28708

Merged
merged 7 commits into from
Feb 20, 2024

Conversation

nileshkokane01
Copy link
Contributor

@nileshkokane01 nileshkokane01 commented Jan 25, 2024

What does this PR do?

This PR fixes #28167 by making label_smoothing= 0 .

Fixes #28167

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 or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@younesbelkada

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.

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Thanks ! Could you apply the same changes on the TF modeling file?

@nileshkokane01
Copy link
Contributor Author

@younesbelkada ,
Can you please review the changes?

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Thanks ! there is a small merge conflict with main - could you resolve that ? After that well be able to merge

src/transformers/models/blip/modeling_tf_blip_text.py Outdated Show resolved Hide resolved
@nileshkokane01
Copy link
Contributor Author

@younesbelkada ,
I rebased and resolved the conflict. I hope its a right way, or else let me know.

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Thank you @nileshkokane01 for your contribution !

@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.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

IMO that's a breaking change. Not sure if the best is to update the documentation or update this!
Should we add a config arg for this?

@ArthurZucker
Copy link
Collaborator

cc @younesbelkada

@younesbelkada
Copy link
Contributor

younesbelkada commented Feb 9, 2024

@ArthurZucker IMO this is not really breaking, it is even the opposite as it fixes some subtle bugs with respect to training with BLIP- see @NielsRogge ' comment here: #28167 (comment)

@younesbelkada
Copy link
Contributor

younesbelkada commented Feb 9, 2024

thinking a bit about it, indeed maybe we should make that configurable through a variable in the config so that potentially users could revert to original behaviour if needed.
@nileshkokane01 would be happy to adjust the PR accordingly? You just need to add a new variable label_smoothing in the blip config class and set it to 0

@nileshkokane01
Copy link
Contributor Author

@younesbelkada sure! I'll do that.

@younesbelkada
Copy link
Contributor

thank you @nileshkokane01 !

@nileshkokane01
Copy link
Contributor Author

@younesbelkada ,

Do I have to change the nll loss to the following as well:

loss_fct = CrossEntropyLoss(reduction=reduction, label_smoothing=self.config.lable_smoothing)

@younesbelkada
Copy link
Contributor

hi @nileshkokane01
Yes please, this sounds great

@nileshkokane01
Copy link
Contributor Author

@younesbelkada ,
can you have a look ?

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Looking good thanks ! left few nits on docstrings!

src/transformers/models/blip/configuration_blip.py Outdated Show resolved Hide resolved
src/transformers/models/blip/configuration_blip.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

Thanks for fixing and making this controllable!

@younesbelkada younesbelkada merged commit 49c0b29 into huggingface:main Feb 20, 2024
18 checks passed
itazap pushed a commit that referenced this pull request May 14, 2024
* Fixed nll with label_smoothing to nll

* Resolved conflict by rebase

* Fixed nll with label_smoothing to nll

* Resolved conflict by rebase

* Added label_smoothing to config file

* Fixed nits
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.

Misleading doc on BLIP outputs.loss: doesn't return true NLL but NLL *with label smoothing*
5 participants