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
8d533e6a
Unverified
Commit
8d533e6a
authored
Sep 21, 2021
by
Kamal Raj
Committed by
GitHub
Sep 21, 2021
Browse files
Typo "UNKWOWN" -> "UNKNOWN" (#13675)
parent
78807d86
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
14 additions
and
14 deletions
+14
-14
src/transformers/testing_utils.py
src/transformers/testing_utils.py
+1
-1
tests/test_configuration_auto.py
tests/test_configuration_auto.py
+2
-2
tests/test_file_utils.py
tests/test_file_utils.py
+2
-2
tests/test_modeling_auto.py
tests/test_modeling_auto.py
+2
-2
tests/test_modeling_tf_auto.py
tests/test_modeling_tf_auto.py
+2
-2
tests/test_modeling_tf_pytorch.py
tests/test_modeling_tf_pytorch.py
+3
-3
tests/test_tokenization_auto.py
tests/test_tokenization_auto.py
+2
-2
No files found.
src/transformers/testing_utils.py
View file @
8d533e6a
...
@@ -55,7 +55,7 @@ from .integrations import is_optuna_available, is_ray_available
...
@@ -55,7 +55,7 @@ from .integrations import is_optuna_available, is_ray_available
SMALL_MODEL_IDENTIFIER
=
"julien-c/bert-xsmall-dummy"
SMALL_MODEL_IDENTIFIER
=
"julien-c/bert-xsmall-dummy"
DUMMY_UNK
W
OWN_IDENTIFIER
=
"julien-c/dummy-unknown"
DUMMY_UNK
N
OWN_IDENTIFIER
=
"julien-c/dummy-unknown"
DUMMY_DIFF_TOKENIZER_IDENTIFIER
=
"julien-c/dummy-diff-tokenizer"
DUMMY_DIFF_TOKENIZER_IDENTIFIER
=
"julien-c/dummy-diff-tokenizer"
# Used to test Auto{Config, Model, Tokenizer} model_type detection.
# Used to test Auto{Config, Model, Tokenizer} model_type detection.
...
...
tests/test_configuration_auto.py
View file @
8d533e6a
...
@@ -19,7 +19,7 @@ import unittest
...
@@ -19,7 +19,7 @@ import unittest
from
transformers.models.auto.configuration_auto
import
CONFIG_MAPPING
,
AutoConfig
from
transformers.models.auto.configuration_auto
import
CONFIG_MAPPING
,
AutoConfig
from
transformers.models.bert.configuration_bert
import
BertConfig
from
transformers.models.bert.configuration_bert
import
BertConfig
from
transformers.models.roberta.configuration_roberta
import
RobertaConfig
from
transformers.models.roberta.configuration_roberta
import
RobertaConfig
from
transformers.testing_utils
import
DUMMY_UNK
W
OWN_IDENTIFIER
from
transformers.testing_utils
import
DUMMY_UNK
N
OWN_IDENTIFIER
SAMPLE_ROBERTA_CONFIG
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"fixtures/dummy-config.json"
)
SAMPLE_ROBERTA_CONFIG
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"fixtures/dummy-config.json"
)
...
@@ -35,7 +35,7 @@ class AutoConfigTest(unittest.TestCase):
...
@@ -35,7 +35,7 @@ class AutoConfigTest(unittest.TestCase):
self
.
assertIsInstance
(
config
,
RobertaConfig
)
self
.
assertIsInstance
(
config
,
RobertaConfig
)
def
test_config_model_type_from_model_identifier
(
self
):
def
test_config_model_type_from_model_identifier
(
self
):
config
=
AutoConfig
.
from_pretrained
(
DUMMY_UNK
W
OWN_IDENTIFIER
)
config
=
AutoConfig
.
from_pretrained
(
DUMMY_UNK
N
OWN_IDENTIFIER
)
self
.
assertIsInstance
(
config
,
RobertaConfig
)
self
.
assertIsInstance
(
config
,
RobertaConfig
)
def
test_config_for_model_str
(
self
):
def
test_config_for_model_str
(
self
):
...
...
tests/test_file_utils.py
View file @
8d533e6a
...
@@ -21,10 +21,10 @@ import transformers
...
@@ -21,10 +21,10 @@ import transformers
# Try to import everything from transformers to ensure every object can be loaded.
# Try to import everything from transformers to ensure every object can be loaded.
from
transformers
import
*
# noqa F406
from
transformers
import
*
# noqa F406
from
transformers.file_utils
import
CONFIG_NAME
,
WEIGHTS_NAME
,
filename_to_url
,
get_from_cache
,
hf_bucket_url
from
transformers.file_utils
import
CONFIG_NAME
,
WEIGHTS_NAME
,
filename_to_url
,
get_from_cache
,
hf_bucket_url
from
transformers.testing_utils
import
DUMMY_UNK
W
OWN_IDENTIFIER
from
transformers.testing_utils
import
DUMMY_UNK
N
OWN_IDENTIFIER
MODEL_ID
=
DUMMY_UNK
W
OWN_IDENTIFIER
MODEL_ID
=
DUMMY_UNK
N
OWN_IDENTIFIER
# An actual model hosted on huggingface.co
# An actual model hosted on huggingface.co
REVISION_ID_DEFAULT
=
"main"
REVISION_ID_DEFAULT
=
"main"
...
...
tests/test_modeling_auto.py
View file @
8d533e6a
...
@@ -20,7 +20,7 @@ import unittest
...
@@ -20,7 +20,7 @@ import unittest
from
transformers
import
is_torch_available
from
transformers
import
is_torch_available
from
transformers.testing_utils
import
(
from
transformers.testing_utils
import
(
DUMMY_UNK
W
OWN_IDENTIFIER
,
DUMMY_UNK
N
OWN_IDENTIFIER
,
SMALL_MODEL_IDENTIFIER
,
SMALL_MODEL_IDENTIFIER
,
require_scatter
,
require_scatter
,
require_torch
,
require_torch
,
...
@@ -261,7 +261,7 @@ class AutoModelTest(unittest.TestCase):
...
@@ -261,7 +261,7 @@ class AutoModelTest(unittest.TestCase):
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
def
test_from_identifier_from_model_type
(
self
):
def
test_from_identifier_from_model_type
(
self
):
model
=
AutoModelWithLMHead
.
from_pretrained
(
DUMMY_UNK
W
OWN_IDENTIFIER
)
model
=
AutoModelWithLMHead
.
from_pretrained
(
DUMMY_UNK
N
OWN_IDENTIFIER
)
self
.
assertIsInstance
(
model
,
RobertaForMaskedLM
)
self
.
assertIsInstance
(
model
,
RobertaForMaskedLM
)
self
.
assertEqual
(
model
.
num_parameters
(),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
...
...
tests/test_modeling_tf_auto.py
View file @
8d533e6a
...
@@ -18,7 +18,7 @@ import tempfile
...
@@ -18,7 +18,7 @@ import tempfile
import
unittest
import
unittest
from
transformers
import
is_tf_available
from
transformers
import
is_tf_available
from
transformers.testing_utils
import
DUMMY_UNK
W
OWN_IDENTIFIER
,
SMALL_MODEL_IDENTIFIER
,
require_tf
,
slow
from
transformers.testing_utils
import
DUMMY_UNK
N
OWN_IDENTIFIER
,
SMALL_MODEL_IDENTIFIER
,
require_tf
,
slow
if
is_tf_available
():
if
is_tf_available
():
...
@@ -174,7 +174,7 @@ class TFAutoModelTest(unittest.TestCase):
...
@@ -174,7 +174,7 @@ class TFAutoModelTest(unittest.TestCase):
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
def
test_from_identifier_from_model_type
(
self
):
def
test_from_identifier_from_model_type
(
self
):
model
=
TFAutoModelWithLMHead
.
from_pretrained
(
DUMMY_UNK
W
OWN_IDENTIFIER
)
model
=
TFAutoModelWithLMHead
.
from_pretrained
(
DUMMY_UNK
N
OWN_IDENTIFIER
)
self
.
assertIsInstance
(
model
,
TFRobertaForMaskedLM
)
self
.
assertIsInstance
(
model
,
TFRobertaForMaskedLM
)
self
.
assertEqual
(
model
.
num_parameters
(),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
...
...
tests/test_modeling_tf_pytorch.py
View file @
8d533e6a
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
import
unittest
import
unittest
from
transformers
import
is_tf_available
,
is_torch_available
from
transformers
import
is_tf_available
,
is_torch_available
from
transformers.testing_utils
import
DUMMY_UNK
W
OWN_IDENTIFIER
,
SMALL_MODEL_IDENTIFIER
,
is_pt_tf_cross_test
,
slow
from
transformers.testing_utils
import
DUMMY_UNK
N
OWN_IDENTIFIER
,
SMALL_MODEL_IDENTIFIER
,
is_pt_tf_cross_test
,
slow
if
is_tf_available
():
if
is_tf_available
():
...
@@ -232,12 +232,12 @@ class TFPTAutoModelTest(unittest.TestCase):
...
@@ -232,12 +232,12 @@ class TFPTAutoModelTest(unittest.TestCase):
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
def
test_from_identifier_from_model_type
(
self
):
def
test_from_identifier_from_model_type
(
self
):
model
=
TFAutoModelWithLMHead
.
from_pretrained
(
DUMMY_UNK
W
OWN_IDENTIFIER
,
from_pt
=
True
)
model
=
TFAutoModelWithLMHead
.
from_pretrained
(
DUMMY_UNK
N
OWN_IDENTIFIER
,
from_pt
=
True
)
self
.
assertIsInstance
(
model
,
TFRobertaForMaskedLM
)
self
.
assertIsInstance
(
model
,
TFRobertaForMaskedLM
)
self
.
assertEqual
(
model
.
num_parameters
(),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
model
=
AutoModelWithLMHead
.
from_pretrained
(
DUMMY_UNK
W
OWN_IDENTIFIER
,
from_tf
=
True
)
model
=
AutoModelWithLMHead
.
from_pretrained
(
DUMMY_UNK
N
OWN_IDENTIFIER
,
from_tf
=
True
)
self
.
assertIsInstance
(
model
,
RobertaForMaskedLM
)
self
.
assertIsInstance
(
model
,
RobertaForMaskedLM
)
self
.
assertEqual
(
model
.
num_parameters
(),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
self
.
assertEqual
(
model
.
num_parameters
(
only_trainable
=
True
),
14410
)
tests/test_tokenization_auto.py
View file @
8d533e6a
...
@@ -38,7 +38,7 @@ from transformers.models.auto.tokenization_auto import (
...
@@ -38,7 +38,7 @@ from transformers.models.auto.tokenization_auto import (
from
transformers.models.roberta.configuration_roberta
import
RobertaConfig
from
transformers.models.roberta.configuration_roberta
import
RobertaConfig
from
transformers.testing_utils
import
(
from
transformers.testing_utils
import
(
DUMMY_DIFF_TOKENIZER_IDENTIFIER
,
DUMMY_DIFF_TOKENIZER_IDENTIFIER
,
DUMMY_UNK
W
OWN_IDENTIFIER
,
DUMMY_UNK
N
OWN_IDENTIFIER
,
SMALL_MODEL_IDENTIFIER
,
SMALL_MODEL_IDENTIFIER
,
require_tokenizers
,
require_tokenizers
,
slow
,
slow
,
...
@@ -66,7 +66,7 @@ class AutoTokenizerTest(unittest.TestCase):
...
@@ -66,7 +66,7 @@ class AutoTokenizerTest(unittest.TestCase):
self
.
assertEqual
(
tokenizer
.
vocab_size
,
12
)
self
.
assertEqual
(
tokenizer
.
vocab_size
,
12
)
def
test_tokenizer_from_model_type
(
self
):
def
test_tokenizer_from_model_type
(
self
):
tokenizer
=
AutoTokenizer
.
from_pretrained
(
DUMMY_UNK
W
OWN_IDENTIFIER
)
tokenizer
=
AutoTokenizer
.
from_pretrained
(
DUMMY_UNK
N
OWN_IDENTIFIER
)
self
.
assertIsInstance
(
tokenizer
,
(
RobertaTokenizer
,
RobertaTokenizerFast
))
self
.
assertIsInstance
(
tokenizer
,
(
RobertaTokenizer
,
RobertaTokenizerFast
))
self
.
assertEqual
(
tokenizer
.
vocab_size
,
20
)
self
.
assertEqual
(
tokenizer
.
vocab_size
,
20
)
...
...
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