-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: num_return_sequences should be less than num_beams, not top_k #5280
Conversation
Pull Request Test Coverage Report for Build 5518507439
💛 - Coveralls |
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.
@faaany Thank you for this contribution! The pull request looks very good to me already. Just two small things that could be improved and then we can merge it.
The warning message should include both values num_beams
and num_return_sequences
to make it easier for the user to understand how to set the parameters correctly.
Second, could you please add a small unit test that checks that the warning is displayed if
num_return_sequences
> num_beams
? You can add the test to the file test/prompt/invocation_layer/test_hugging_face.py
and it should be similar to the test called test_ensure_token_limit_negative
here: https://github.com/deepset-ai/haystack/blob/main/test/prompt/invocation_layer/test_hugging_face.py#L189
You shouldn't need a real model for that test so you can use mocking as in this other test:
def test_constructor_with_various_kwargs(mock_pipeline, mock_get_task): |
Happy to help with the mocking if that part is unclear. Just let me know. 🙂
done. My test run through, but I am not quite sure whether there is a better way to write this test. Feel free to leave comments, so I can update it quickly and write better unit tests in the future. Thanks a lot! |
@julian-risch any feedback on this? |
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.
@faaany Thank you for another contribution to Haystack! The pull request looks very good to me now. 👍 I extended the tests a bit to also check that num_return_sequences
is set to num_beams
as expected. I also changed the docstring describing the test accordingly. The init of HFLocalInvocationLayer I was able to simplify. Have a look if you're interested. Your test was quite good already before this final polishing step. Great work! 🙂
Wow, the tests look really good now! Thanks so much! Learned new stuff again. lol |
Related Issues
Proposed Changes:
num_beams
instead oftop_k
and removetop_k
, because the realtop_k
is used for top-k sampling or sampling decoding methods not beam searchnum_return_sequences
, not by usHow did you test it?
manual test
Notes for the reviewer
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
.