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
c8bdf7f4
Unverified
Commit
c8bdf7f4
authored
Jul 27, 2020
by
Suraj Patil
Committed by
GitHub
Jul 27, 2020
Browse files
Add new AutoModel classes in pipeline (#6062)
* use new AutoModel classed * make style and quality
parent
5779e543
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
src/transformers/pipelines.py
src/transformers/pipelines.py
+12
-9
No files found.
src/transformers/pipelines.py
View file @
c8bdf7f4
...
...
@@ -60,13 +60,14 @@ if is_torch_available():
AutoModelForSequenceClassification
,
AutoModelForQuestionAnswering
,
AutoModelForTokenClassification
,
AutoModelWithLMHead
,
AutoModelForSeq2SeqLM
,
MODEL_WITH_LM_HEAD_MAPPING
,
AutoModelForCausalLM
,
AutoModelForMaskedLM
,
MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
,
MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING
,
MODEL_FOR_QUESTION_ANSWERING_MAPPING
,
MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
,
MODEL_FOR_MASKED_LM_MAPPING
,
)
if
TYPE_CHECKING
:
...
...
@@ -1029,7 +1030,7 @@ class FillMaskPipeline(Pipeline):
task
=
task
,
)
self
.
check_model_type
(
TF_MODEL_WITH_LM_HEAD_MAPPING
if
self
.
framework
==
"tf"
else
MODEL_
WITH_LM_HEAD
_MAPPING
)
self
.
check_model_type
(
TF_MODEL_WITH_LM_HEAD_MAPPING
if
self
.
framework
==
"tf"
else
MODEL_
FOR_MASKED_LM
_MAPPING
)
self
.
topk
=
topk
...
...
@@ -1817,7 +1818,9 @@ class TranslationPipeline(Pipeline):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
check_model_type
(
TF_MODEL_WITH_LM_HEAD_MAPPING
if
self
.
framework
==
"tf"
else
MODEL_WITH_LM_HEAD_MAPPING
)
self
.
check_model_type
(
TF_MODEL_WITH_LM_HEAD_MAPPING
if
self
.
framework
==
"tf"
else
MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
)
def
__call__
(
self
,
*
args
,
return_tensors
=
False
,
return_text
=
True
,
clean_up_tokenization_spaces
=
False
,
**
generate_kwargs
...
...
@@ -1933,7 +1936,7 @@ SUPPORTED_TASKS = {
"fill-mask"
:
{
"impl"
:
FillMaskPipeline
,
"tf"
:
TFAutoModelWithLMHead
if
is_tf_available
()
else
None
,
"pt"
:
AutoModel
WithLMHead
if
is_torch_available
()
else
None
,
"pt"
:
AutoModel
ForMaskedLM
if
is_torch_available
()
else
None
,
"default"
:
{
"model"
:
{
"pt"
:
"distilroberta-base"
,
"tf"
:
"distilroberta-base"
}},
},
"summarization"
:
{
...
...
@@ -1945,25 +1948,25 @@ SUPPORTED_TASKS = {
"translation_en_to_fr"
:
{
"impl"
:
TranslationPipeline
,
"tf"
:
TFAutoModelWithLMHead
if
is_tf_available
()
else
None
,
"pt"
:
AutoModel
WithLMHead
if
is_torch_available
()
else
None
,
"pt"
:
AutoModel
ForSeq2SeqLM
if
is_torch_available
()
else
None
,
"default"
:
{
"model"
:
{
"pt"
:
"t5-base"
,
"tf"
:
"t5-base"
}},
},
"translation_en_to_de"
:
{
"impl"
:
TranslationPipeline
,
"tf"
:
TFAutoModelWithLMHead
if
is_tf_available
()
else
None
,
"pt"
:
AutoModel
WithLMHead
if
is_torch_available
()
else
None
,
"pt"
:
AutoModel
ForSeq2SeqLM
if
is_torch_available
()
else
None
,
"default"
:
{
"model"
:
{
"pt"
:
"t5-base"
,
"tf"
:
"t5-base"
}},
},
"translation_en_to_ro"
:
{
"impl"
:
TranslationPipeline
,
"tf"
:
TFAutoModelWithLMHead
if
is_tf_available
()
else
None
,
"pt"
:
AutoModel
WithLMHead
if
is_torch_available
()
else
None
,
"pt"
:
AutoModel
ForSeq2SeqLM
if
is_torch_available
()
else
None
,
"default"
:
{
"model"
:
{
"pt"
:
"t5-base"
,
"tf"
:
"t5-base"
}},
},
"text-generation"
:
{
"impl"
:
TextGenerationPipeline
,
"tf"
:
TFAutoModelWithLMHead
if
is_tf_available
()
else
None
,
"pt"
:
AutoModel
WithLMHead
if
is_torch_available
()
else
None
,
"pt"
:
AutoModel
ForCausalLM
if
is_torch_available
()
else
None
,
"default"
:
{
"model"
:
{
"pt"
:
"gpt2"
,
"tf"
:
"gpt2"
}},
},
"zero-shot-classification"
:
{
...
...
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