Skip to content

Commit

Permalink
Skip top_p computations when set to 1.0 (#8905)
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Delalleau <507137+odelalleau@users.noreply.github.com>
Co-authored-by: Pablo Garay <palenq@gmail.com>
  • Loading branch information
odelalleau and pablo-garay authored Apr 22, 2024
1 parent a452a4f commit e0b3fe5
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def top_k_logits(logits, top_k=0, top_p=0.0, filter_value=-float('Inf'), started
else:
logits[indices_to_remove] = filter_value

if top_p > 0.0:
if 0.0 < top_p < 1.0:
# Cconvert to 1D
sorted_logits, sorted_indices = torch.sort(logits, descending=True, dim=-1)
cumulative_probs = torch.cumsum(F.softmax(sorted_logits, dim=-1), dim=-1)
Expand Down

0 comments on commit e0b3fe5

Please sign in to comment.