{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "IqM-T1RTzY6C" }, "source": [ "To run this, press \"*Runtime*\" and press \"*Run all*\" on a **free** Tesla T4 Google Colab instance!\n", "
\n", "\n", "To install Unsloth on your own computer, follow the installation instructions on our Github page [here](https://github.com/unslothai/unsloth?tab=readme-ov-file#-installation-instructions).\n", "\n", "You will learn how to do [data prep](#Data), how to [train](#Train), how to [run the model](#Inference), & [how to save it](#Save) (eg for Llama.cpp).\n", "\n", "[NEW] Llama-3.1 8b, 70b & 405b are trained on a crazy 15 trillion tokens with 128K long context lengths!\n", "\n", "**[NEW] Try 2x faster inference in a free Colab for Llama-3.1 8b Instruct [here](https://colab.research.google.com/drive/1T-YBVfnphoVc8E2E854qF3jdia2Ll2W2?usp=sharing)**" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "2eSvM9zX_2d3" }, "outputs": [], "source": [ "%%capture\n", "!pip install unsloth\n", "# Also get the latest nightly Unsloth!\n", "!pip uninstall unsloth -y && pip install --upgrade --no-cache-dir \"unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git\"" ] }, { "cell_type": "markdown", "metadata": { "id": "r2v_X2fA0Df5" }, "source": [ "* We support Llama, Mistral, Phi-3, Gemma, Yi, DeepSeek, Qwen, TinyLlama, Vicuna, Open Hermes etc\n", "* We support 16bit LoRA or 4bit QLoRA. Both 2x faster.\n", "* `max_seq_length` can be set to anything, since we do automatic RoPE Scaling via [kaiokendev's](https://kaiokendev.github.io/til) method.\n", "* [**NEW**] We make Gemma-2 9b / 27b **2x faster**! See our [Gemma-2 9b notebook](https://colab.research.google.com/drive/1vIrqH5uYDQwsJ4-OO3DErvuv4pBgVwk4?usp=sharing)\n", "* [**NEW**] To finetune and auto export to Ollama, try our [Ollama notebook](https://colab.research.google.com/drive/1WZDi7APtQ9VsvOrQSSC5DDtxq159j8iZ?usp=sharing)\n", "* [**NEW**] We make Mistral NeMo 12B 2x faster and fit in under 12GB of VRAM! [Mistral NeMo notebook](https://colab.research.google.com/drive/17d3U-CAIwzmbDRqbZ9NnpHxCkmXB6LZ0?usp=sharing)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 300, "referenced_widgets": [ "6e3c281f112b4a86af7a3ef95933d221", "92395f250a154006923aaf9ea0a9c30b", "f84bfc5390054ec687c157c4d68199a6", "4228734651ca45e19fc7bda79817f9b3", "4613edbbec6846edb5b1677c25d542b6", "d032fe2ba5d647d99026fdade758c0cd", "e9971d220fe24552a1e9aa299765cfb9", "2be29a4553ad4dfea8a9bc620c81a3ae", "94cbb87829d1486899e2ff6325c2ecdf", "f878c2e00bc240c7b0333cce950080e1", "6b908368de51428585552dfef6a83088", "ac5eacaaee8346c080e54ea7a52648a4", "7981edf408d54d41bbeac42da7492c6b", "2b848e5a85bc42bc87945fd9ed5db038", "e88c33f37d6849e0b1a6b41254104cb9", "33843107b93647b28985bfc37ea781ca", "76e5410e286a4a5abd6c213a38aa38bb", "ae7e90a811f94e75997d6a9ed1be8596", "bb9f3379310d4b04be694996f3137b28", "75082ba15db445df907f5612976590ae", "89934c4f26834f15b9889ec36fee3b65", "e887160635cb4803b9f33845df615ec6", "1c7bc5fdb7dd4c39af8d4c2c504ec3ed", "843a27e619534ea8914f9d36386c364b", "8f5adc70fbf248f2811527f620553be5", "4ffb4b2f015046fb94c1115ed0397a20", "5a232ed040f94633a2a374031284c1f6", "2006be31c09349738e221295bb84939f", "07055fc12b0841aaa5317f8252b5d347", "1eb90e686e214122ae763b1b79ae321d", "7a935956348e47c68fbdf05ddf4752f3", "8653acb618ad4e76bbf1daa00ea71238", "e3c3bd9c4c124b0a8c88c83c1fc747d3", "1bd75ddaf57c4438a4e2c3070b9cef65", "a3a3ef6d6337403cabea8b23f7c3021b", "c2ea0a3f01f34ffa8c94ab9b5098e9da", "68ea1d7cb8274a639b3fb5326f4218c3", "39fef7b257614a0595f39355fa226b69", "d125995cc0934239a01ba01b78529f21", "634ae4c6cfe04673b1cdc9c9cac4cbf9", "d7f92e8332374313bee87ccd427446a4", "36799fbcd90d43128620ff98225a825d", "5310346dd579424fa676b8e8e64790e7", "0c1835f404db4846bb13b5da8d8f4447", "29c5b713f07043dda51820523e5c8ff3", "d7375f0f048841b29a20601c122666e8", "f433ced9bfcd4a57ba691d3c1caeed08", "da8ffc70820a48f5a12c6d4b5967015b", "1a6db9aea6a64ae3aaef51d6265b35b2", "331f516c7a76456d801bc2a2feb228aa", "9be9074028da42d39d044a78393a861f", "51cd9026b1664819a67712996ca97bd5", "ea55293415ca48a4be97c2e1e4769122", "8ea52b105a7e44978caca33c0e7e815b", "3662f1445ef34a50b462e601ed31bb69" ] }, "id": "QmUBVEnvCDJv", "outputId": "0a47b925-663d-4543-9c61-994a6302f3c5" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/kurogane/anaconda3/envs/llmfact/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "๐ฆฅ Unsloth: Will patch your computer to enable 2x faster free finetuning.\n", "[2024-09-18 21:27:01,596] [INFO] [real_accelerator.py:203:get_accelerator] Setting ds_accelerator to cuda (auto detect)\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/home/kurogane/anaconda3/envs/llmfact/bin/../lib/gcc/x86_64-conda-linux-gnu/11.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: cannot find -laio: ใใฎใใใชใใกใคใซใใใฃใฌใฏใใชใฏใใใพใใ\n", "collect2: error: ld returned 1 exit status\n", "nvcc warning : incompatible redefinition for option 'compiler-bindir', the last value of this option was used\n", "/home/kurogane/anaconda3/envs/llmfact/bin/../lib/gcc/x86_64-conda-linux-gnu/11.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: cannot find -laio: ใใฎใใใชใใกใคใซใใใฃใฌใฏใใชใฏใใใพใใ\n", "collect2: error: ld returned 1 exit status\n", "nvcc warning : incompatible redefinition for option 'compiler-bindir', the last value of this option was used\n", "nvcc warning : incompatible redefinition for option 'compiler-bindir', the last value of this option was used\n", "nvcc warning : incompatible redefinition for option 'compiler-bindir', the last value of this option was used\n", "nvcc warning : incompatible redefinition for option 'compiler-bindir', the last value of this option was used\n", "nvcc warning : incompatible redefinition for option 'compiler-bindir', the last value of this option was used\n", "nvcc warning : incompatible redefinition for option 'compiler-bindir', the last value of this option was used\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "==((====))== Unsloth 2024.8: Fast Llama patching. Transformers = 4.45.0.dev0.\n", " \\\\ /| GPU: NVIDIA RTX A6000. Max memory: 47.521 GB. Platform = Linux.\n", "O^O/ \\_/ \\ Pytorch: 2.4.0+cu121. CUDA = 8.6. CUDA Toolkit = 12.1.\n", "\\ / Bfloat16 = TRUE. FA [Xformers = 0.0.27.post2. FA2 = True]\n", " \"-____-\" Free Apache license: http://github.com/unslothai/unsloth\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Loading checkpoint shards: 100%|โโโโโโโโโโ| 2/2 [00:01<00:00, 1.26it/s]\n", "Magpie-Align/MagpieLM-4B-Chat-v0.1 does not have a padding token! Will use pad_token = <|finetune_right_pad_id|>.\n", "