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
7e7f62bf
Unverified
Commit
7e7f62bf
authored
Oct 05, 2022
by
Sylvain Gugger
Committed by
GitHub
Oct 05, 2022
Browse files
Fix pipeline tests for Roberta-like tokenizers (#19365)
* Fix pipeline tests for Roberta-like tokenizers * Fix fix
parent
bad353ce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
tests/pipelines/test_pipelines_common.py
tests/pipelines/test_pipelines_common.py
+11
-3
No files found.
tests/pipelines/test_pipelines_common.py
View file @
7e7f62bf
...
...
@@ -37,8 +37,6 @@ from transformers import (
AutoModelForSequenceClassification
,
AutoTokenizer
,
DistilBertForSequenceClassification
,
IBertConfig
,
RobertaConfig
,
TextClassificationPipeline
,
TFAutoModelForSequenceClassification
,
pipeline
,
...
...
@@ -71,6 +69,16 @@ from test_module.custom_pipeline import PairClassificationPipeline # noqa E402
logger
=
logging
.
getLogger
(
__name__
)
ROBERTA_EMBEDDING_ADJUSMENT_CONFIGS
=
[
"CamembertConfig"
,
"IBertConfig"
,
"LongformerConfig"
,
"MarkupLMConfig"
,
"RobertaConfig"
,
"XLMRobertaConfig"
,
]
def
get_checkpoint_from_architecture
(
architecture
):
try
:
module
=
importlib
.
import_module
(
architecture
.
__module__
)
...
...
@@ -194,7 +202,7 @@ class PipelineTestCaseMeta(type):
try
:
tokenizer
=
get_tiny_tokenizer_from_checkpoint
(
checkpoint
)
# XLNet actually defines it as -1.
if
isinstance
(
model
.
config
,
(
RobertaConfig
,
IBertConfig
))
:
if
model
.
config
.
__class__
.
__name__
in
ROBERTA_EMBEDDING_ADJUSMENT_CONFIGS
:
tokenizer
.
model_max_length
=
model
.
config
.
max_position_embeddings
-
2
elif
(
hasattr
(
model
.
config
,
"max_position_embeddings"
)
...
...
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