{ "cells": [ { "cell_type": "markdown", "id": "540de0f1-8363-4185-b88c-2cf165aa5b91", "metadata": { "id": "540de0f1-8363-4185-b88c-2cf165aa5b91" }, "source": [ "# Lightweight Fine-Tuning Project" ] }, { "cell_type": "markdown", "id": "618bc1e3-b7c4-4d60-a840-c04d0d92e3d2", "metadata": { "id": "618bc1e3-b7c4-4d60-a840-c04d0d92e3d2" }, "source": [ "TODO: In this cell, describe your choices for each of the following\n", "\n", "* PEFT technique:\n", "* Model:\n", "* Evaluation approach:\n", "* Fine-tuning dataset:" ] }, { "cell_type": "markdown", "id": "cc6aadea-517d-4ac3-908d-4e60dbbe987b", "metadata": { "id": "cc6aadea-517d-4ac3-908d-4e60dbbe987b" }, "source": [ "## Loading and Evaluating a Foundation Model\n", "\n", "TODO: In the cells below, load your chosen pre-trained Hugging Face model and evaluate its performance prior to fine-tuning. This step includes loading an appropriate tokenizer and dataset." ] }, { "cell_type": "markdown", "id": "1660d997", "metadata": { "id": "1660d997" }, "source": [ "# 1. Installation\n", "\n", "Below we install the necessary packages for this notebook." ] }, { "cell_type": "code", "execution_count": 1, "id": "8qA7EH0umAsX", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "8qA7EH0umAsX", "outputId": "c8a26717-3ca6-489b-e022-b86154b58adc" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Defaulting to user installation because normal site-packages is not writeable\n", "Collecting evaluate\n", " Downloading evaluate-0.4.3-py3-none-any.whl (84 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m84.0/84.0 kB\u001b[0m \u001b[31m1.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m\n", "\u001b[?25hCollecting scikit-learn\n", " Downloading scikit_learn-1.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.5 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.5/13.5 MB\u001b[0m \u001b[31m80.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m0:01\u001b[0m\n", "\u001b[?25hCollecting datasets==3.2.0\n", " Downloading datasets-3.2.0-py3-none-any.whl (480 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m480.6/480.6 kB\u001b[0m \u001b[31m44.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: bitsandbytes in /opt/conda/lib/python3.10/site-packages (0.41.1)\n", "Collecting requests>=2.32.2\n", " Downloading requests-2.32.3-py3-none-any.whl (64 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m64.9/64.9 kB\u001b[0m \u001b[31m11.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: xxhash in /opt/conda/lib/python3.10/site-packages (from datasets==3.2.0) (3.4.1)\n", "Requirement already satisfied: fsspec[http]<=2024.9.0,>=2023.1.0 in /home/student/.local/lib/python3.10/site-packages (from datasets==3.2.0) (2024.2.0)\n", "Requirement already satisfied: aiohttp in /opt/conda/lib/python3.10/site-packages (from datasets==3.2.0) (3.9.3)\n", "Collecting huggingface-hub>=0.23.0\n", " Downloading huggingface_hub-0.27.0-py3-none-any.whl (450 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m450.5/450.5 kB\u001b[0m \u001b[31m45.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: numpy>=1.17 in /home/student/.local/lib/python3.10/site-packages (from datasets==3.2.0) (1.26.4)\n", "Requirement already satisfied: filelock in /home/student/.local/lib/python3.10/site-packages (from datasets==3.2.0) (3.13.1)\n", "Requirement already satisfied: pyarrow>=15.0.0 in /opt/conda/lib/python3.10/site-packages (from datasets==3.2.0) (15.0.1)\n", "Requirement already satisfied: pyyaml>=5.1 in /home/student/.local/lib/python3.10/site-packages (from datasets==3.2.0) (6.0.1)\n", "Requirement already satisfied: dill<0.3.9,>=0.3.0 in /opt/conda/lib/python3.10/site-packages (from datasets==3.2.0) (0.3.8)\n", "Collecting tqdm>=4.66.3\n", " Downloading tqdm-4.67.1-py3-none-any.whl (78 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m78.5/78.5 kB\u001b[0m \u001b[31m14.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: multiprocess<0.70.17 in /opt/conda/lib/python3.10/site-packages (from datasets==3.2.0) (0.70.16)\n", "Requirement already satisfied: pandas in /home/student/.local/lib/python3.10/site-packages (from datasets==3.2.0) (2.2.1)\n", "Requirement already satisfied: packaging in /home/student/.local/lib/python3.10/site-packages (from datasets==3.2.0) (24.0)\n", "Collecting threadpoolctl>=3.1.0\n", " Downloading threadpoolctl-3.5.0-py3-none-any.whl (18 kB)\n", "Collecting joblib>=1.2.0\n", " Downloading joblib-1.4.2-py3-none-any.whl (301 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m301.8/301.8 kB\u001b[0m \u001b[31m36.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: scipy>=1.6.0 in /opt/conda/lib/python3.10/site-packages (from scikit-learn) (1.11.2)\n", "Requirement already satisfied: aiosignal>=1.1.2 in /opt/conda/lib/python3.10/site-packages (from aiohttp->datasets==3.2.0) (1.3.1)\n", "Requirement already satisfied: frozenlist>=1.1.1 in /opt/conda/lib/python3.10/site-packages (from aiohttp->datasets==3.2.0) (1.4.1)\n", "Requirement already satisfied: yarl<2.0,>=1.0 in /opt/conda/lib/python3.10/site-packages (from aiohttp->datasets==3.2.0) (1.9.4)\n", "Requirement already satisfied: multidict<7.0,>=4.5 in /opt/conda/lib/python3.10/site-packages (from aiohttp->datasets==3.2.0) (6.0.5)\n", "Requirement already satisfied: async-timeout<5.0,>=4.0 in /opt/conda/lib/python3.10/site-packages (from aiohttp->datasets==3.2.0) (4.0.3)\n", "Requirement already satisfied: attrs>=17.3.0 in /home/student/.local/lib/python3.10/site-packages (from aiohttp->datasets==3.2.0) (23.2.0)\n", "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/student/.local/lib/python3.10/site-packages (from huggingface-hub>=0.23.0->datasets==3.2.0) (4.10.0)\n", "Requirement already satisfied: certifi>=2017.4.17 in /home/student/.local/lib/python3.10/site-packages (from requests>=2.32.2->datasets==3.2.0) (2024.2.2)\n", "Requirement already satisfied: idna<4,>=2.5 in /home/student/.local/lib/python3.10/site-packages (from requests>=2.32.2->datasets==3.2.0) (3.6)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/student/.local/lib/python3.10/site-packages (from requests>=2.32.2->datasets==3.2.0) (2.2.1)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /home/student/.local/lib/python3.10/site-packages (from requests>=2.32.2->datasets==3.2.0) (3.3.2)\n", "Requirement already satisfied: pytz>=2020.1 in /home/student/.local/lib/python3.10/site-packages (from pandas->datasets==3.2.0) (2024.1)\n", "Requirement already satisfied: python-dateutil>=2.8.2 in /home/student/.local/lib/python3.10/site-packages (from pandas->datasets==3.2.0) (2.9.0.post0)\n", "Requirement already satisfied: tzdata>=2022.7 in /home/student/.local/lib/python3.10/site-packages (from pandas->datasets==3.2.0) (2024.1)\n", "Requirement already satisfied: six>=1.5 in /home/student/.local/lib/python3.10/site-packages (from python-dateutil>=2.8.2->pandas->datasets==3.2.0) (1.16.0)\n", "Installing collected packages: tqdm, threadpoolctl, requests, joblib, scikit-learn, huggingface-hub, datasets, evaluate\n", " Attempting uninstall: tqdm\n", " Found existing installation: tqdm 4.66.2\n", " Uninstalling tqdm-4.66.2:\n", " Successfully uninstalled tqdm-4.66.2\n", "\u001b[33m WARNING: The script tqdm is installed in '/home/student/.local/bin' which is not on PATH.\n", " Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\u001b[0m\u001b[33m\n", "\u001b[0m Attempting uninstall: requests\n", " Found existing installation: requests 2.31.0\n", " Uninstalling requests-2.31.0:\n", " Successfully uninstalled requests-2.31.0\n", " Attempting uninstall: huggingface-hub\n", " Found existing installation: huggingface-hub 0.21.4\n", " Uninstalling huggingface-hub-0.21.4:\n", " Successfully uninstalled huggingface-hub-0.21.4\n", "\u001b[33m WARNING: The script huggingface-cli is installed in '/home/student/.local/bin' which is not on PATH.\n", " Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\u001b[0m\u001b[33m\n", "\u001b[0m\u001b[33m WARNING: The script datasets-cli is installed in '/home/student/.local/bin' which is not on PATH.\n", " Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\u001b[0m\u001b[33m\n", "\u001b[0m\u001b[33m WARNING: The script evaluate-cli is installed in '/home/student/.local/bin' which is not on PATH.\n", " Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\u001b[0m\u001b[33m\n", "\u001b[0mSuccessfully installed datasets-3.2.0 evaluate-0.4.3 huggingface-hub-0.27.0 joblib-1.4.2 requests-2.32.3 scikit-learn-1.6.0 threadpoolctl-3.5.0 tqdm-4.67.1\n" ] } ], "source": [ "# You will need to choose \"Kernel > Restart Kernel\" from the menu after executing this cell\n", "\n", "!pip install evaluate scikit-learn \"datasets==3.2.0\" bitsandbytes" ] }, { "cell_type": "markdown", "id": "8920ddfd", "metadata": { "id": "8920ddfd" }, "source": [ "# 2. Imports\n", "\n", "In this section, we import the libraries and modules we will need." ] }, { "cell_type": "code", "execution_count": 2, "id": "4ffe2951", "metadata": { "id": "4ffe2951" }, "outputs": [], "source": [ "from transformers import AutoTokenizer, AutoModelForSequenceClassification\n", "from datasets import load_dataset\n", "import pandas as pd\n", "import torch\n", "import numpy as np\n", "\n", "from peft import LoraConfig, TaskType, get_peft_model, AutoPeftModelForSequenceClassification\n", "from transformers import DataCollatorWithPadding, TrainingArguments, Trainer, BitsAndBytesConfig\n", "from huggingface_hub import login" ] }, { "cell_type": "markdown", "id": "353bcfbd-7272-49b9-b429-06ffcea54420", "metadata": { "id": "353bcfbd-7272-49b9-b429-06ffcea54420" }, "source": [ "# 3. Tokenizer Initialization\n", "\n", "We load the GPT-2 tokenizer here, specifying a maximum length for the tokens." ] }, { "cell_type": "code", "execution_count": 3, "id": "575464d1-566c-4bf6-8e4e-b914356c6ce1", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 301, "referenced_widgets": [ "8ef69789ed6e402a9e2b1bf40639996a", "712324d4db274b07b998297a17234b50", "62235a25203447c1a409ba0187384099", "a57c4ee0dbe04cdcbc8aea642012e472", "e9ea3d3b7618456daa4a69a9cf606393", "13bb5eb0be2c4e44ba3399b34a5a9f7d", "b647d7c4c9124fb690f8b0457de65947", "e5468f5ffae54995b4be5949a6776779", "4df005527ec54ba38f5a68237cc7e857", "8460913c8ac24b4bb365abaece1bc567", "4698294920024f57b088908d3cfa4adc", "769b112c566148b28990d01cf51a8cb5", "d1174c6811ad4beebf3a07ef64353cc5", "93c5c1dade0d492a9ac6787240244f02", "3a5b281892d74aa7b2f1f4dac9571807", "7801d9a7d0ac427eaa0d219687c2b8da", "c9da2833e9344e0ebb1ebaa648541d4b", "24c0797f1b8c4229b82f71133bf6a72d", "020a63cb25a54f5eb73f015facf50efe", "e843522456d64502acfd59f587be3420", "857cbc7b5ecc41d890063e6dbc182345", "14b9629965504128bd506ad6499b0c58", "fbc7bcfad2f441f4a24ef4c9a26fc3c8", "58e808e9fe4a4d8385d52e43a2a98322", "bb0cec766fd0413ea136e9c4bfd3c23b", "c863898951c445eb8c2acfbcb2c18f0f", "d41f243f980740ab9bcc62e639919144", "49aef9964d364d648ea6a771b825b5fa", "e76fb526eff640839fa3170b4193e2fb", "c6a609a876a1443fb0966326c8fd578c", "ae0098a53299486c8e14dba48911a43c", "df2e3ab1fbd54c3a8d64be8fc805bacd", "2e0a55e7df5e4481bc593127e09f8193", "a7b96ff8bc3b46d6a0c54e5728dd4130", "36d5f58681754426bd5372e651106bce", "c87485ccdd214a2b8603953fcb069308", "08308fbfcd4e44e4b2f6e51e0f3a8dee", "a5492ac8232f49458d205bbe9b9deefc", "eb43f7c90f4a4b479813821a20723dfe", "ba6feac5667746f7a3f937a9d7ce3dbc", "c65ceb81975a48339199a4ca0a488d4f", "3b114a738a4b44aea9aa2c0589e36acc", "6a961253b896417ab0fd869de117a309", "ba6ba427f9494e319b8194965e864c7f", "a1168b67db6f40f199a465f7a4bbf43e", "2c965fe289184f469d5d03f979e89fa1", "df70c0d7a36d463ca99af360d5dc1e0d", "115c433c683b43d783906028783313a6", "b3a6061ba142465cbe922d7142d25fb1", "82fe175ceae04028871f46311881851c", "216b78952d754deb824037a6a2eb8e50", "805fbc6840104cf897f19eaada4cca3e", "713300c88d934d4c95fb1ec5d1c55959", "15433682a5b240f38fe3efe28cb3a60e", "3d43e2944b1c409c9546c5bcdcf12953" ] }, "id": "575464d1-566c-4bf6-8e4e-b914356c6ce1", "outputId": "fd06f6b0-50c2-408e-d8d7-cd68e3d21aaf" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/student/.local/lib/python3.10/site-packages/huggingface_hub/file_download.py:795: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n", " warnings.warn(\n" ] } ], "source": [ "MODEL_NAME = \"gpt2\"\n", "\n", "tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, max_length=1024)\n", "tokenizer.pad_token = tokenizer.eos_token # Set pad token to the EOS token" ] }, { "cell_type": "markdown", "id": "fdNWtZ-_FEjR", "metadata": { "id": "fdNWtZ-_FEjR" }, "source": [ "# 4. Load and Preview Dataset\n", "\n", "We load the **sms_spam** dataset and split it into training and test sets. We then display the raw dataset for inspection." ] }, { "cell_type": "code", "execution_count": 4, "id": "f8fdc6bb-cf82-4f04-b30b-9c4ed3e9a556", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 287, "referenced_widgets": [ "0f0d0f46d9b64b8da3198e32037ce582", "7b5c6dd8832a490f8eb7b9268c6c4a8a", "a2f6678ec63549189e19efc456e4dcc9", "869a0a74ab72492c89c3b64c6bb1e762", "af7acc7f056b499e86461bf7f3144ca8", "b5d1fc1ac7ad4e6fb189d93cbccc836b", "966316cb0b9b4a0b822ebd2046306aae", "c5bbb77191d84cf699a60d99244fdd62", "d9f3e2fd9ce241ec8759dc6acbed27c0", "dfb969eac5684c6fa09bf556e48fce7f", "08c3790881a44e4a8c25d505d7c441c4", "bfd944bf59c7475196b98b6aaa7291c7", "1fe53669a9ad4b86a53c44f603c6b7e4", "24e6dcb248024a1e82f4f07227bbb2a0", "e5425918a72744659f874cd8c1dd660e", "9f398a8145d7400b996d6277ed18c40c", "5e7097a34a0f4ab2a3137882c599c3f1", "7c8a884a688b4cafbc0305084e11c99e", "827eddb9e93a4500a669eb74f81deaad", "8fafad6243814ad3b036697653058eeb", "5d386e56017b49e7b819d5d1c684637d", "d18796a6857e45a8a27bc29537357832", "eda4c72ca07d4021b29228dbc719c95b", "8f6a296c6e364c4ab1d2dc0acd36b5ac", "7f19dc0038204724bfaae182c4b1bb72", "5914b8fb99d3426bb673afc9ed84cb67", "daea8dea3eba48129c8e8bdb62b423b2", "7092d7fcc2734da782279e50b9774459", "5f8e5fa84c464e5685bf9ba9f701b2a6", "5dd47cfbfc3c4ff0b12e377342ecc5d6", "a597b617c94b40f1a848919c3fadb969", "376559fec4e6400dae522f92701ca29f", "454e0f3b390e44d3b1bcbad38d22208f" ] }, "id": "f8fdc6bb-cf82-4f04-b30b-9c4ed3e9a556", "outputId": "74df2830-c0db-4089-a4cf-041c86421840", "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "DatasetDict({\n", " train: Dataset({\n", " features: ['sms', 'label'],\n", " num_rows: 4459\n", " })\n", " test: Dataset({\n", " features: ['sms', 'label'],\n", " num_rows: 1115\n", " })\n", "})" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dataset_name = \"sms_spam\"\n", "\n", "raw_datasets = load_dataset(dataset_name, split=\"train\").train_test_split(\n", " test_size=0.2, shuffle=True, seed=23\n", ")\n", "\n", "# Display basic dataset info\n", "raw_datasets" ] }, { "cell_type": "markdown", "id": "vvyH2xotUXVw", "metadata": { "id": "vvyH2xotUXVw" }, "source": [ "# 5. Tokenize the Dataset\n", "\n", "Here, we define a `tokenize_func` function and apply it to the dataset. We remove the original 'sms' column to keep the dataset clean." ] }, { "cell_type": "code", "execution_count": 5, "id": "a6qLbG6cUbIy", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 220, "referenced_widgets": [ "a654b855045146c1ad0443e912f62854", "1f1a81e1db9c42b080e12f9505c79d7a", "03fffa864a5e4a5d84bdbe01110d2c6a", "2777ec433e2c4afab18a7a35a36f5bfe", "85ec8ee1f13a4052b5a8d0761e7b4bd8", "eb48cc3fec2646ee9ef1d82d43d85338", "b56fa5ae47454ac88ea0d667629cba9f", "af13bb2b30ad46b1805ffc8582365bac", "b9ca6d18b93d4be58ca59183e1a311a4", "3cab7bc6d28f4b42a50986ebb0752d4f", "7cb217feba7147cdacaf9f01a0e9f694", "de35e90f73d34ac7bc1a9df988b48ad7", "bfe954e4647f45dd868678b2c7cff740", "99f8a7b1680748f289ebff1049625f07", "fd4cff9a5a6942e684c8b33087fa36ff", "035c94715c9542c4acf5d8771453eb72", "22c95e74f8774aef8d8bd8ff32eafdbc", "32fc1ee385384bf0862368a03e21c755", "4f1502e4aecb4022b5918dffe6869c34", "0a881fdf7eb44492acccb2d2b363966d", "743ff74017d74632aacd1c4121606c23", "7fd500b4388e4deca8e0eb28be9a4836" ] }, "id": "a6qLbG6cUbIy", "outputId": "51200a92-afbb-4912-dc7b-94629f9deb58" }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "8af0e32dd8b24bb3ac686fff1fd39d03", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map: 0%| | 0/1115 [00:00, ? examples/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "{'train': Dataset({\n", " features: ['label', 'input_ids', 'attention_mask'],\n", " num_rows: 4459\n", " }),\n", " 'test': Dataset({\n", " features: ['label', 'input_ids', 'attention_mask'],\n", " num_rows: 1115\n", " })}" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def tokenize_func(element):\n", " return tokenizer(\n", " element['sms'],\n", " padding=\"max_length\",\n", " truncation=True\n", " )\n", "\n", "splits = [\"train\", \"test\"]\n", "tokenized_datasets = {}\n", "\n", "for split in splits:\n", " tokenized_datasets[split] = raw_datasets[split].map(\n", " tokenize_func,\n", " batched=True,\n", " remove_columns=[\"sms\"]\n", " )\n", "\n", "# Inspect the resulting tokenized dataset\n", "tokenized_datasets" ] }, { "cell_type": "markdown", "id": "5727744e", "metadata": { "id": "5727744e" }, "source": [ "# 6. Quick Look at Tokenized Data\n", "\n", "Convert the first few examples to a DataFrame to see how they look after tokenization." ] }, { "cell_type": "code", "execution_count": 6, "id": "4b8da8d5", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 206 }, "id": "4b8da8d5", "outputId": "742430d3-df03-47cb-e4e9-966455533d97" }, "outputs": [ { "data": { "text/html": [ "
| \n", " | label | \n", "input_ids | \n", "attention_mask | \n", "
|---|---|---|---|
| 0 | \n", "1 | \n", "[25383, 534, 5175, 838, 285, 9998, 30, 10133, ... | \n", "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ... | \n", "
| 1 | \n", "0 | \n", "[7594, 220, 1222, 2528, 26, 2, 5, 13655, 26, 8... | \n", "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, ... | \n", "
| 2 | \n", "0 | \n", "[19926, 314, 423, 6497, 510, 257, 14507, 393, ... | \n", "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, ... | \n", "
| 3 | \n", "0 | \n", "[18565, 306, 8508, 319, 428, 1323, 290, 340, 1... | \n", "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, ... | \n", "
| 4 | \n", "0 | \n", "[18690, 986, 198, 50256, 50256, 50256, 50256, ... | \n", "[1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... | \n", "
| Step | \n", "Training Loss | \n", "Validation Loss | \n", "Accuracy | \n", "
|---|---|---|---|
| 100 | \n", "0.555500 | \n", "0.093548 | \n", "0.982063 | \n", "
| 200 | \n", "0.092900 | \n", "0.077017 | \n", "0.983857 | \n", "
| 300 | \n", "0.060500 | \n", "0.083342 | \n", "0.985650 | \n", "
| 400 | \n", "0.062000 | \n", "0.070049 | \n", "0.985650 | \n", "
| 500 | \n", "0.047400 | \n", "0.070088 | \n", "0.986547 | \n", "
"
],
"text/plain": [
" 406\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 407\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m HTTPError \u001b[38;5;28;01mas\u001b[39;00m e:\n",
"File \u001b[0;32m~/.local/lib/python3.10/site-packages/requests/models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 1023\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[0;32m-> 1024\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n",
"\u001b[0;31mHTTPError\u001b[0m: 401 Client Error: Unauthorized for url: https://huggingface.co/api/repos/create",
"\nThe above exception was the direct cause of the following exception:\n",
"\u001b[0;31mHfHubHTTPError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[19], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m login()\n\u001b[0;32m----> 2\u001b[0m \u001b[43mpeft_model\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpush_to_hub\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mjonathanbenavides/peft-model-gpt2-sms-spam-bitsandbytes-8bits\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/transformers/utils/hub.py:860\u001b[0m, in \u001b[0;36mPushToHubMixin.push_to_hub\u001b[0;34m(self, repo_id, use_temp_dir, commit_message, private, token, max_shard_size, create_pr, safe_serialization, revision, commit_description, **deprecated_kwargs)\u001b[0m\n\u001b[1;32m 857\u001b[0m repo_url \u001b[38;5;241m=\u001b[39m deprecated_kwargs\u001b[38;5;241m.\u001b[39mpop(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrepo_url\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[1;32m 858\u001b[0m organization \u001b[38;5;241m=\u001b[39m deprecated_kwargs\u001b[38;5;241m.\u001b[39mpop(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124morganization\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[0;32m--> 860\u001b[0m repo_id \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_create_repo\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 861\u001b[0m \u001b[43m \u001b[49m\u001b[43mrepo_id\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mprivate\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mprivate\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtoken\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtoken\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrepo_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrepo_url\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43morganization\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43morganization\u001b[49m\n\u001b[1;32m 862\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 864\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m use_temp_dir \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 865\u001b[0m use_temp_dir \u001b[38;5;241m=\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39misdir(working_dir)\n",
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/transformers/utils/hub.py:680\u001b[0m, in \u001b[0;36mPushToHubMixin._create_repo\u001b[0;34m(self, repo_id, private, token, repo_url, organization)\u001b[0m\n\u001b[1;32m 677\u001b[0m repo_id \u001b[38;5;241m=\u001b[39m repo_id\u001b[38;5;241m.\u001b[39msplit(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m/\u001b[39m\u001b[38;5;124m\"\u001b[39m)[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m]\n\u001b[1;32m 678\u001b[0m repo_id \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00morganization\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mrepo_id\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m--> 680\u001b[0m url \u001b[38;5;241m=\u001b[39m \u001b[43mcreate_repo\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrepo_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrepo_id\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtoken\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtoken\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mprivate\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mprivate\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mexist_ok\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 681\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m url\u001b[38;5;241m.\u001b[39mrepo_id\n",
"File \u001b[0;32m~/.local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114\u001b[0m, in \u001b[0;36mvalidate_hf_hub_args.