From 8a8d3d8accd0872463f150a626ffcda201be88c5 Mon Sep 17 00:00:00 2001 From: lvliang-intel Date: Sun, 14 Apr 2024 23:34:41 +0800 Subject: [PATCH 1/2] Update CPU chatbot notebook Signed-off-by: lvliang-intel --- .../setup_text_chatbot_service_on_spr.ipynb | 64 ++++++++++++------- .../neural_chat/requirements_cpu.txt | 2 + .../ui/gradio/basic/requirements.txt | 3 +- 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/intel_extension_for_transformers/neural_chat/docs/notebooks/setup_text_chatbot_service_on_spr.ipynb b/intel_extension_for_transformers/neural_chat/docs/notebooks/setup_text_chatbot_service_on_spr.ipynb index c4860874825..73cb2e5aac0 100644 --- a/intel_extension_for_transformers/neural_chat/docs/notebooks/setup_text_chatbot_service_on_spr.ipynb +++ b/intel_extension_for_transformers/neural_chat/docs/notebooks/setup_text_chatbot_service_on_spr.ipynb @@ -27,14 +27,15 @@ "metadata": {}, "outputs": [], "source": [ - "!pip install intel-extension-for-transformers\n", + "!pip install intel-extension-for-transformers==1.3.2\n", "!git clone https://github.com/intel/intel-extension-for-transformers.git\n", + "!git checkout 989671d365ce6bfd9ef2ad34c2bc1d8614dd708e\n", "%cd ./intel-extension-for-transformers/intel_extension_for_transformers/neural_chat/\n", - "!pip install -r requirements.txt\n", - "!sudo apt install numactl\n", - "!conda install astunparse ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses -y\n", - "!conda install jemalloc gperftools -c conda-forge -y\n", - "!pip install nest_asyncio" + "!pip install -r requirements_cpu.txt\n", + "!pip install accelerate==0.28.0\n", + "!pip install transformers_stream_generator==0.0.5\n", + "!pip install nest_asyncio\n", + "!git checkout main" ] }, { @@ -100,9 +101,9 @@ "For detailed information about the configuration settings, please refer to the [Hugging Face Spaces Config Reference](https://huggingface.co/docs/hub/spaces-config-reference).\n", "\n", "### Setup application\n", - "We strongly recommend utilizing the provided textbot frontend code as it represents the reference implementation already deployed on Hugging Face Space. To establish your application, simply copy the code files from this directory(intel_extension_for_transformers/neural_chat/examples/textbot/frontend) and adjust their configurations as necessary (e.g., backend service URL in the `app.py` file like below).\n", + "We strongly recommend utilizing the provided textbot frontend code as it represents the reference implementation already deployed on Hugging Face Space. To establish your application, simply copy the code files from this directory(intel_extension_for_transformers/neural_chat/ui/gradio/basic) and adjust their configurations as necessary (e.g., backend service URL in the `app.py` file like below).\n", "\n", - "![Update backend URL](https://i.imgur.com/rQxPOV7.png)\n", + "![Update backend URL](https://i.imgur.com/rhObrcv.png)\n", "\n", "Alternatively, you have the option to clone the existing space from [https://huggingface.co/spaces/Intel/NeuralChat-GNR-1](https://huggingface.co/spaces/Intel/NeuralChat-GNR-1).\n", "\n", @@ -126,7 +127,10 @@ "metadata": {}, "outputs": [], "source": [ - "!pip install -r ./examples/deployment/textbot/frontend/requirements.txt" + "%cd ./ui/gradio/basic\n", + "!pip install -r requirements.txt\n", + "!pip install gradio==3.36.0\n", + "!pip install pydantic==1.10.13" ] }, { @@ -144,38 +148,50 @@ "metadata": {}, "outputs": [], "source": [ - "!cd ./examples/deployment/textbot/frontend/\n", - "!nohup python app.py &" + "!python app.py" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "This will run the chatbot application in the background on your server. The port is defined in `server_port=` at the end of the `app.py` file.\n", + "This will run the chatbot frontend application on your server. The port is defined in `server_port=` at the end of the `app.py` file. You can change it according to your environment.\n", "\n", "Once the application is running, you can find the access URL in the trace log:\n", "\n", "```log\n", - "INFO | gradio_web_server | Models: meta-llama/Llama-2-7b-chat-hf\n", - "INFO | stdout | Running on local URL: http://0.0.0.0:7860\n", + "2024-04-14 23:18:52 | INFO | gradio_web_server | Models: ['/mnt/localdisk/models/neural-chat-7b-v3-1']\n", + "2024-04-14 23:18:54 | INFO | stdout | Running on local URL: http://0.0.0.0:80\n", + "2024-04-14 23:18:54 | INFO | stdout | \n", + "2024-04-14 23:18:54 | INFO | stdout | To create a public link, set `share=True` in `launch()`.\n", + "2024-04-14 23:19:01 | INFO | gradio_web_server | load_demo. ip: 127.0.0.1. params: {}\n", + "2024-04-14 23:19:01 | INFO | httpx | HTTP Request: POST http://localhost/api/predict \"HTTP/1.1 200 OK\"\n", "```\n", - "The URL to access the chatbot frontend is http://SERVER_IP_ADDRESS:7860. Please remember to replace SERVER_IP_ADDRESS with your server's actual IP address.\n", - "\n", - "![URL](https://i.imgur.com/La3tJ8d.png)\n", - "\n", - "Please update the backend service URL in the `app.py` file.\n", + "The URL to access the chatbot frontend is http://SERVER_IP_ADDRESS:80. Please remember to replace SERVER_IP_ADDRESS with your server's actual IP address.\n", "\n", - "![Update backend URL](https://i.imgur.com/gRtZHrJ.png)" + "![URL](https://i.imgur.com/Mcs6Ysh.png)\n" ] } ], "metadata": { - "language_info": { - "name": "python" + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" }, - "orig_nbformat": 4 + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.0" + } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/intel_extension_for_transformers/neural_chat/requirements_cpu.txt b/intel_extension_for_transformers/neural_chat/requirements_cpu.txt index f17d13be487..a78a21b90c1 100644 --- a/intel_extension_for_transformers/neural_chat/requirements_cpu.txt +++ b/intel_extension_for_transformers/neural_chat/requirements_cpu.txt @@ -1,3 +1,4 @@ +accelerate==0.28.0 cchardet einops evaluate @@ -23,5 +24,6 @@ tiktoken==0.4.0 torch==2.2.0 torchaudio==2.2.0 transformers>=4.35.2 +transformers_stream_generator==0.0.5 uvicorn yacs diff --git a/intel_extension_for_transformers/neural_chat/ui/gradio/basic/requirements.txt b/intel_extension_for_transformers/neural_chat/ui/gradio/basic/requirements.txt index 48462d7b6cd..b5f5b927ade 100644 --- a/intel_extension_for_transformers/neural_chat/ui/gradio/basic/requirements.txt +++ b/intel_extension_for_transformers/neural_chat/ui/gradio/basic/requirements.txt @@ -1,10 +1,11 @@ diffusers==0.8.1 fschat -gradio +gradio==3.36.0 huggingface_hub markdown2 nh3 openai +pydantic==1.10.13 pip requests torch==2.2.0 From a0acebc09dfe0afbe88edb3093a1c2b2e720191e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 14 Apr 2024 15:38:14 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../neural_chat/ui/gradio/basic/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intel_extension_for_transformers/neural_chat/ui/gradio/basic/requirements.txt b/intel_extension_for_transformers/neural_chat/ui/gradio/basic/requirements.txt index b5f5b927ade..c75dc9b0d82 100644 --- a/intel_extension_for_transformers/neural_chat/ui/gradio/basic/requirements.txt +++ b/intel_extension_for_transformers/neural_chat/ui/gradio/basic/requirements.txt @@ -5,8 +5,8 @@ huggingface_hub markdown2 nh3 openai -pydantic==1.10.13 pip +pydantic==1.10.13 requests torch==2.2.0 transformers