Skip to content

Commit

Permalink
Adding ValueError when imcompatible parameters are used. (huggingface…
Browse files Browse the repository at this point in the history
  • Loading branch information
Narsil authored Dec 12, 2022
1 parent 5ba2dbd commit 53357e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/transformers/pipelines/text_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def _sanitize_parameters(

postprocess_params = {}
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
if return_tensors is not None and return_type is None:
return_type = ReturnType.TENSORS
Expand Down
3 changes: 3 additions & 0 deletions tests/pipelines/test_pipelines_text_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ def run_pipeline_test(self, text_generator, _):
],
)

with self.assertRaises(ValueError):
outputs = text_generator("test", return_full_text=True, return_text=True)

# Empty prompt is slighly special
# it requires BOS token to exist.
# Special case for Pegasus which will always append EOS so will
Expand Down

0 comments on commit 53357e8

Please sign in to comment.