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

Add multinomial sampling to sequence generation #161

Merged
merged 7 commits into from
Apr 12, 2023
Merged

Conversation

seanmor5
Copy link
Contributor

@seanmor5 seanmor5 commented Feb 17, 2023

Adds multinomial sampling strategy and top-k/top-p options for adjusting the distribution.


* `:sample` - whether or not to use random sampling. Defaults to `false`

* `:prng_key` - random key to use when sampling. Defaults to `nil`
Copy link
Member

Choose a reason for hiding this comment

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

Since this function is pretty higher-level, what about :seed instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, though one thing I was thinking was if we should pass this in the serving as well and return the updated key. They do accept key in generate in HF, but they do not return an updated key, so maybe just allowing a key to the serving is enough and it is assumed you will split it outside the serving

Copy link
Member

Choose a reason for hiding this comment

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

Servings are so high-level that it seems to me the seed is for reproducibility if anything else (or to explore different result for the same prompt), and so a number is more transparent than a tensor key. Or do you think there's a scenario where you would actually use a split key?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, what I mean is currently you'd need to create a new serving with a new seed to get different inputs. Maybe this is desirable though, but I'm not sure as if you want something non-deterministic you may want the option to pass a key to the serving

seanmor5 and others added 2 commits February 17, 2023 06:02
Co-authored-by: José Valim <jose.valim@dashbit.co>
Co-authored-by: José Valim <jose.valim@dashbit.co>
@jonatanklosko jonatanklosko changed the title Add more generation strategies Add multinomial sampling to sequence generation Apr 12, 2023
@jonatanklosko
Copy link
Member

jonatanklosko commented Apr 12, 2023

@seanmor5 I finished sampling, we can do beam search separately, especially that we have contrastive search already :)

@josevalim
Copy link
Contributor

we can do beam search separately

If you think about it, every search we do is a beam search.

@jonatanklosko jonatanklosko merged commit 1f968a5 into main Apr 12, 2023
@jonatanklosko jonatanklosko deleted the sm-generation branch April 12, 2023 16:57
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.

None yet

4 participants