File size: 17,249 Bytes
a94599e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "aba711ad-331a-4c27-b732-be5886f70599",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"!pip install -q -U transformers peft accelerate optimum"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "2fa956a0-882e-4df7-8af4-30a91efb1fb2",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: auto-gptq in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (0.4.2+cu117)\n",
"Requirement already satisfied: accelerate>=0.19.0 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from auto-gptq) (0.22.0)\n",
"Requirement already satisfied: torch>=1.13.0 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from auto-gptq) (2.0.1)\n",
"Requirement already satisfied: transformers>=4.31.0 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from auto-gptq) (4.32.1)\n",
"Requirement already satisfied: datasets in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from auto-gptq) (2.14.4)\n",
"Requirement already satisfied: peft in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from auto-gptq) (0.5.0)\n",
"Requirement already satisfied: numpy in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from auto-gptq) (1.25.2)\n",
"Requirement already satisfied: rouge in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from auto-gptq) (1.0.1)\n",
"Requirement already satisfied: safetensors in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from auto-gptq) (0.3.3)\n",
"Requirement already satisfied: psutil in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from accelerate>=0.19.0->auto-gptq) (5.9.5)\n",
"Requirement already satisfied: pyyaml in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from accelerate>=0.19.0->auto-gptq) (6.0)\n",
"Requirement already satisfied: packaging>=20.0 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from accelerate>=0.19.0->auto-gptq) (23.1)\n",
"Requirement already satisfied: filelock in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (3.12.3)\n",
"Requirement already satisfied: nvidia-cuda-cupti-cu11==11.7.101 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (11.7.101)\n",
"Requirement already satisfied: nvidia-cusparse-cu11==11.7.4.91 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (11.7.4.91)\n",
"Requirement already satisfied: nvidia-cuda-nvrtc-cu11==11.7.99 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (11.7.99)\n",
"Requirement already satisfied: nvidia-nccl-cu11==2.14.3 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (2.14.3)\n",
"Requirement already satisfied: nvidia-cuda-runtime-cu11==11.7.99 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (11.7.99)\n",
"Requirement already satisfied: nvidia-cublas-cu11==11.10.3.66 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (11.10.3.66)\n",
"Requirement already satisfied: sympy in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (1.12)\n",
"Requirement already satisfied: nvidia-cusolver-cu11==11.4.0.1 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (11.4.0.1)\n",
"Requirement already satisfied: jinja2 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (3.1.2)\n",
"Requirement already satisfied: networkx in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (3.1)\n",
"Requirement already satisfied: typing-extensions in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (4.7.1)\n",
"Requirement already satisfied: nvidia-nvtx-cu11==11.7.91 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (11.7.91)\n",
"Requirement already satisfied: nvidia-cufft-cu11==10.9.0.58 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (10.9.0.58)\n",
"Requirement already satisfied: triton==2.0.0 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (2.0.0)\n",
"Requirement already satisfied: nvidia-curand-cu11==10.2.10.91 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (10.2.10.91)\n",
"Requirement already satisfied: nvidia-cudnn-cu11==8.5.0.96 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from torch>=1.13.0->auto-gptq) (8.5.0.96)\n",
"Requirement already satisfied: wheel in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from nvidia-cublas-cu11==11.10.3.66->torch>=1.13.0->auto-gptq) (0.41.1)\n",
"Requirement already satisfied: setuptools in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from nvidia-cublas-cu11==11.10.3.66->torch>=1.13.0->auto-gptq) (68.0.0)\n",
"Requirement already satisfied: lit in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from triton==2.0.0->torch>=1.13.0->auto-gptq) (16.0.6)\n",
"Requirement already satisfied: cmake in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from triton==2.0.0->torch>=1.13.0->auto-gptq) (3.27.2)\n",
"Requirement already satisfied: tqdm>=4.27 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from transformers>=4.31.0->auto-gptq) (4.66.1)\n",
"Requirement already satisfied: regex!=2019.12.17 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from transformers>=4.31.0->auto-gptq) (2023.8.8)\n",
"Requirement already satisfied: huggingface-hub<1.0,>=0.15.1 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from transformers>=4.31.0->auto-gptq) (0.16.4)\n",
"Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from transformers>=4.31.0->auto-gptq) (0.13.3)\n",
"Requirement already satisfied: requests in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from transformers>=4.31.0->auto-gptq) (2.31.0)\n",
"Requirement already satisfied: fsspec in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.15.1->transformers>=4.31.0->auto-gptq) (2023.6.0)\n",
"Requirement already satisfied: multiprocess in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from datasets->auto-gptq) (0.70.15)\n",
"Requirement already satisfied: dill<0.3.8,>=0.3.0 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from datasets->auto-gptq) (0.3.7)\n",
"Requirement already satisfied: aiohttp in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from datasets->auto-gptq) (3.8.5)\n",
"Requirement already satisfied: xxhash in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from datasets->auto-gptq) (3.3.0)\n",
"Requirement already satisfied: pyarrow>=8.0.0 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from datasets->auto-gptq) (13.0.0)\n",
"Requirement already satisfied: pandas in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from datasets->auto-gptq) (2.1.0)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from aiohttp->datasets->auto-gptq) (6.0.4)\n",
"Requirement already satisfied: attrs>=17.3.0 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from aiohttp->datasets->auto-gptq) (23.1.0)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from aiohttp->datasets->auto-gptq) (4.0.3)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from aiohttp->datasets->auto-gptq) (1.3.1)\n",
"Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from aiohttp->datasets->auto-gptq) (3.2.0)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from aiohttp->datasets->auto-gptq) (1.4.0)\n",
"Requirement already satisfied: yarl<2.0,>=1.0 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from aiohttp->datasets->auto-gptq) (1.9.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from requests->transformers>=4.31.0->auto-gptq) (3.4)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from requests->transformers>=4.31.0->auto-gptq) (2.0.4)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from requests->transformers>=4.31.0->auto-gptq) (2023.7.22)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from jinja2->torch>=1.13.0->auto-gptq) (2.1.3)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from pandas->datasets->auto-gptq) (2.8.2)\n",
"Requirement already satisfied: pytz>=2020.1 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from pandas->datasets->auto-gptq) (2023.3)\n",
"Requirement already satisfied: tzdata>=2022.1 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from pandas->datasets->auto-gptq) (2023.3)\n",
"Requirement already satisfied: six>=1.5 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from python-dateutil>=2.8.2->pandas->datasets->auto-gptq) (1.16.0)\n",
"Requirement already satisfied: mpmath>=0.19 in /home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages (from sympy->torch>=1.13.0->auto-gptq) (1.3.0)\n"
]
}
],
"source": [
"!pip install auto-gptq"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "89705dea-d988-4ece-8073-54970626f4f7",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9540122492f14f46ba75ebce474c28b7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (…)lve/main/config.json: 0%| | 0.00/1.10k [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2e25472cc600484ca211d91ca59f0d36",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (…)fetensors.index.json: 0%| | 0.00/126k [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b17f43950b43488ebba5a2143c02aed3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading shards: 0%| | 0/2 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0e11ede92c694293aaa5d004f7efe364",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (…)of-00002.safetensors: 0%| | 0.00/9.98G [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b241c5f66c854876b574739f7ba3aaba",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (…)of-00002.safetensors: 0%| | 0.00/2.00G [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f21bb47869cb4841b65ca603c7449453",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Loading checkpoint shards: 0%| | 0/2 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7154fe572cf949e38cbeaa1e212281f7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (…)neration_config.json: 0%| | 0.00/154 [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "426dd05bb0a743c79b9604564809a5a1",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (…)okenizer_config.json: 0%| | 0.00/244 [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "66fab430ded94aada339c52da8cabaf7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading tokenizer.model: 0%| | 0.00/500k [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3b65f4ac6a764c919996c5dd750feaa0",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (…)/main/tokenizer.json: 0%| | 0.00/1.84M [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "222828ac2eb44eefa1de3ad41cb81cf4",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (…)in/added_tokens.json: 0%| | 0.00/21.0 [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "850fb340b7104c3a8b7d8fedda825690",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading (…)cial_tokens_map.json: 0%| | 0.00/435 [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from transformers import AutoTokenizer, AutoModelForCausalLM\n",
"\n",
"model_id = \"agonh/MythoMax22b-Falseblock-GPT\"\n",
"model = AutoModelForCausalLM.from_pretrained(model_id, device_map=\"auto\")\n",
"tokenizer = AutoTokenizer.from_pretrained(model_id)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d295d782-866a-4c60-9d03-18777a777568",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"text = \"Tell me about AI\"\n",
"inputs = tokenizer(text, return_tensors=\"pt\").to(0)\n",
"\n",
"out = model.generate(**inputs, max_new_tokens=500)\n",
"print(tokenizer.decode(out[0], skip_special_tokens=True))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ea9720ad-d3ca-4a5f-8cf6-1846ea3e1e13",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "default:Python",
"language": "python",
"name": "conda-env-default-py"
},
"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.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|