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
005b5157
Unverified
Commit
005b5157
authored
Feb 17, 2023
by
Joao Gante
Committed by
GitHub
Feb 17, 2023
Browse files
Generate: eta sampling numerical stability (#21676)
parent
bb6a664e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/generation/logits_process.py
src/transformers/generation/logits_process.py
+1
-1
No files found.
src/transformers/generation/logits_process.py
View file @
005b5157
...
...
@@ -419,7 +419,7 @@ class EtaLogitsWarper(LogitsWarper):
def
__call__
(
self
,
input_ids
:
torch
.
LongTensor
,
scores
:
torch
.
FloatTensor
)
->
torch
.
FloatTensor
:
# Calculate the adaptive cutoff
probabilities
=
scores
.
softmax
(
dim
=-
1
)
entropy
=
torch
.
distributions
.
Categorical
(
probs
=
probabiliti
es
).
entropy
()
entropy
=
torch
.
distributions
.
Categorical
(
logits
=
scor
es
).
entropy
()
eta
=
torch
.
min
(
self
.
epsilon
,
torch
.
sqrt
(
self
.
epsilon
)
*
torch
.
exp
(
-
entropy
))[...,
None
]
indices_to_remove
=
probabilities
<
eta
...
...
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