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
656e1386
"examples/vscode:/vscode.git/clone" did not exist on "494c2a8c4daf38fcf0cf5cdd9bead0dc4c4e8cea"
Commit
656e1386
authored
Mar 18, 2020
by
Julien Chaumond
Browse files
Fix #3305: run_ner only possible on ModelForTokenClassification models
parent
0c44b119
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
examples/ner/run_ner.py
examples/ner/run_ner.py
+5
-5
No files found.
examples/ner/run_ner.py
View file @
656e1386
...
...
@@ -31,7 +31,6 @@ from torch.utils.data.distributed import DistributedSampler
from
tqdm
import
tqdm
,
trange
from
transformers
import
(
ALL_PRETRAINED_MODEL_ARCHIVE_MAP
,
WEIGHTS_NAME
,
AdamW
,
AutoConfig
,
...
...
@@ -39,7 +38,7 @@ from transformers import (
AutoTokenizer
,
get_linear_schedule_with_warmup
,
)
from
transformers.modeling_auto
import
MODEL_MAPPING
from
transformers.modeling_auto
import
MODEL_
FOR_TOKEN_CLASSIFICATION_
MAPPING
from
utils_ner
import
convert_examples_to_features
,
get_labels
,
read_examples_from_file
...
...
@@ -51,8 +50,9 @@ except ImportError:
logger
=
logging
.
getLogger
(
__name__
)
ALL_MODELS
=
tuple
(
ALL_PRETRAINED_MODEL_ARCHIVE_MAP
)
MODEL_CLASSES
=
tuple
(
m
.
model_type
for
m
in
MODEL_MAPPING
)
MODEL_CONFIG_CLASSES
=
list
(
MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING
.
keys
())
MODEL_TYPES
=
tuple
(
conf
.
model_type
for
conf
in
MODEL_CONFIG_CLASSES
)
ALL_MODELS
=
sum
((
tuple
(
conf
.
pretrained_config_archive_map
.
keys
())
for
conf
in
MODEL_CONFIG_CLASSES
),
())
TOKENIZER_ARGS
=
[
"do_lower_case"
,
"strip_accents"
,
"keep_accents"
,
"use_fast"
]
...
...
@@ -384,7 +384,7 @@ def main():
default
=
None
,
type
=
str
,
required
=
True
,
help
=
"Model type selected in the list: "
+
", "
.
join
(
MODEL_
CLASS
ES
),
help
=
"Model type selected in the list: "
+
", "
.
join
(
MODEL_
TYP
ES
),
)
parser
.
add_argument
(
"--model_name_or_path"
,
...
...
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