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
53357e81
Unverified
Commit
53357e81
authored
Dec 12, 2022
by
Nicolas Patry
Committed by
GitHub
Dec 12, 2022
Browse files
Adding ValueError when imcompatible parameters are used. (#20729)
parent
5ba2dbd9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
0 deletions
+5
-0
src/transformers/pipelines/text_generation.py
src/transformers/pipelines/text_generation.py
+2
-0
tests/pipelines/test_pipelines_text_generation.py
tests/pipelines/test_pipelines_text_generation.py
+3
-0
No files found.
src/transformers/pipelines/text_generation.py
View file @
53357e81
...
@@ -130,6 +130,8 @@ class TextGenerationPipeline(Pipeline):
...
@@ -130,6 +130,8 @@ class TextGenerationPipeline(Pipeline):
postprocess_params
=
{}
postprocess_params
=
{}
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
:
raise
ValueError
(
"`return_text` is mutually exclusive with `return_full_text`"
)
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
:
return_type
=
ReturnType
.
TENSORS
return_type
=
ReturnType
.
TENSORS
...
...
tests/pipelines/test_pipelines_text_generation.py
View file @
53357e81
...
@@ -201,6 +201,9 @@ class TextGenerationPipelineTests(unittest.TestCase, metaclass=PipelineTestCaseM
...
@@ -201,6 +201,9 @@ class TextGenerationPipelineTests(unittest.TestCase, metaclass=PipelineTestCaseM
],
],
)
)
with
self
.
assertRaises
(
ValueError
):
outputs
=
text_generator
(
"test"
,
return_full_text
=
True
,
return_text
=
True
)
# Empty prompt is slighly special
# Empty prompt is slighly special
# it requires BOS token to exist.
# it requires BOS token to exist.
# Special case for Pegasus which will always append EOS so will
# Special case for Pegasus which will always append EOS so will
...
...
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