Skip to content

Commit

Permalink
Update generation_utils.py (#8502)
Browse files Browse the repository at this point in the history
* Update generation_utils.py

* Update generation_utils.py
  • Loading branch information
carryyu committed Jun 6, 2024
1 parent d06b327 commit 0e0c9b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions paddlenlp/experimental/transformers/generation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,12 @@ def _post_process_(outputs, top_p, temperature, step_idx_ori, model_kwargs):
model_kwargs["min_dec_len"],
eos_token_id,
)
logits = logits / temperature

# sample
probs = F.softmax(logits)

# compute next_tokens, use paddle.tensor.top_p_sampling
logits = logits / temperature

_, next_tokens = paddle.tensor.top_p_sampling(probs, top_p)

if self.config.tensor_parallel_degree > 1:
Expand Down

0 comments on commit 0e0c9b4

Please sign in to comment.