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
a0c62d24
Unverified
Commit
a0c62d24
authored
Nov 18, 2020
by
Sylvain Gugger
Committed by
GitHub
Nov 18, 2020
Browse files
Fix training from scratch in new scripts (#8623)
parent
1e62e999
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
8 deletions
+29
-8
examples/language-modeling/run_clm.py
examples/language-modeling/run_clm.py
+5
-2
examples/language-modeling/run_mlm.py
examples/language-modeling/run_mlm.py
+5
-2
examples/language-modeling/run_mlm_wwm.py
examples/language-modeling/run_mlm_wwm.py
+5
-2
examples/language-modeling/run_plm.py
examples/language-modeling/run_plm.py
+5
-2
templates/adding_a_new_example_script/{{cookiecutter.directory_name}}/run_{{cookiecutter.example_shortcut}}.py
...directory_name}}/run_{{cookiecutter.example_shortcut}}.py
+9
-0
No files found.
examples/language-modeling/run_clm.py
View file @
a0c62d24
...
...
@@ -313,9 +313,12 @@ def main():
# Training
if
training_args
.
do_train
:
trainer
.
train
(
model_path
=
model_args
.
model_name_or_path
if
os
.
path
.
isdir
(
model_args
.
model_name_or_path
)
else
None
model_path
=
(
model_args
.
model_name_or_path
if
(
model_args
.
model_name_or_path
is
not
None
and
os
.
path
.
isdir
(
model_args
.
model_name_or_path
))
else
None
)
trainer
.
train
(
model_path
=
model_path
)
trainer
.
save_model
()
# Saves the tokenizer too for easy upload
# Evaluation
...
...
examples/language-modeling/run_mlm.py
View file @
a0c62d24
...
...
@@ -354,9 +354,12 @@ def main():
# Training
if
training_args
.
do_train
:
trainer
.
train
(
model_path
=
model_args
.
model_name_or_path
if
os
.
path
.
isdir
(
model_args
.
model_name_or_path
)
else
None
model_path
=
(
model_args
.
model_name_or_path
if
(
model_args
.
model_name_or_path
is
not
None
and
os
.
path
.
isdir
(
model_args
.
model_name_or_path
))
else
None
)
trainer
.
train
(
model_path
=
model_path
)
trainer
.
save_model
()
# Saves the tokenizer too for easy upload
# Evaluation
...
...
examples/language-modeling/run_mlm_wwm.py
View file @
a0c62d24
...
...
@@ -302,9 +302,12 @@ def main():
# Training
if
training_args
.
do_train
:
trainer
.
train
(
model_path
=
model_args
.
model_name_or_path
if
os
.
path
.
isdir
(
model_args
.
model_name_or_path
)
else
None
model_path
=
(
model_args
.
model_name_or_path
if
(
model_args
.
model_name_or_path
is
not
None
and
os
.
path
.
isdir
(
model_args
.
model_name_or_path
))
else
None
)
trainer
.
train
(
model_path
=
model_path
)
trainer
.
save_model
()
# Saves the tokenizer too for easy upload
# Evaluation
...
...
examples/language-modeling/run_plm.py
View file @
a0c62d24
...
...
@@ -344,9 +344,12 @@ def main():
# Training
if
training_args
.
do_train
:
trainer
.
train
(
model_path
=
model_args
.
model_name_or_path
if
os
.
path
.
isdir
(
model_args
.
model_name_or_path
)
else
None
model_path
=
(
model_args
.
model_name_or_path
if
(
model_args
.
model_name_or_path
is
not
None
and
os
.
path
.
isdir
(
model_args
.
model_name_or_path
))
else
None
)
trainer
.
train
(
model_path
=
model_path
)
trainer
.
save_model
()
# Saves the tokenizer too for easy upload
# Evaluation
...
...
templates/adding_a_new_example_script/{{cookiecutter.directory_name}}/run_{{cookiecutter.example_shortcut}}.py
View file @
a0c62d24
...
...
@@ -307,9 +307,18 @@ def main():
# Training
if
training_args
.
do_train
:
{
%-
if
cookiecutter
.
can_train_from_scratch
==
"False"
%
}
trainer
.
train
(
model_path
=
model_args
.
model_name_or_path
if
os
.
path
.
isdir
(
model_args
.
model_name_or_path
)
else
None
)
{
%-
elif
cookiecutter
.
can_train_from_scratch
==
"True"
%
}
model_path
=
(
model_args
.
model_name_or_path
if
(
model_args
.
model_name_or_path
is
not
None
and
os
.
path
.
isdir
(
model_args
.
model_name_or_path
))
else
None
)
trainer
.
train
(
model_path
=
model_path
)
{
%
endif
%
}
trainer
.
save_model
()
# Saves the tokenizer too for easy upload
# Evaluation
...
...
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