{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "1. Download **ChatGLM-Efficient-Tuning** repo." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "vscode": { "languageId": "plaintext" } }, "outputs": [], "source": [ "!git clone https://github.com/hiyouga/ChatGLM-Efficient-Tuning.git" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "2. Install requirements." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "vscode": { "languageId": "plaintext" } }, "outputs": [], "source": [ "!pip install -r /content/ChatGLM-Efficient-Tuning/requirements.txt" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "3. Download your finetune checkpoint" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "vscode": { "languageId": "plaintext" } }, "outputs": [], "source": [ "!git clone git lfs install\n", "!git clone https://huggingface.co/your-finetune-checkpoint" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "4. Download cloudfared" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "vscode": { "languageId": "plaintext" } }, "outputs": [], "source": [ "!wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -O cloudflared\n", "!chmod a+x cloudflared" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "5. Deploy the finetune model" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "vscode": { "languageId": "plaintext" } }, "outputs": [], "source": [ "import nest_asyncio\n", "nest_asyncio.apply()\n", "\n", "import subprocess\n", "print(\"start cloudflared runnel\")\n", "f = open(\"stdout\", \"w\")\n", "p = subprocess.Popen(['./cloudflared', '--url', 'http://localhost:7860'], bufsize=0, stdout=f, stderr=subprocess.STDOUT)\n", "\n", "import time\n", "\n", "time.sleep(3)\n", "\n", "!grep -F trycloudflare stdout\n", "\n", "!CUDA_VISIBLE_DEVICES=0 python /content/ChatGLM-Efficient-Tuning/src/web_demo.py \\\n", " --checkpoint_dir /content/your-finetune-checkpoint" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "1. Open the link in the third line of the figure, you can share the link to any who want to try your finetune model.\n", "![image](https://i.imgur.com/b9LWJcZ.png)" ] } ], "metadata": { "language_info": { "name": "python" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }