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
2c5d993b
Commit
2c5d993b
authored
Nov 08, 2018
by
thomwolf
Browse files
update readme - fix SQuAD model on multi-GPU
parent
4850ec58
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
README.md
README.md
+5
-0
modeling.py
modeling.py
+5
-3
No files found.
README.md
View file @
2c5d993b
...
@@ -194,3 +194,8 @@ python run_squad.py \
...
@@ -194,3 +194,8 @@ python run_squad.py \
--doc_stride
128
\
--doc_stride
128
\
--output_dir
../debug_squad/
--output_dir
../debug_squad/
```
```
Training with the previous hyper-parameters and a batch size 32 (on 4 GPUs) for 2 epochs gave us the following results:
```
bash
{
"f1"
: 88.19829549714827,
"exact_match"
: 80.75685903500474
}
```
modeling.py
View file @
2c5d993b
...
@@ -455,9 +455,11 @@ class BertForQuestionAnswering(nn.Module):
...
@@ -455,9 +455,11 @@ class BertForQuestionAnswering(nn.Module):
end_logits
=
end_logits
.
squeeze
(
-
1
)
end_logits
=
end_logits
.
squeeze
(
-
1
)
if
start_positions
is
not
None
and
end_positions
is
not
None
:
if
start_positions
is
not
None
and
end_positions
is
not
None
:
# If we are on multi-GPU, split add a dimension - if not this is a no-op
# If we are on multi-GPU, split add a dimension
start_positions
=
start_positions
.
squeeze
(
-
1
)
if
len
(
start_positions
.
size
())
>
1
:
end_positions
=
end_positions
.
squeeze
(
-
1
)
start_positions
=
start_positions
.
squeeze
(
-
1
)
if
len
(
end_positions
.
size
())
>
1
:
end_positions
=
end_positions
.
squeeze
(
-
1
)
# sometimes the start/end positions are outside our model inputs, we ignore these terms
# sometimes the start/end positions are outside our model inputs, we ignore these terms
ignored_index
=
start_logits
.
size
(
1
)
ignored_index
=
start_logits
.
size
(
1
)
start_positions
.
clamp_
(
0
,
ignored_index
)
start_positions
.
clamp_
(
0
,
ignored_index
)
...
...
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