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
34e07f4b
Unverified
Commit
34e07f4b
authored
Mar 22, 2024
by
Joao Gante
Committed by
GitHub
Mar 22, 2024
Browse files
Generate: remove unused attributes in `AssistedCandidateGenerator` (#29787)
remove unused attrs
parent
e85654f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
9 deletions
+0
-9
src/transformers/generation/candidate_generator.py
src/transformers/generation/candidate_generator.py
+0
-9
No files found.
src/transformers/generation/candidate_generator.py
View file @
34e07f4b
...
...
@@ -131,11 +131,9 @@ class AssistedCandidateGenerator(CandidateGenerator):
if
assistant_model
.
config
.
is_encoder_decoder
:
# both are encoder-decoder
self
.
input_ids_key
=
"decoder_input_ids"
self
.
attention_key
=
"decoder_attention_mask"
elif
"encoder_outputs"
in
assistant_kwargs
:
# special case for encoder-decoder with decoder-only assistant (like DistilWhisper)
self
.
input_ids_key
=
"input_ids"
self
.
attention_key
=
"attention_mask"
self
.
assistant_kwargs
[
"attention_mask"
]
=
self
.
assistant_kwargs
.
get
(
"decoder_attention_mask"
,
torch
.
ones
((
input_ids
.
shape
[
0
],
1
),
device
=
input_ids
.
device
,
dtype
=
torch
.
long
),
...
...
@@ -143,15 +141,8 @@ class AssistedCandidateGenerator(CandidateGenerator):
else
:
# both are decoder-only
self
.
input_ids_key
=
"input_ids"
self
.
attention_key
=
"attention_mask"
# Prepare generation-related options.
eos_token_id
=
generation_config
.
eos_token_id
if
isinstance
(
eos_token_id
,
int
):
eos_token_id
=
[
eos_token_id
]
self
.
eos_token_id_tensor
=
(
torch
.
tensor
(
eos_token_id
).
to
(
input_ids
.
device
)
if
eos_token_id
is
not
None
else
None
)
self
.
logits_processor
=
logits_processor
self
.
generation_config
=
copy
.
deepcopy
(
generation_config
)
self
.
generation_config
.
return_dict_in_generate
=
True
...
...
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