« FastChat » : différence entre les versions

De Lea Linux
Aller à la navigation Aller à la recherche
(Page créée avec « {{En construction}} FastChat est une platforme libre (licence Apache 2.0) pour entraîner, mettre à disposition et évaluer des robots conversationnels utilisation des modèles de langage. Installation directe avec pip: <syntaxhighlight lang="bash"> $ pip3 install "fschat[model_worker,webui]" Defaulting to user installation because normal site-packages is not writeable Collecting fschat[model_worker,webui] Downloading fschat-0.2.34-py3-none-any.whl (220 kB)... »)
 
Aucun résumé des modifications
 
(7 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
{{En construction}}
[https://github.com/lm-sys/FastChat FastChat] est un logiciel libre (licence Apache 2.0) pour entraîner, mettre à disposition et évaluer des robots conversationnels. C'est une alternative libre à [[ChatGPT]]. L'avantage du libre, c'est que l'on peut utiliser un grand nombre de modèles différents. Ainsi, FastChat supporte par exemple LLama 2, Vicuna, Alpaca, GPT4ALL, Baize, xDAN-AI, ChatGLM, Dolly, Falcon, FastChat-T5, Guanaco, MTP, OpenAssistant, OpenChat, RedPajama, StableLM, WizardLM. Et il est même possible d'ajouter son propre modèle!


FastChat est une platforme libre (licence Apache 2.0) pour entraîner, mettre à disposition et évaluer des robots conversationnels utilisation des modèles de langage.
== Pré-requis ==
 
Un ordinateur avec au moins 15G d'espace libre, car les modèles les plus petits font rapidement cette taille. Par défaut, FastChat les stockent dans le répertoire .cache de votre répertoire personnel. Idéalement, un processeur graphique (GPU) qui va être utilisé par FastChat en complément du processeur, mais ce n'est pas obligatoire.
 
== Installation ==


Installation directe avec pip:
Installation directe avec pip:
Ligne 39 : Ligne 43 :
</syntaxhighlight>
</syntaxhighlight>


Ensuite, on peut simplement lancer FastChat pour le modèle Vicuna avec la commande suivante:
== Lancer FastChat ==
 
Lançons FastChat avec le modèle libre FastChat-T5 (license Apache 2.0). La commande va d'abord télécharger le modèle et puis lancer l'interface de discussion :


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$ python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5
$ python3 -m fastchat.serve.cli --model-path lmsys/fastchat-t5-3b-v1.0


tokenizer_config.json: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 749/749 [00:00<00:00, 3.34MB/s]
tokenizer_config.json: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.40k/2.40k [00:00<00:00, 16.4MB/s]
tokenizer.model: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 500k/500k [00:00<00:00, 1.98MB/s]
spiece.model: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 792k/792k [00:00<00:00, 4.39MB/s]
special_tokens_map.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 438/438 [00:00<00:00, 1.88MB/s]
added_tokens.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 150/150 [00:00<00:00, 550kB/s]
config.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 615/615 [00:00<00:00, 2.24MB/s]
special_tokens_map.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.20k/2.20k [00:00<00:00, 12.9MB/s]
pytorch_model.bin.index.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 26.8k/26.8k [00:00<00:00, 10.2MB/s]
You are using the default legacy behaviour of the <class 'transformers.models.t5.tokenization_t5.T5Tokenizer'>. This is expected, and simply means that the `legacy` (previous) behavior will be used so nothing changes for you. If you want to use the new behaviour, set `legacy=False`. This should only be set if you understand what it means, and thouroughly read the reason why this was added as explained in https://github.com/huggingface/transformers/pull/24565
Downloading shards:   0%|                                                                                                                                                                        
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
pytorch_model-00001-of-00002.bin: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9.98G/9.98G [09:17<00:00, 5.48MB/s]
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
pytorch_model-00001-of-00002.bin: 69%|█████████████████████████████████████████████████████████████████████████████████████████████████                                          | 6.92G/9.98G [58:47<35:10, 1.45MB/s]
config.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.52k/1.52k [00:00<00:00, 6.09MB/s]
pytorch_model-00001-of-00002.bin: 18%|████████████████████████▉                                                                                                                | 1.81G/9.98G [1:05:18<4:53:51, 463kB/s]
generation_config.json: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 142/142 [00:00<00:00, 684kB/s]
pytorch_model-00002-of-00002.bin: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3.50G/3.50G [10:40<00:00, 5.46MB/s]
.gitattributes: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.48k/1.48k [00:00<00:00, 11.2MB/s]
Downloading shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [1:15:59<00:00, 2279.83s/it]
README.md: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.98k/1.98k [00:00<00:00, 16.0MB/s]
Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:15<00:00, 7.54s/it]
pytorch_model.bin.index.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50.8k/50.8k [00:00<00:00, 385kB/s]
generation_config.json: 100%|██████
pytorch_model.bin: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 6.71G/6.71G [22:57<00:00, 4.87MB/s]
USER:  
Fetching 10 files: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [22:57<00:00, 137.77s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:37<00:00, 37.81s/it]
Human:  
</syntaxhighlight>
</syntaxhighlight>


Cela peut prendre plusieurs minutes pour que le chat soit prêt, car il doit d'abord télécharger le modèle.
Cela peut prendre plusieurs minutes pour que le chat soit prêt, car il doit d'abord télécharger le modèle. Même si la commande finit en erreur, si le modèle a été téléchargé, vous n'aurez plus à le télécharger la prochaine fois si vous relancez la commande.


Si vous avez une erreur de type: "PermissionError: [Errno 13] Permission denied: '/home/jiel/.cache/huggingface/hub/models--lmsys--vicuna-7b-v1.5'"
Si vous avez une erreur de type: "PermissionError: [Errno 13] Permission denied: '/home/jiel/.cache/huggingface/hub/models--lmsys--vicuna-7b-v1.5'"
Ligne 68 : Ligne 76 :
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$ sudo chown -R $USER:$USER /home/$USER/.cache/huggingface/
$ sudo chown -R $USER:$USER /home/$USER/.cache/huggingface/
$ python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5
$ python3 -m fastchat.serve.cli --model-path lmsys/fastchat-t5-3b-v1.0
</syntaxhighlight>
</syntaxhighlight>


Ligne 76 : Ligne 84 :


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5 --device cpu --load-8bit
$ python3 -m fastchat.serve.cli --model-path lmsys/fastchat-t5-3b-v1.0 --device cpu --load-8bit


100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:44<00:00, 22.42s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:44<00:00, 22.42s/it]
USER:  
Human:  
</syntaxhighlight>
</syntaxhighlight>


Vous pouvez commencer à discuter.
Vous pouvez commencer à discuter.


<syntaxhighlight lang="text">
Human: Aimes-tu Linux?
Assistant: Yes,  I  am  familiar  with  Linux  and  its  many  applications.  How  may  I  assist  you?
Human: Partez-vous français?
Assistant: Oui,  je  parle  français.  Comment  puis-je  vous  aider?
</syntaxhighlight>
== Autres modèles ==
On peut lancer FastChat pour le modèle Vicuna (non libre, Llama 2 Community License Agreement) :


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
USER: do you like Linux?
$ python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5
ASSISTANT: As an artificial intelligence language model, I don't have personal preferences or feelings. However, I can provide information and answer questions about Linux if that's helpful.
 
USER: parles-tu français?
tokenizer_config.json: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 749/749 [00:00<00:00, 3.34MB/s]
ASSISTANT: Oui, je parle français. Que puis-je faire pour vous aujourd'hui?
tokenizer.model: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 500k/500k [00:00<00:00, 1.98MB/s]
USER:
special_tokens_map.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 438/438 [00:00<00:00, 1.88MB/s]
config.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 615/615 [00:00<00:00, 2.24MB/s]
pytorch_model.bin.index.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 26.8k/26.8k [00:00<00:00, 10.2MB/s]
Downloading shards:   0%|                                                                                                                                                                       
pytorch_model-00001-of-00002.bin: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9.98G/9.98G [09:17<00:00, 5.48MB/s]
pytorch_model-00001-of-00002.bin: 69%|█████████████████████████████████████████████████████████████████████████████████████████████████                                          | 6.92G/9.98G [58:47<35:10, 1.45MB/s]
pytorch_model-00001-of-00002.bin:  18%|████████████████████████▉                                                                                                                | 1.81G/9.98G [1:05:18<4:53:51, 463kB/s]
pytorch_model-00002-of-00002.bin: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3.50G/3.50G [10:40<00:00, 5.46MB/s]
Downloading shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [1:15:59<00:00, 2279.83s/it]
Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:15<00:00,  7.54s/it]
generation_config.json: 100%|██████
USER:  
</syntaxhighlight>
</syntaxhighlight>
{{Logiciels}}
{{Copy|2024|[[Utilisateur:Jiel|Jiel Beaumadier]]|FDL}}

Dernière version du 2 janvier 2024 à 13:22

FastChat est un logiciel libre (licence Apache 2.0) pour entraîner, mettre à disposition et évaluer des robots conversationnels. C'est une alternative libre à ChatGPT. L'avantage du libre, c'est que l'on peut utiliser un grand nombre de modèles différents. Ainsi, FastChat supporte par exemple LLama 2, Vicuna, Alpaca, GPT4ALL, Baize, xDAN-AI, ChatGLM, Dolly, Falcon, FastChat-T5, Guanaco, MTP, OpenAssistant, OpenChat, RedPajama, StableLM, WizardLM. Et il est même possible d'ajouter son propre modèle!

Pré-requis

Un ordinateur avec au moins 15G d'espace libre, car les modèles les plus petits font rapidement cette taille. Par défaut, FastChat les stockent dans le répertoire .cache de votre répertoire personnel. Idéalement, un processeur graphique (GPU) qui va être utilisé par FastChat en complément du processeur, mais ce n'est pas obligatoire.

Installation

Installation directe avec pip:

$ pip3 install "fschat[model_worker,webui]"
Defaulting to user installation because normal site-packages is not writeable
Collecting fschat[model_worker,webui]
  Downloading fschat-0.2.34-py3-none-any.whl (220 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 220.1/220.1 kB 1.8 MB/s eta 0:00:00
Requirement already satisfied: aiohttp in /home/jiel/.local/lib/python3.11/site-packages (from fschat[model_worker,webui]) (3.9.1)
Requirement already satisfied: fastapi in /home/jiel/.local/lib/python3.11/site-packages (from fschat[model_worker,webui]) (0.108.0)
Requirement already satisfied: httpx in /home/jiel/.local/lib/python3.11/site-packages (from fschat[model_worker,webui]) (0.26.0)
Collecting markdown2[all]
  Downloading markdown2-2.4.12-py2.py3-none-any.whl (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.2/41.2 kB 4.5 MB/s eta 0:00:00
     
  Running setup.py install for wavedrom ... done
  Attempting uninstall: gradio-client
    Found existing installation: gradio_client 0.8.0
    Uninstalling gradio_client-0.8.0:
      Successfully uninstalled gradio_client-0.8.0
  Attempting uninstall: gradio
    Found existing installation: gradio 4.12.0
    Uninstalling gradio-4.12.0:
      Successfully uninstalled gradio-4.12.0
Successfully installed fschat-0.2.34 gradio-3.50.2 gradio-client-0.6.1 markdown2-2.4.12 nh3-0.2.15 protobuf-4.25.1 pydantic-1.10.13 shortuuid-1.0.11 svgwrite-1.4.3 tiktoken-0.5.2 wavedrom-2.0.3.post3

Alternativement, on peut cloner le dépôt et on installe avec pip:

$ git clone https://github.com/lm-sys/FastChat.git
$ cd FastChat
$ pip3 install --upgrade pip  # enable PEP 660 support
$ pip3 install -e ".[model_worker,webui]"

Lancer FastChat

Lançons FastChat avec le modèle libre FastChat-T5 (license Apache 2.0). La commande va d'abord télécharger le modèle et puis lancer l'interface de discussion :

$ python3 -m fastchat.serve.cli --model-path lmsys/fastchat-t5-3b-v1.0

tokenizer_config.json: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.40k/2.40k [00:00<00:00, 16.4MB/s]
spiece.model: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 792k/792k [00:00<00:00, 4.39MB/s]
added_tokens.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 150/150 [00:00<00:00, 550kB/s]
special_tokens_map.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.20k/2.20k [00:00<00:00, 12.9MB/s]
You are using the default legacy behaviour of the <class 'transformers.models.t5.tokenization_t5.T5Tokenizer'>. This is expected, and simply means that the `legacy` (previous) behavior will be used so nothing changes for you. If you want to use the new behaviour, set `legacy=False`. This should only be set if you understand what it means, and thouroughly read the reason why this was added as explained in https://github.com/huggingface/transformers/pull/24565
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
config.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.52k/1.52k [00:00<00:00, 6.09MB/s]
generation_config.json: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 142/142 [00:00<00:00, 684kB/s]
.gitattributes: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.48k/1.48k [00:00<00:00, 11.2MB/s]
README.md: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.98k/1.98k [00:00<00:00, 16.0MB/s]
pytorch_model.bin.index.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50.8k/50.8k [00:00<00:00, 385kB/s]
pytorch_model.bin: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 6.71G/6.71G [22:57<00:00, 4.87MB/s]
Fetching 10 files: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [22:57<00:00, 137.77s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:37<00:00, 37.81s/it]
Human:

Cela peut prendre plusieurs minutes pour que le chat soit prêt, car il doit d'abord télécharger le modèle. Même si la commande finit en erreur, si le modèle a été téléchargé, vous n'aurez plus à le télécharger la prochaine fois si vous relancez la commande.

Si vous avez une erreur de type: "PermissionError: [Errno 13] Permission denied: '/home/jiel/.cache/huggingface/hub/models--lmsys--vicuna-7b-v1.5'"

Ajustez les droits sur le cache puis relancez la commande précédente:

$ sudo chown -R $USER:$USER /home/$USER/.cache/huggingface/
$ python3 -m fastchat.serve.cli --model-path lmsys/fastchat-t5-3b-v1.0

Si vous n'avez pas de processeur graphique (GPU) ou que vous avez une erreur du type "RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx", ou une erreur de mémoire, il existe une solution.

Alors ajoutez deux options à la fin de la commande. Cela indique à FastChat de n'utiliser que le processeur (CPU) mais pas le processeur graphique (GPU). Cependant, dans ce cas cela demande plusieurs dizaines de gigaoctets de mémoire. Si vous n'avez pas assez de mémoire, vous pouvez activer la compresssion 8 bits. Cela va réduire l'utilisation de la mémoire mais dégrader un peu la qualité du modèle. Vous verrez, le chat sera lent, mais fonctionnera très bien quand même!

$ python3 -m fastchat.serve.cli --model-path lmsys/fastchat-t5-3b-v1.0 --device cpu --load-8bit

100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:44<00:00, 22.42s/it]
Human:

Vous pouvez commencer à discuter.

Human: Aimes-tu Linux?
Assistant: Yes,  I  am  familiar  with  Linux  and  its  many  applications.  How  may  I  assist  you?
Human: Partez-vous français?
Assistant: Oui,  je  parle  français.  Comment  puis-je  vous  aider?

Autres modèles

On peut lancer FastChat pour le modèle Vicuna (non libre, Llama 2 Community License Agreement) :

$ python3 -m fastchat.serve.cli --model-path lmsys/vicuna-7b-v1.5

tokenizer_config.json: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 749/749 [00:00<00:00, 3.34MB/s]
tokenizer.model: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 500k/500k [00:00<00:00, 1.98MB/s]
special_tokens_map.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 438/438 [00:00<00:00, 1.88MB/s]
config.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 615/615 [00:00<00:00, 2.24MB/s]
pytorch_model.bin.index.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 26.8k/26.8k [00:00<00:00, 10.2MB/s]
Downloading shards:   0%|                                                                                                                                                                         
pytorch_model-00001-of-00002.bin: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9.98G/9.98G [09:17<00:00, 5.48MB/s]
pytorch_model-00001-of-00002.bin:  69%|█████████████████████████████████████████████████████████████████████████████████████████████████                                           | 6.92G/9.98G [58:47<35:10, 1.45MB/s]
pytorch_model-00001-of-00002.bin:  18%|████████████████████████▉                                                                                                                | 1.81G/9.98G [1:05:18<4:53:51, 463kB/s]
pytorch_model-00002-of-00002.bin: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3.50G/3.50G [10:40<00:00, 5.46MB/s]
Downloading shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [1:15:59<00:00, 2279.83s/it]
Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:15<00:00,  7.54s/it]
generation_config.json: 100%|██████
USER:



@ Retour à la rubrique Logiciels

Copyright

© 2024 Jiel Beaumadier

Tête de GNU Vous avez l'autorisation de copier, distribuer et/ou modifier ce document suivant les termes de la GNU Free Documentation License, Version 1.2 ou n'importe quelle version ultérieure publiée par la Free Software Foundation; sans section invariante, sans page de garde, sans entête et sans page finale.