|
| 1 | +{ |
| 2 | + "nbformat": 4, |
| 3 | + "nbformat_minor": 0, |
| 4 | + "metadata": { |
| 5 | + "colab": { |
| 6 | + "provenance": [], |
| 7 | + "authorship_tag": "ABX9TyMm6Jtb/FirjPQByRiT6TFm", |
| 8 | + "include_colab_link": true |
| 9 | + }, |
| 10 | + "kernelspec": { |
| 11 | + "name": "python3", |
| 12 | + "display_name": "Python 3" |
| 13 | + }, |
| 14 | + "language_info": { |
| 15 | + "name": "python" |
| 16 | + }, |
| 17 | + "accelerator": "GPU", |
| 18 | + "gpuClass": "standard" |
| 19 | + }, |
| 20 | + "cells": [ |
| 21 | + { |
| 22 | + "cell_type": "markdown", |
| 23 | + "metadata": { |
| 24 | + "id": "view-in-github", |
| 25 | + "colab_type": "text" |
| 26 | + }, |
| 27 | + "source": [ |
| 28 | + "<a href=\"https://colab.research.google.com/github/togethercomputer/OpenChatKit/blob/main/inference/example.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" |
| 29 | + ] |
| 30 | + }, |
| 31 | + { |
| 32 | + "cell_type": "markdown", |
| 33 | + "source": [ |
| 34 | + "# OpenChatKit" |
| 35 | + ], |
| 36 | + "metadata": { |
| 37 | + "id": "sLrKqm0BULlD" |
| 38 | + } |
| 39 | + }, |
| 40 | + { |
| 41 | + "cell_type": "markdown", |
| 42 | + "source": [ |
| 43 | + "### Check GPU availability" |
| 44 | + ], |
| 45 | + "metadata": { |
| 46 | + "id": "eZsgPnayURrc" |
| 47 | + } |
| 48 | + }, |
| 49 | + { |
| 50 | + "cell_type": "code", |
| 51 | + "source": [ |
| 52 | + "!nvidia-smi" |
| 53 | + ], |
| 54 | + "metadata": { |
| 55 | + "id": "qy_ENUlFgG4a" |
| 56 | + }, |
| 57 | + "execution_count": null, |
| 58 | + "outputs": [] |
| 59 | + }, |
| 60 | + { |
| 61 | + "cell_type": "markdown", |
| 62 | + "source": [ |
| 63 | + "### Install conda" |
| 64 | + ], |
| 65 | + "metadata": { |
| 66 | + "id": "0gy7ssnoT_SI" |
| 67 | + } |
| 68 | + }, |
| 69 | + { |
| 70 | + "cell_type": "code", |
| 71 | + "source": [ |
| 72 | + "!wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && chmod +x Miniconda3-latest-Linux-x86_64.sh && ./Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local" |
| 73 | + ], |
| 74 | + "metadata": { |
| 75 | + "id": "11MMVFkAKtyg" |
| 76 | + }, |
| 77 | + "execution_count": null, |
| 78 | + "outputs": [] |
| 79 | + }, |
| 80 | + { |
| 81 | + "cell_type": "markdown", |
| 82 | + "source": [ |
| 83 | + "### Setting up conda environment" |
| 84 | + ], |
| 85 | + "metadata": { |
| 86 | + "id": "CD7yF4rvT3Y8" |
| 87 | + } |
| 88 | + }, |
| 89 | + { |
| 90 | + "cell_type": "code", |
| 91 | + "source": [ |
| 92 | + "!conda install mamba -n base -c conda-forge -y" |
| 93 | + ], |
| 94 | + "metadata": { |
| 95 | + "id": "-W6PrOSILQoc" |
| 96 | + }, |
| 97 | + "execution_count": null, |
| 98 | + "outputs": [] |
| 99 | + }, |
| 100 | + { |
| 101 | + "cell_type": "markdown", |
| 102 | + "source": [ |
| 103 | + "Expect the next step to take a while" |
| 104 | + ], |
| 105 | + "metadata": { |
| 106 | + "id": "rWzDhB5rTrrT" |
| 107 | + } |
| 108 | + }, |
| 109 | + { |
| 110 | + "cell_type": "code", |
| 111 | + "source": [ |
| 112 | + "!git clone https://github.com/togethercomputer/OpenChatKit.git && cd OpenChatKit && mamba env create -f environment.yml" |
| 113 | + ], |
| 114 | + "metadata": { |
| 115 | + "id": "hC8ob6kuLSn2" |
| 116 | + }, |
| 117 | + "execution_count": null, |
| 118 | + "outputs": [] |
| 119 | + }, |
| 120 | + { |
| 121 | + "cell_type": "code", |
| 122 | + "source": [ |
| 123 | + "!source activate OpenChatKit && pip install bitsandbytes" |
| 124 | + ], |
| 125 | + "metadata": { |
| 126 | + "id": "T_K3hXCVz7I1" |
| 127 | + }, |
| 128 | + "execution_count": null, |
| 129 | + "outputs": [] |
| 130 | + }, |
| 131 | + { |
| 132 | + "cell_type": "markdown", |
| 133 | + "source": [ |
| 134 | + "### Loading and running the model" |
| 135 | + ], |
| 136 | + "metadata": { |
| 137 | + "id": "jOKRM0VVUjwk" |
| 138 | + } |
| 139 | + }, |
| 140 | + { |
| 141 | + "cell_type": "markdown", |
| 142 | + "source": [ |
| 143 | + "\n", |
| 144 | + "The model will be downloaded the first time. Remove `--load-in-8bit` to disable loading model in 8-bit.\n", |
| 145 | + "\n" |
| 146 | + ], |
| 147 | + "metadata": { |
| 148 | + "id": "psFgkD69Upu3" |
| 149 | + } |
| 150 | + }, |
| 151 | + { |
| 152 | + "cell_type": "code", |
| 153 | + "source": [ |
| 154 | + "!source activate OpenChatKit && python OpenChatKit/inference/bot.py --model togethercomputer/Pythia-Chat-Base-7B --load-in-8bit" |
| 155 | + ], |
| 156 | + "metadata": { |
| 157 | + "id": "9hvg2CLSZ2Kd" |
| 158 | + }, |
| 159 | + "execution_count": null, |
| 160 | + "outputs": [] |
| 161 | + } |
| 162 | + ] |
| 163 | +} |
0 commit comments