Unverified Commit db69bd88 authored by Matt's avatar Matt Committed by GitHub
Browse files

Update the ConversationalPipeline docstring for chat templates (#27250)

* Update the ConversationalPipeline docstring now that we're using chat templates

* Direct access to conversation.messages

* Explain the string init
parent 011b15c1
...@@ -208,17 +208,19 @@ class ConversationalPipeline(Pipeline): ...@@ -208,17 +208,19 @@ class ConversationalPipeline(Pipeline):
```python ```python
>>> from transformers import pipeline, Conversation >>> from transformers import pipeline, Conversation
# Any model with a chat template can be used in a ConversationalPipeline.
>>> chatbot = pipeline(model="microsoft/DialoGPT-medium") >>> chatbot = pipeline(model="facebook/blenderbot-400M-distill")
>>> conversation = Conversation("Going to the movies tonight - any suggestions?") >>> # 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) >>> conversation = chatbot(conversation)
>>> conversation.generated_responses[-1] >>> conversation.messages[-1]["content"]
'The Big Lebowski' ' I don't really have a favorite movie, but I do like action movies. What about you?'
>>> conversation.add_user_input("Is it an action movie?") >>> conversation.add_message({"role": "user", "content": "That's interesting, why do you like action movies?"})
>>> conversation = chatbot(conversation) >>> conversation = chatbot(conversation)
>>> conversation.generated_responses[-1] >>> conversation.messages[-1]["content"]
"It's a comedy." ' I think it's just because they're so fast-paced and action-fantastic.'
``` ```
Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial) Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial)
...@@ -226,10 +228,8 @@ class ConversationalPipeline(Pipeline): ...@@ -226,10 +228,8 @@ class ConversationalPipeline(Pipeline):
This conversational pipeline can currently be loaded from [`pipeline`] using the following task identifier: This conversational pipeline can currently be loaded from [`pipeline`] using the following task identifier:
`"conversational"`. `"conversational"`.
The models that this pipeline can use are models that have been fine-tuned on a multi-turn conversational task, This pipeline can be used with any model that has a [chat
currently: *'microsoft/DialoGPT-small'*, *'microsoft/DialoGPT-medium'*, *'microsoft/DialoGPT-large'*. See the template](https://huggingface.co/docs/transformers/chat_templating) set.
up-to-date list of available models on
[huggingface.co/models](https://huggingface.co/models?filter=conversational).
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
......
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