From ac7dc205996fc8995af54b364e8c6f45f3c5e3fa Mon Sep 17 00:00:00 2001 From: Lysandre Date: Wed, 2 Jul 2025 13:36:58 -0300 Subject: [PATCH 1/2] Add a 'chat' extra --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index a38814188411..97eb0dcc88a5 100644 --- a/setup.py +++ b/setup.py @@ -314,6 +314,7 @@ def run(self): extras["integrations"] = extras["hub-kernels"] + extras["optuna"] + extras["ray"] + extras["sigopt"] extras["serving"] = deps_list("pydantic", "uvicorn", "fastapi", "starlette") +extras["chat"] = deps_list("aiohttp", "rich") extras["audio"] = deps_list( "librosa", "pyctcdecode", From b83adbbf215483bc91dcb67a8bfc7b49012ce258 Mon Sep 17 00:00:00 2001 From: Lysandre Date: Wed, 2 Jul 2025 13:40:24 -0300 Subject: [PATCH 2/2] Add to docs --- README.md | 3 ++- docs/source/en/conversations.md | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 13afb112caa8..79c6aa1cc4a8 100644 --- a/README.md +++ b/README.md @@ -133,8 +133,9 @@ pipeline("the secret to baking a really good cake is ") To chat with a model, the usage pattern is the same. The only difference is you need to construct a chat history (the input to `Pipeline`) between you and the system. > [!TIP] -> You can also chat with a model directly from the command line. +> You can also chat with a model directly from the command line. Please make sure you have the `chat` extra installed: > ```shell +> pip install .[chat] # or pip install transformers[chat] > transformers chat Qwen/Qwen2.5-0.5B-Instruct > ``` diff --git a/docs/source/en/conversations.md b/docs/source/en/conversations.md index f661eb91e58f..005a4386a055 100644 --- a/docs/source/en/conversations.md +++ b/docs/source/en/conversations.md @@ -31,6 +31,13 @@ This guide shows you how to quickly start chatting with Transformers from the co ### Interactive chat session After you've [installed Transformers](./installation.md), chat with a model directly from the command line as shown below. It launches an interactive session with a model, with a few base commands listed at the start of the session. +For this to work, you need to have installed the chat extra: + +```bash +pip install transformers[chat] +``` + +You can then launch an interactive session as follows: ```bash transformers chat Qwen/Qwen2.5-0.5B-Instruct