Repository navigation
fix(entropy_decoding): Keep the nucleus head and apply min_p in _sample - #349
Open
flyingdoubleG wants to merge 1 commit into
Open
flyingdoubleG wants to merge 1 commit into
flyingdoubleG wants to merge 1 commit into
Conversation
- Top-p sorted the top-k probabilities in ascending order before the cumulative-sum test, so it removed the most likely tokens once the less likely ones exceeded top_p, instead of the least likely tail. Keep the descending top-k order. - min_p masked the logits, but sampling used the probabilities computed before, so it never removed anything. Mask the probabilities.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
entropy_decoding._sample(used bydecoding="entropy_decoding"for local inference) has two filtering bugs.cumsum. The maskprobs_sum - probs_sort > top_ptherefore drops every token whose less likely predecessors already exceedtop_p, i.e. the most likely tokens.top_p=0.9andtop_k=40. The most likely token is never sampled, the three largest are removed, and the whole tail stays.logit, but sampling continues fromprobs, which were computed before the mask.min_p=0.1and p = [0.5, 0.3, 20 × 0.01], tokens below 0.05 are still sampled about 20% of the time.Changes
torch.tensor(..., device=device)constants in the mask, which used the module's global device rather than the logits' device.Tests
New
tests/test_entropy_decoding_sampling.pychecks:Both tests fail on
mainand pass with this change.