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
c1116011
Commit
c1116011
authored
Mar 11, 2020
by
Patrick von Platen
Browse files
small clean-up
parent
2e81b9d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
3 deletions
+2
-3
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+2
-3
No files found.
src/transformers/modeling_utils.py
View file @
c1116011
...
...
@@ -845,7 +845,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin):
encoder_inputs
=
input_ids
input_ids
=
torch
.
full
(
(
effective_batch_size
*
num_beams
,
1
),
bos_token_id
,
bos_token_id
,
# TODO: wait for results of Bart CNN summarization
dtype
=
torch
.
long
,
device
=
next
(
self
.
parameters
()).
device
,
)
...
...
@@ -1082,7 +1082,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin):
scores
=
F
.
log_softmax
(
next_token_logits
,
dim
=-
1
)
# (batch_size * num_beams, vocab_size)
if
self
.
config
.
is_encoder_decoder
and
do_sample
is
False
:
# TODO
(PVP) to be refactored later - do we need this boolean flag here? Also Only add for beam_search or also for no_beam_search? The prepare scores fn is ugly here
# TODO
: maybe give better naming
scores
=
self
.
prepare_scores_for_generation
(
scores
,
cur_len
,
max_length
)
# set eos token prob to zero if min_length is not reached
...
...
@@ -1276,7 +1276,6 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin):
decoded
=
torch
.
stack
(
best
).
type
(
torch
.
long
).
to
(
next
(
self
.
parameters
()).
device
)
if
self
.
config
.
is_encoder_decoder
:
# do not return first <EOS> token
return
decoded
[:,
1
:]
return
decoded
...
...
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