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
a9912d2f
Unverified
Commit
a9912d2f
authored
Dec 15, 2022
by
Nicolas Patry
Committed by
GitHub
Dec 15, 2022
Browse files
Even more validation. (#20762)
* Even more validation. * Fixing order.
parent
67acb07e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
0 deletions
+8
-0
src/transformers/pipelines/text_generation.py
src/transformers/pipelines/text_generation.py
+4
-0
tests/pipelines/test_pipelines_text_generation.py
tests/pipelines/test_pipelines_text_generation.py
+4
-0
No files found.
src/transformers/pipelines/text_generation.py
View file @
a9912d2f
...
@@ -132,8 +132,12 @@ class TextGenerationPipeline(Pipeline):
...
@@ -132,8 +132,12 @@ class TextGenerationPipeline(Pipeline):
if
return_full_text
is
not
None
and
return_type
is
None
:
if
return_full_text
is
not
None
and
return_type
is
None
:
if
return_text
is
not
None
:
if
return_text
is
not
None
:
raise
ValueError
(
"`return_text` is mutually exclusive with `return_full_text`"
)
raise
ValueError
(
"`return_text` is mutually exclusive with `return_full_text`"
)
if
return_tensors
is
not
None
:
raise
ValueError
(
"`return_full_text` is mutually exclusive with `return_tensors`"
)
return_type
=
ReturnType
.
FULL_TEXT
if
return_full_text
else
ReturnType
.
NEW_TEXT
return_type
=
ReturnType
.
FULL_TEXT
if
return_full_text
else
ReturnType
.
NEW_TEXT
if
return_tensors
is
not
None
and
return_type
is
None
:
if
return_tensors
is
not
None
and
return_type
is
None
:
if
return_text
is
not
None
:
raise
ValueError
(
"`return_text` is mutually exclusive with `return_tensors`"
)
return_type
=
ReturnType
.
TENSORS
return_type
=
ReturnType
.
TENSORS
if
return_type
is
not
None
:
if
return_type
is
not
None
:
postprocess_params
[
"return_type"
]
=
return_type
postprocess_params
[
"return_type"
]
=
return_type
...
...
tests/pipelines/test_pipelines_text_generation.py
View file @
a9912d2f
...
@@ -203,6 +203,10 @@ class TextGenerationPipelineTests(unittest.TestCase, metaclass=PipelineTestCaseM
...
@@ -203,6 +203,10 @@ class TextGenerationPipelineTests(unittest.TestCase, metaclass=PipelineTestCaseM
with
self
.
assertRaises
(
ValueError
):
with
self
.
assertRaises
(
ValueError
):
outputs
=
text_generator
(
"test"
,
return_full_text
=
True
,
return_text
=
True
)
outputs
=
text_generator
(
"test"
,
return_full_text
=
True
,
return_text
=
True
)
with
self
.
assertRaises
(
ValueError
):
outputs
=
text_generator
(
"test"
,
return_full_text
=
True
,
return_tensors
=
True
)
with
self
.
assertRaises
(
ValueError
):
outputs
=
text_generator
(
"test"
,
return_text
=
True
,
return_tensors
=
True
)
# Empty prompt is slighly special
# Empty prompt is slighly special
# it requires BOS token to exist.
# it requires BOS token to exist.
...
...
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