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
571c7a11
Unverified
Commit
571c7a11
authored
Sep 25, 2020
by
Patrick von Platen
Committed by
GitHub
Sep 25, 2020
Browse files
[Rag] Fix wrong usage of `num_beams` and `bos_token_id` in Rag Sequence generation (#7386)
* fix_rag_sequence * add second bug fix
parent
415071b4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
src/transformers/modeling_rag.py
src/transformers/modeling_rag.py
+3
-2
No files found.
src/transformers/modeling_rag.py
View file @
571c7a11
...
...
@@ -882,7 +882,7 @@ class RagSequenceForGeneration(RagPreTrainedModel):
hypos
=
[]
kwargs
[
"num_beams"
]
=
num_beams
kwargs
[
"num_return_sequences"
]
=
num_
return_sequence
s
kwargs
[
"num_return_sequences"
]
=
num_
beam
s
kwargs
[
"attention_mask"
]
=
None
for
index
in
range
(
len
(
input_ids
)):
...
...
@@ -916,7 +916,8 @@ class RagSequenceForGeneration(RagPreTrainedModel):
)
# bos_token_id is None for T5
use_bos
=
self
.
config
.
bos_token_id
is
not
None
and
target
[:,
0
].
eq
(
self
.
config
.
bos_token_id
).
all
()
bos_token_id
=
self
.
config
.
bos_token_id
or
self
.
config
.
generator
.
bos_token_id
use_bos
=
bos_token_id
is
not
None
and
target
[:,
0
].
eq
(
bos_token_id
).
all
()
def
_mask_pads
(
ll
,
smooth_obj
):
pad_mask
=
target
.
eq
(
self
.
config
.
generator
.
pad_token_id
)
...
...
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