-
Notifications
You must be signed in to change notification settings - Fork 511
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
Allow configurable sampling steps #318
Allow configurable sampling steps #318
Conversation
The dimensions of the mock decoder output and the test input token ids did not match and were causing PyTorch to issue a warning/error in CI.
|
||
""" | ||
probs = torch.nn.functional.softmax(logits, dim=-1) | ||
# next_token_ids = torch.multinomial(probs, num_samples=samples, generator=rng) |
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.
torch.multinomial
accepts matrices for probs
: https://pytorch.org/docs/stable/generated/torch.multinomial.html
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.
I have a few follow-up updates to add shortly; I'll put that in place alongside those.
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.
While torch.multinomial
does work for matrices, we still need to check its results against the higher dimensional tensor inputs in the tests (and update the tests that rely on RNG seeds), so the change should come in a follow-up.
👍 :) |
This PR allows one to specify sampler functions that decide exactly how generated token sequences are sampled/produced from the logit values. In doing so, this PR also adds a greedy "sampler" function (i.e. one that chooses the max logit values).