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
ecd15667
"vscode:/vscode.git/clone" did not exist on "7176674849680cfc38dda617677634222f0debaa"
Commit
ecd15667
authored
Oct 17, 2019
by
leo-du
Committed by
Lysandre Debut
Oct 17, 2019
Browse files
fix repetition penalty
parent
c5441946
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
examples/run_generation.py
examples/run_generation.py
+1
-1
No files found.
examples/run_generation.py
View file @
ecd15667
...
...
@@ -139,7 +139,7 @@ def sample_sequence(model, length, context, num_samples=1, temperature=1, top_k=
next_token_logits
=
outputs
[
0
][
0
,
-
1
,
:]
/
(
temperature
if
temperature
>
0
else
1.
)
# reptition penalty from CTRL (https://arxiv.org/abs/1909.05858)
for
_
in
set
(
generated
):
for
_
in
set
(
generated
.
view
(
-
1
).
tolist
()
):
next_token_logits
[
_
]
/=
repetition_penalty
filtered_logits
=
top_k_top_p_filtering
(
next_token_logits
,
top_k
=
top_k
,
top_p
=
top_p
)
...
...
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