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
506e5bb0
"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "a2c8e516c2fb55cf37844d434ae04b5abcfbc81b"
Commit
506e5bb0
authored
Jan 11, 2019
by
tholor
Browse files
add do_lower_case arg and adjust model saving for lm finetuning.
parent
e485829a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
examples/run_lm_finetuning.py
examples/run_lm_finetuning.py
+7
-4
No files found.
examples/run_lm_finetuning.py
View file @
506e5bb0
...
@@ -461,6 +461,9 @@ def main():
...
@@ -461,6 +461,9 @@ def main():
parser
.
add_argument
(
"--on_memory"
,
parser
.
add_argument
(
"--on_memory"
,
action
=
'store_true'
,
action
=
'store_true'
,
help
=
"Whether to load train samples into memory or use disk"
)
help
=
"Whether to load train samples into memory or use disk"
)
parser
.
add_argument
(
"--do_lower_case"
,
action
=
'store_true'
,
help
=
"Whether to lower case the input text. True for uncased models, False for cased models."
)
parser
.
add_argument
(
"--local_rank"
,
parser
.
add_argument
(
"--local_rank"
,
type
=
int
,
type
=
int
,
default
=-
1
,
default
=-
1
,
...
@@ -612,12 +615,12 @@ def main():
...
@@ -612,12 +615,12 @@ def main():
optimizer
.
zero_grad
()
optimizer
.
zero_grad
()
global_step
+=
1
global_step
+=
1
# Save a trained model
logger
.
info
(
"** ** * Saving fine - tuned model ** ** * "
)
logger
.
info
(
"** ** * Saving fine - tuned model ** ** * "
)
model_to_save
=
model
.
module
if
hasattr
(
model
,
'module'
)
else
model
# Only save the model it-self
output_model_file
=
os
.
path
.
join
(
args
.
output_dir
,
"pytorch_model.bin"
)
output_model_file
=
os
.
path
.
join
(
args
.
output_dir
,
"pytorch_model.bin"
)
if
n_gpu
>
1
:
if
args
.
do_train
:
torch
.
save
(
model
.
module
.
bert
.
state_dict
(),
output_model_file
)
torch
.
save
(
model_to_save
.
state_dict
(),
output_model_file
)
else
:
torch
.
save
(
model
.
bert
.
state_dict
(),
output_model_file
)
def
_truncate_seq_pair
(
tokens_a
,
tokens_b
,
max_length
):
def
_truncate_seq_pair
(
tokens_a
,
tokens_b
,
max_length
):
...
...
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