Skip to content

Fixed nll with label_smoothing to just nll#28708

Merged
younesbelkada merged 7 commits into
huggingface:mainfrom
nileshkokane01:fix_nll
Feb 20, 2024
Merged

Fixed nll with label_smoothing to just nll#28708
younesbelkada merged 7 commits into
huggingface:mainfrom
nileshkokane01:fix_nll

Conversation

@nileshkokane01

@nileshkokane01 nileshkokane01 commented Jan 25, 2024

Copy link
Copy Markdown
Contributor

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.

@younesbelkada younesbelkada left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

@younesbelkada ,
Can you please review the changes?

@younesbelkada younesbelkada left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread src/transformers/models/blip/modeling_tf_blip_text.py Outdated
@nileshkokane01

Copy link
Copy Markdown
Contributor Author

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

@younesbelkada younesbelkada left a comment

Copy link
Copy Markdown
Contributor

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

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.

@ArthurZucker ArthurZucker left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator

cc @younesbelkada

@younesbelkada

younesbelkada commented Feb 9, 2024

Copy link
Copy Markdown
Contributor

@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

younesbelkada commented Feb 9, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

@younesbelkada sure! I'll do that.

@younesbelkada

Copy link
Copy Markdown
Contributor

thank you @nileshkokane01 !

@nileshkokane01

Copy link
Copy Markdown
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
Copy Markdown
Contributor

hi @nileshkokane01
Yes please, this sounds great

@nileshkokane01

Copy link
Copy Markdown
Contributor Author

@younesbelkada ,
can you have a look ?

@younesbelkada younesbelkada left a comment

Copy link
Copy Markdown
Contributor

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!

Comment thread src/transformers/models/blip/configuration_blip.py Outdated
Comment thread src/transformers/models/blip/configuration_blip.py Outdated

@amyeroberts amyeroberts left a comment

Copy link
Copy Markdown
Contributor

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