-
Notifications
You must be signed in to change notification settings - Fork 31k
Add early stopping for Bark generation via logits processor #26675
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
Conversation
|
@ylacombe maybe we can continue the conversation here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @isaac-chung , thanks for the quick PR and for the good job!
I left a few comments here, let me know if you still have questions!
Other than that, for testing, I would add a test_XXXX on LogitsProcessorTest which first checks that the new logits processor behaves as expected with an hand-made example.
Ideally, we'd have another test on BarkSemanticModelTest, but I'm not sure how to proceed yet.
Do you have any ideas?
I'm not entirely sure. Maybe we could assert outputs from
To confirm that we support this, maybe we should add to |
|
Let's try to do both! |
|
I think I managed to add to
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @isaac-chung, I've addressed 2. in the comments below! I'm not sure to understand point 1. though, could you expand on this a bit ?
thanks!
|
@ylacombe thanks! Regarding 1, let's take |
|
Let's try to find a case where the semantic model has to stop. You can get inspiration from that test: transformers/tests/models/bark/test_modeling_bark.py Lines 904 to 921 in d085662
So basically, an example where, the same seed, the last output tokens are different, do you think it's possible? |
|
If we set Is that what you have in mind? |
|
Oh, that seems weird, have you tried with another generation strategy ? (i.e |
|
Regarding using a stopping criteria, I don't think it's possible at the moment -> quoting #26672
|
|
It receives None because |
|
Yes of course, but don't you think users should have the liberty to set |
|
For sure. So the goal here is by default to always stop early? (actually not returning the scores might be better in terms of memory ?) |
Yes this is the goal here. Totally agree on the stopping criteria usage! Actually I haven't find a stopping criteria which uses |
|
Hey @ylacombe / @ArthurZucker , please let me know if there's anything else I can do to further this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits. Other than that, looks good to me! Thank you for working on it 💪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for iterating 💛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for iterating here @isaac-chung !
@ArthurZucker could you make a final review?
Two last demands on my side:
- are all the bark integration tests passing ? Could you make sure they are?
- At the risk of repeating myself, we still need a test to make sure that generated ids with
min_eos_p>0are shorter than generated ids without it.
|
btw, regarding it being a logits processor vs stopping criteria: it is my impression that we want to generate an EOS token under the conditions defined here. Since we want to generate a token, it has to be a logits processor. (the main difference between them is that the stopping criteria stops generation right away, and doesn't add any new token -- for batched generation, this can make a big difference) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, let's just keep camel case and adresse the comments from @ylacombe !
|
@ylacombe I've run this command and all tests are passing ✅ |
|
LGTM ! Let's wait for all the check to pass and merge then! Thanks for the great work here and all the iterations! |
|
Thank you all again for your guidance and patience 🙏 much appreciated. |
…ace#26675) * add early stopping logits processor * black formmated * indent * follow method signature * actual logic * check for None * address comments on docstrings and method signature * add unit test under `LogitsProcessorTest` wip * unit test passing * black formatted * condition per sample * add to BarkModelIntegrationTests * wip BarkSemanticModelTest * rename and add to kwargs handling * not add to BarkSemanticModelTest * correct logic and assert last outputs tokens different in test * doc-builder style * read from kwargs as well * assert len of with less than that of without * ruff * add back seed and test case * add original impl default suggestion * doc-builder * rename and use softmax * switch back to LogitsProcessor and update docs wording * camelCase and spelling and saving compute * assert strictly less than * assert less than * expand test_generate_semantic_early_stop instead
What does this PR do?
Fixes # (issue) #26672
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
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.