You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
131 lines
3.0 KiB
Plaintext
131 lines
3.0 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "54d5d255-aa98-4655-8dd1-bc726430d86a",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Qwen-7B-Chat Chat Demo"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "31e04af4-eb27-4802-a7b2-6ea0525f1dc8",
|
|
"metadata": {},
|
|
"source": [
|
|
"This notebook uses Qwen-7B-Chat as an example to introduce you to how to build a web-based conversational assistant using Gradio."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "75e51155-9f8e-40dc-8432-60f4567d93a8",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Preparation"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "ff6f061c-a033-49f2-8f7d-af3f23ac9125",
|
|
"metadata": {},
|
|
"source": [
|
|
"Download Qwen-7B-Chat\n",
|
|
"\n",
|
|
"Firstly, we need to download the model. You can use the snapshot_download that comes with modelscope to download the model to a specified directory."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "c469a129-451f-4d01-8bc0-e2cf70a262c8",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"!pip install modelscope"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "69af626e-22b8-49ad-8869-8354f4c72bcc",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from modelscope.hub.snapshot_download import snapshot_download\n",
|
|
"snapshot_download(\"qwen/Qwen-7B-Chat\",cache_dir='/tmp/models') "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "01d2ff34-4053-4710-a289-e354673be1ca",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Install Dependencies"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "48b51791-4bbc-4d12-9cd6-587c24c8bea7",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"!pip install -r ../../../requirements.txt\n",
|
|
"!pip install gradio==3.37.0 mdtex2html"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "7732037a-246a-4953-af07-dae7a3ae5937",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Run the web UI code to start the Qwen chatbot\n",
|
|
"\n",
|
|
"Users can run the web_demo.py file to have real-time conversations with Qwen-7b-chat on the webpage."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "9e256f0a-d96d-4fd7-b305-fe43c6959dc8",
|
|
"metadata": {
|
|
"ExecutionIndicator": {
|
|
"show": true
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"!python ../../../web_demo.py -c /tmp/models/qwen/Qwen-7B-Chat"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"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.10.13"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|
|
|