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
d98a384c
Commit
d98a384c
authored
Dec 23, 2019
by
patrickvonplaten
Browse files
fix bug in prepare inputs for language generation for xlm for effective batch_size > 1
parent
81db12c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
src/transformers/modeling_xlm.py
src/transformers/modeling_xlm.py
+2
-1
No files found.
src/transformers/modeling_xlm.py
View file @
d98a384c
...
@@ -674,7 +674,8 @@ class XLMWithLMHeadModel(XLMPreTrainedModel):
...
@@ -674,7 +674,8 @@ class XLMWithLMHeadModel(XLMPreTrainedModel):
mask_token_id
=
self
.
config
.
mask_token_id
mask_token_id
=
self
.
config
.
mask_token_id
lang_id
=
self
.
config
.
lang_id
lang_id
=
self
.
config
.
lang_id
mask_token
=
torch
.
full
((
1
,
1
),
mask_token_id
,
dtype
=
torch
.
long
,
device
=
input_ids
.
device
)
effective_batch_size
=
input_ids
.
shape
[
0
]
mask_token
=
torch
.
full
((
effective_batch_size
,
1
),
mask_token_id
,
dtype
=
torch
.
long
,
device
=
input_ids
.
device
)
input_ids
=
torch
.
cat
([
input_ids
,
mask_token
],
dim
=
1
)
input_ids
=
torch
.
cat
([
input_ids
,
mask_token
],
dim
=
1
)
if
lang_id
is
not
None
:
if
lang_id
is
not
None
:
langs
=
torch
.
full_like
(
input_ids
,
lang_id
)
langs
=
torch
.
full_like
(
input_ids
,
lang_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