Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
735968b6
Unverified
Commit
735968b6
authored
Jan 15, 2024
by
Boris Dayma
Committed by
GitHub
Jan 15, 2024
Browse files
fix: sampling in flax keeps EOS (#28378)
parent
7e0ddf89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/generation/flax_utils.py
src/transformers/generation/flax_utils.py
+1
-1
No files found.
src/transformers/generation/flax_utils.py
View file @
735968b6
...
...
@@ -716,8 +716,8 @@ class FlaxGenerationMixin:
next_token
=
jax
.
random
.
categorical
(
prng_key
,
logits
,
axis
=-
1
)
next_token
=
next_token
*
~
state
.
is_sent_finished
+
pad_token_id
*
state
.
is_sent_finished
next_is_sent_finished
=
state
.
is_sent_finished
|
(
next_token
==
eos_token_id
)
next_token
=
next_token
*
~
next_is_sent_finished
+
pad_token_id
*
next_is_sent_finished
next_token
=
next_token
[:,
None
]
next_sequences
=
lax
.
dynamic_update_slice
(
state
.
sequences
,
next_token
,
(
0
,
state
.
cur_len
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment