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
9f81f4f6
Unverified
Commit
9f81f4f6
authored
Jun 12, 2023
by
Joao Gante
Committed by
GitHub
Jun 12, 2023
Browse files
Generate: force caching on the main model, in assisted generation (#24177)
parent
535f92ae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
src/transformers/generation/utils.py
src/transformers/generation/utils.py
+4
-0
No files found.
src/transformers/generation/utils.py
View file @
9f81f4f6
...
...
@@ -4322,6 +4322,7 @@ class GenerationMixin:
encoder_outputs
=
model_kwargs
[
"encoder_outputs"
],
output_attentions
=
output_attentions
,
output_hidden_states
=
output_hidden_states
,
use_cache
=
True
,
)
else
:
outputs
=
self
(
...
...
@@ -4330,6 +4331,7 @@ class GenerationMixin:
past_key_values
=
model_kwargs
[
"past_key_values"
],
output_attentions
=
output_attentions
,
output_hidden_states
=
output_hidden_states
,
use_cache
=
True
,
)
else
:
if
self
.
config
.
is_encoder_decoder
:
...
...
@@ -4338,12 +4340,14 @@ class GenerationMixin:
encoder_outputs
=
model_kwargs
[
"encoder_outputs"
],
output_attentions
=
output_attentions
,
output_hidden_states
=
output_hidden_states
,
use_cache
=
True
,
)
else
:
outputs
=
self
(
candidate_input_ids
,
output_attentions
=
output_attentions
,
output_hidden_states
=
output_hidden_states
,
use_cache
=
True
,
)
# 2.2. Process the new logits
...
...
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