Skip to content

Conversation pipeline example doesn't work #31158

Closed
@qgallouedec

Description

System Info

  • transformers version: 4.40.2
  • Platform: Linux-5.15.0-1048-aws-x86_64-with-glibc2.31
  • Python version: 3.10.14
  • Huggingface_hub version: 0.23.0
  • Safetensors version: 0.4.3
  • Accelerate version: 0.30.1
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.3.0+cu121 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?: Yes
  • Using distributed or parallel set-up in script?: No

Who can help?

@stevhliu

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

>>> from transformers import pipeline, Conversation
# Any model with a chat template can be used in a ConversationalPipeline.
>>> chatbot = pipeline(model="facebook/blenderbot-400M-distill")
>>> # Conversation objects initialized with a string will treat it as a user message
>>> conversation = Conversation("I'm looking for a movie - what's your favourite one?")
>>> conversation = chatbot(conversation)

Traceback (most recent call last):
  File "/fsx/qgallouedec/trl/conv.py", line 6, in <module>
    conversation = chatbot(conversation)
  File "/fsx/qgallouedec/miniconda3/envs/trl/lib/python3.10/site-packages/transformers/pipelines/text2text_generation.py", line 167, in __call__
    result = super().__call__(*args, **kwargs)
  File "/fsx/qgallouedec/miniconda3/envs/trl/lib/python3.10/site-packages/transformers/pipelines/base.py", line 1242, in __call__
    return self.run_single(inputs, preprocess_params, forward_params, postprocess_params)
  File "/fsx/qgallouedec/miniconda3/envs/trl/lib/python3.10/site-packages/transformers/pipelines/base.py", line 1248, in run_single
    model_inputs = self.preprocess(inputs, **preprocess_params)
  File "/fsx/qgallouedec/miniconda3/envs/trl/lib/python3.10/site-packages/transformers/pipelines/text2text_generation.py", line 177, in preprocess
    inputs = self._parse_and_tokenize(inputs, truncation=truncation, **kwargs)
  File "/fsx/qgallouedec/miniconda3/envs/trl/lib/python3.10/site-packages/transformers/pipelines/text2text_generation.py", line 129, in _parse_and_tokenize
    raise ValueError(
ValueError:  `args[0]`: Conversation id: 44b49edc-7f94-45fc-ac5c-9166b7fb7b1e
user: I'm looking for a movie - what's your favourite one?
 have the wrong format. The should be either of type `str` or type `list`

Expected behavior

The example to work.

It's probably linked to the fact that the pipeline has the wrong type. When you do

chatbot = pipeline(model="facebook/blenderbot-400M-distill", task="conversational")

it works.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions