Unverified Commit d7389cd2 authored by yuanwu2017's avatar yuanwu2017 Committed by GitHub
Browse files

fix: TextIteratorStreamer cannot work with pipeline (#23641)



* fix: TextIteratorStreamer cannot work with pipeline

Deepcopying the TextIteratorStreamer object causes the exception.
Signed-off-by: default avataryuanwu <yuan.wu@intel.com>

* Update src/transformers/pipelines/text_generation.py

Got it. I will update the patch.
Co-authored-by: default avatarJoao Gante <joaofranciscocardosogante@gmail.com>

* Update src/transformers/pipelines/text_generation.py
Co-authored-by: default avatarJoao Gante <joaofranciscocardosogante@gmail.com>

* Update text_generation.py

---------
Signed-off-by: default avataryuanwu <yuan.wu@intel.com>
Co-authored-by: default avatarJoao Gante <joaofranciscocardosogante@gmail.com>
parent 70c79940
import copy
import enum import enum
import warnings import warnings
...@@ -242,7 +241,6 @@ class TextGenerationPipeline(Pipeline): ...@@ -242,7 +241,6 @@ class TextGenerationPipeline(Pipeline):
# If there is a prefix, we may need to adjust the generation length. Do so without permanently modifying # If there is a prefix, we may need to adjust the generation length. Do so without permanently modifying
# generate_kwargs, as some of the parameterization may come from the initialization of the pipeline. # generate_kwargs, as some of the parameterization may come from the initialization of the pipeline.
generate_kwargs = copy.deepcopy(generate_kwargs)
prefix_length = generate_kwargs.pop("prefix_length", 0) prefix_length = generate_kwargs.pop("prefix_length", 0)
if prefix_length > 0: if prefix_length > 0:
has_max_new_tokens = "max_new_tokens" in generate_kwargs or ( has_max_new_tokens = "max_new_tokens" in generate_kwargs or (
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment