{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 1000 }, "id": "LRojCPkpOHlk", "outputId": "5cac7b18-d3a3-4885-9c5b-bbcfcabaaf5b" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: unsloth in ./lib/python3.11/site-packages (2025.4.6)\n", "Requirement already satisfied: torch in ./lib/python3.11/site-packages (2.5.1)\n", "Requirement already satisfied: pandas in ./lib/python3.11/site-packages (2.2.3)\n", "Requirement already satisfied: datasets in ./lib/python3.11/site-packages (3.2.0)\n", "Requirement already satisfied: transformers in ./lib/python3.11/site-packages (4.51.3)\n", "Requirement already satisfied: sentence-transformers in ./lib/python3.11/site-packages (3.4.1)\n", "Requirement already satisfied: joblib in ./lib/python3.11/site-packages (1.4.2)\n", "Requirement already satisfied: scikit-learn in ./lib/python3.11/site-packages (1.6.1)\n", "Requirement already satisfied: wandb in ./lib/python3.11/site-packages (0.19.8)\n", "Requirement already satisfied: trl in ./lib/python3.11/site-packages (0.13.0)\n", "Requirement already satisfied: huggingface_hub in ./lib/python3.11/site-packages (0.30.2)\n", "Requirement already satisfied: filelock in ./lib/python3.11/site-packages (from torch) (3.17.0)\n", "Requirement already satisfied: typing-extensions>=4.8.0 in ./lib/python3.11/site-packages (from torch) (4.12.2)\n", "Requirement already satisfied: networkx in ./lib/python3.11/site-packages (from torch) (3.4.2)\n", "Requirement already satisfied: jinja2 in ./lib/python3.11/site-packages (from torch) (3.1.5)\n", "Requirement already satisfied: fsspec in ./lib/python3.11/site-packages (from torch) (2024.9.0)\n", "Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.4.127 in ./lib/python3.11/site-packages (from torch) (12.4.127)\n", "Requirement already satisfied: nvidia-cuda-runtime-cu12==12.4.127 in ./lib/python3.11/site-packages (from torch) (12.4.127)\n", "Requirement already satisfied: nvidia-cuda-cupti-cu12==12.4.127 in ./lib/python3.11/site-packages (from torch) (12.4.127)\n", "Requirement already satisfied: nvidia-cudnn-cu12==9.1.0.70 in ./lib/python3.11/site-packages (from torch) (9.1.0.70)\n", "Requirement already satisfied: nvidia-cublas-cu12==12.4.5.8 in ./lib/python3.11/site-packages (from torch) (12.4.5.8)\n", "Requirement already satisfied: nvidia-cufft-cu12==11.2.1.3 in ./lib/python3.11/site-packages (from torch) (11.2.1.3)\n", "Requirement already satisfied: nvidia-curand-cu12==10.3.5.147 in ./lib/python3.11/site-packages (from torch) (10.3.5.147)\n", "Requirement already satisfied: nvidia-cusolver-cu12==11.6.1.9 in ./lib/python3.11/site-packages (from torch) (11.6.1.9)\n", "Requirement already satisfied: nvidia-cusparse-cu12==12.3.1.170 in ./lib/python3.11/site-packages (from torch) (12.3.1.170)\n", "Requirement already satisfied: nvidia-nccl-cu12==2.21.5 in ./lib/python3.11/site-packages (from torch) (2.21.5)\n", "Requirement already satisfied: nvidia-nvtx-cu12==12.4.127 in ./lib/python3.11/site-packages (from torch) (12.4.127)\n", "Requirement already satisfied: nvidia-nvjitlink-cu12==12.4.127 in ./lib/python3.11/site-packages (from torch) (12.4.127)\n", "Requirement already satisfied: triton==3.1.0 in ./lib/python3.11/site-packages (from torch) (3.1.0)\n", "Requirement already satisfied: sympy==1.13.1 in ./lib/python3.11/site-packages (from torch) (1.13.1)\n", "Requirement already satisfied: mpmath<1.4,>=1.1.0 in ./lib/python3.11/site-packages (from sympy==1.13.1->torch) (1.3.0)\n", "Requirement already satisfied: numpy>=1.23.2 in ./lib/python3.11/site-packages (from pandas) (2.2.2)\n", "Requirement already satisfied: python-dateutil>=2.8.2 in ./lib/python3.11/site-packages (from pandas) (2.9.0.post0)\n", "Requirement already satisfied: pytz>=2020.1 in ./lib/python3.11/site-packages (from pandas) (2024.2)\n", "Requirement already satisfied: tzdata>=2022.7 in ./lib/python3.11/site-packages (from pandas) (2025.1)\n", "Requirement already satisfied: pyarrow>=15.0.0 in ./lib/python3.11/site-packages (from datasets) (19.0.0)\n", "Requirement already satisfied: dill<0.3.9,>=0.3.0 in ./lib/python3.11/site-packages (from datasets) (0.3.8)\n", "Requirement already satisfied: requests>=2.32.2 in ./lib/python3.11/site-packages (from datasets) (2.32.3)\n", "Requirement already satisfied: tqdm>=4.66.3 in ./lib/python3.11/site-packages (from datasets) (4.67.1)\n", "Requirement already satisfied: xxhash in ./lib/python3.11/site-packages (from datasets) (3.5.0)\n", "Requirement already satisfied: multiprocess<0.70.17 in ./lib/python3.11/site-packages (from datasets) (0.70.16)\n", "Requirement already satisfied: aiohttp in ./lib/python3.11/site-packages (from datasets) (3.11.11)\n", "Requirement already satisfied: packaging in ./lib/python3.11/site-packages (from datasets) (24.2)\n", "Requirement already satisfied: pyyaml>=5.1 in ./lib/python3.11/site-packages (from datasets) (6.0.2)\n", "Requirement already satisfied: regex!=2019.12.17 in ./lib/python3.11/site-packages (from transformers) (2024.11.6)\n", "Requirement already satisfied: tokenizers<0.22,>=0.21 in ./lib/python3.11/site-packages (from transformers) (0.21.0)\n", "Requirement already satisfied: safetensors>=0.4.3 in ./lib/python3.11/site-packages (from transformers) (0.5.2)\n", "Requirement already satisfied: scipy in ./lib/python3.11/site-packages (from sentence-transformers) (1.15.2)\n", "Requirement already satisfied: Pillow in ./lib/python3.11/site-packages (from sentence-transformers) (11.1.0)\n", "Requirement already satisfied: threadpoolctl>=3.1.0 in ./lib/python3.11/site-packages (from scikit-learn) (3.6.0)\n", "Requirement already satisfied: click!=8.0.0,>=7.1 in ./lib/python3.11/site-packages (from wandb) (8.1.8)\n", "Requirement already satisfied: docker-pycreds>=0.4.0 in ./lib/python3.11/site-packages (from wandb) (0.4.0)\n", "Requirement already satisfied: gitpython!=3.1.29,>=1.0.0 in ./lib/python3.11/site-packages (from wandb) (3.1.44)\n", "Requirement already satisfied: platformdirs in ./lib/python3.11/site-packages (from wandb) (4.3.6)\n", "Requirement already satisfied: protobuf!=4.21.0,!=5.28.0,<6,>=3.19.0 in ./lib/python3.11/site-packages (from wandb) (3.20.3)\n", "Requirement already satisfied: psutil>=5.0.0 in ./lib/python3.11/site-packages (from wandb) (6.1.1)\n", "Requirement already satisfied: pydantic<3,>=2.6 in ./lib/python3.11/site-packages (from wandb) (2.10.6)\n", "Requirement already satisfied: sentry-sdk>=2.0.0 in ./lib/python3.11/site-packages (from wandb) (2.22.0)\n", "Requirement already satisfied: setproctitle in ./lib/python3.11/site-packages (from wandb) (1.3.5)\n", "Requirement already satisfied: setuptools in ./lib/python3.11/site-packages (from wandb) (65.5.0)\n", "Requirement already satisfied: accelerate>=0.34.0 in ./lib/python3.11/site-packages (from trl) (1.3.0)\n", "Requirement already satisfied: rich in ./lib/python3.11/site-packages (from trl) (13.9.4)\n", "Requirement already satisfied: six>=1.4.0 in ./lib/python3.11/site-packages (from docker-pycreds>=0.4.0->wandb) (1.17.0)\n", "Requirement already satisfied: aiohappyeyeballs>=2.3.0 in ./lib/python3.11/site-packages (from aiohttp->datasets) (2.4.4)\n", "Requirement already satisfied: aiosignal>=1.1.2 in ./lib/python3.11/site-packages (from aiohttp->datasets) (1.3.2)\n", "Requirement already satisfied: attrs>=17.3.0 in ./lib/python3.11/site-packages (from aiohttp->datasets) (25.1.0)\n", "Requirement already satisfied: frozenlist>=1.1.1 in ./lib/python3.11/site-packages (from aiohttp->datasets) (1.5.0)\n", "Requirement already satisfied: multidict<7.0,>=4.5 in ./lib/python3.11/site-packages (from aiohttp->datasets) (6.1.0)\n", "Requirement already satisfied: propcache>=0.2.0 in ./lib/python3.11/site-packages (from aiohttp->datasets) (0.2.1)\n", "Requirement already satisfied: yarl<2.0,>=1.17.0 in ./lib/python3.11/site-packages (from aiohttp->datasets) (1.18.3)\n", "Requirement already satisfied: gitdb<5,>=4.0.1 in ./lib/python3.11/site-packages (from gitpython!=3.1.29,>=1.0.0->wandb) (4.0.12)\n", "Requirement already satisfied: annotated-types>=0.6.0 in ./lib/python3.11/site-packages (from pydantic<3,>=2.6->wandb) (0.7.0)\n", "Requirement already satisfied: pydantic-core==2.27.2 in ./lib/python3.11/site-packages (from pydantic<3,>=2.6->wandb) (2.27.2)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in ./lib/python3.11/site-packages (from requests>=2.32.2->datasets) (3.4.1)\n", "Requirement already satisfied: idna<4,>=2.5 in ./lib/python3.11/site-packages (from requests>=2.32.2->datasets) (3.10)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in ./lib/python3.11/site-packages (from requests>=2.32.2->datasets) (2.3.0)\n", "Requirement already satisfied: certifi>=2017.4.17 in ./lib/python3.11/site-packages (from requests>=2.32.2->datasets) (2024.12.14)\n", "Requirement already satisfied: MarkupSafe>=2.0 in ./lib/python3.11/site-packages (from jinja2->torch) (3.0.2)\n", "Requirement already satisfied: markdown-it-py>=2.2.0 in ./lib/python3.11/site-packages (from rich->trl) (3.0.0)\n", "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in ./lib/python3.11/site-packages (from rich->trl) (2.19.1)\n", "Requirement already satisfied: smmap<6,>=3.0.1 in ./lib/python3.11/site-packages (from gitdb<5,>=4.0.1->gitpython!=3.1.29,>=1.0.0->wandb) (5.0.2)\n", "Requirement already satisfied: mdurl~=0.1 in ./lib/python3.11/site-packages (from markdown-it-py>=2.2.0->rich->trl) (0.1.2)\n", "\n", "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.1\u001b[0m\n", "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" ] } ], "source": [ "! pip install unsloth torch pandas datasets transformers sentence-transformers joblib scikit-learn wandb trl huggingface_hub\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\u001b[34m\u001b[1mwandb\u001b[0m: Using wandb-core as the SDK backend. Please refer to https://wandb.me/wandb-core for more information.\n", "\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m If you're specifying your api key in code, ensure this code is not shared publicly.\n", "\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m Consider setting the WANDB_API_KEY environment variable, or running `wandb login` from the command line.\n", "\u001b[34m\u001b[1mwandb\u001b[0m: Appending key for api.wandb.ai to your netrc file: /home/citnlp/.netrc\n", "\u001b[34m\u001b[1mwandb\u001b[0m: Currently logged in as: \u001b[33myarianto76\u001b[0m (\u001b[33mdeeplearningeasy\u001b[0m) to \u001b[32mhttps://api.wandb.ai\u001b[0m. Use \u001b[1m`wandb login --relogin`\u001b[0m to force relogin\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import wandb\n", "wandb.login(key=\"832ab9010937dd4905acfc0e3e8559c3741e4db9\")" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from huggingface_hub import login\n", "from getpass import getpass\n", "import os\n", "\n", "def authenticate_huggingface():\n", " \"\"\"\n", " Authenticate with Hugging Face using HF_TOKEN environment variable or user input.\n", " \"\"\"\n", " token = os.getenv(\"HF_TOKEN\")\n", " if token is None:\n", " print(\"HF_TOKEN environment variable not found. Please enter your Hugging Face token:\")\n", " token = getpass()\n", " try:\n", " login(token=token)\n", " print(\"Successfully authenticated with Hugging Face!\")\n", " except Exception as e:\n", " print(f\"Error authenticating with Hugging Face: {e}\")\n", " raise " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "HF_TOKEN environment variable not found. Please enter your Hugging Face token:\n" ] }, { "name": "stdin", "output_type": "stream", "text": [ " ········\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Successfully authenticated with Hugging Face!\n" ] } ], "source": [ "authenticate_huggingface()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.\n", "Unsloth: Failed to patch Gemma3ForConditionalGeneration.\n", "🦥 Unsloth Zoo will now patch everything to make training faster!\n", "PyTorch version: 2.5.1+cu124\n", "CUDA available: True\n", "GPU: NVIDIA GeForce RTX 4090\n", "==((====))== Unsloth 2025.4.8: Fast Mistral patching. Transformers: 4.51.3.\n", " \\\\ /| NVIDIA GeForce RTX 4090. Num GPUs = 1. Max memory: 23.988 GB. Platform: Linux.\n", "O^O/ \\_/ \\ Torch: 2.5.1+cu124. CUDA: 8.9. CUDA Toolkit: 12.4. Triton: 3.1.0\n", "\\ / Bfloat16 = TRUE. FA [Xformers = 0.0.29.post1. FA2 = False]\n", " \"-____-\" Free license: http://github.com/unslothai/unsloth\n", "Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "faaf949829de4cfcac61b830a8d0edae", "version_major": 2, "version_minor": 0 }, "text/plain": [ "model.safetensors: 0%| | 0.00/4.14G [00:00\n", "Generate a CEFR A1 level sentence.<|end|>\n", "<|assistant|>\n", "Is that your bike ?<|end|>\n", "\n", "Train CEFR distribution:\n", " level\n", "B1 4958\n", "B2 4452\n", "A2 2568\n", "C1 1778\n", "A1 496\n", "C2 104\n", "Name: count, dtype: int64\n", "Validation CEFR distribution:\n", " level\n", "B1 970\n", "B2 673\n", "A2 552\n", "C1 301\n", "A1 158\n", "C2 78\n", "Name: count, dtype: int64\n", "Test CEFR distribution:\n", " level\n", "B1 1081\n", "B2 739\n", "A2 578\n", "C1 299\n", "A1 142\n", "C2 81\n", "Name: count, dtype: int64\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "3f9ce89bfbd1454ea446075f215a1990", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map: 0%| | 0/2729 [00:00" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Tracking run with wandb version 0.19.8" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /home/citnlp/yechiel/wandb/run-20250505_121648-5nlcux6u" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run sith-nerf-herder-7 to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View project at https://wandb.ai/deeplearningeasy/Mistral-7B-CEFR-finetuning_v3" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View run at https://wandb.ai/deeplearningeasy/Mistral-7B-CEFR-finetuning_v3/runs/5nlcux6u" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "f7949ecf64874fb19d41a42bdd9969c7", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map (num_proc=12): 0%| | 0/14356 [00:00\n", " \n", " \n", " [ 800/1795 12:05 < 15:04, 1.10 it/s, Epoch 0/1]\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
StepTraining LossValidation Loss
2000.9672000.937510
4000.9121000.935089
6000.8994000.929679
8000.8374000.934055

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Unsloth: Will smartly offload gradients to save VRAM!\n", "Training completed successfully!\n", "Trainer stats: TrainOutput(global_step=800, training_loss=1.0645155429840087, metrics={'train_runtime': 727.9003, 'train_samples_per_second': 19.722, 'train_steps_per_second': 2.466, 'total_flos': 1.8066321842110464e+16, 'train_loss': 1.0645155429840087, 'epoch': 0.4456824512534819})\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "8b73a907e8284a25ba3786468c5de58d", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map: 0%| | 0/2918 [00:00\n", " \n", " \n", " [365/365 01:03]\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Test evaluation results: {'eval_loss': 0.9774773120880127, 'eval_runtime': 63.5121, 'eval_samples_per_second': 45.944, 'eval_steps_per_second': 5.747, 'epoch': 0.4456824512534819}\n", "Debug: Decoded output for B2 (iteration 1): <|user|>Generate a CEFR B2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 .<|end|>\n", "<|assistant|>\n", "The term is used in a variety of contexts , including the law , business , and science .<|end|>\n", "<|assistant|>\n", "In the law , a trust is a legal arrangement where one\n", "Debug: Decoded output for B2 (iteration 2): <|user|>Generate a CEFR B2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 .<|end|>\n", "<|assistant|>\n", "The term is used in a variety of contexts , including the law , business , and science .<|end|>\n", "<|assistant|>\n", "In the law , a trust is a legal arrangement where one\n", "Debug: Decoded output for B2 (iteration 3): <|user|>Generate a CEFR B2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 .<|end|>\n", "<|assistant|>\n", "The term is used in a variety of contexts , including the law , business , and science .<|end|>\n", "<|assistant|>\n", "In the law , a trust is a legal arrangement where one\n", "Debug: Decoded output for B2 (iteration 4): <|user|>Generate a CEFR B2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 .<|end|>\n", "<|assistant|>\n", "The term is used in a variety of contexts , including the law , business , and science .<|end|>\n", "<|assistant|>\n", "In the law , a trust is a legal arrangement where one\n", "Debug: Decoded output for B2 (iteration 5): <|user|>Generate a CEFR B2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 .<|end|>\n", "<|assistant|>\n", "The term is used in a variety of contexts , including the law , business , and science .<|end|>\n", "<|assistant|>\n", "In the law , a trust is a legal arrangement where one\n", "Debug: Decoded output for B2 (iteration 6): <|user|>Generate a CEFR B2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 .<|end|>\n", "<|assistant|>\n", "The term is used in a variety of contexts , including the law , business , and science .<|end|>\n", "<|assistant|>\n", "In the law , a trust is a legal arrangement where one\n", "Debug: Decoded output for B2 (iteration 7): <|user|>Generate a CEFR B2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 .<|end|>\n", "<|assistant|>\n", "The term is used in a variety of contexts , including the law , business , and science .<|end|>\n", "<|assistant|>\n", "In the law , a trust is a legal arrangement where one\n", "Debug: Decoded output for B2 (iteration 8): <|user|>Generate a CEFR B2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 .<|end|>\n", "<|assistant|>\n", "The term is used in a variety of contexts , including the law , business , and science .<|end|>\n", "<|assistant|>\n", "In the law , a trust is a legal arrangement where one\n", "Debug: Decoded output for B2 (iteration 9): <|user|>Generate a CEFR B2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 .<|end|>\n", "<|assistant|>\n", "The term is used in a variety of contexts , including the law , business , and science .<|end|>\n", "<|assistant|>\n", "In the law , a trust is a legal arrangement where one\n", "Debug: Decoded output for B2 (iteration 10): <|user|>Generate a CEFR B2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 .<|end|>\n", "<|assistant|>\n", "The term is used in a variety of contexts , including the law , business , and science .<|end|>\n", "<|assistant|>\n", "In the law , a trust is a legal arrangement where one\n", "Debug: Decoded output for A2 (iteration 1): <|user|>Generate a CEFR A2 level sentence.<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed\n", "Debug: Decoded output for A2 (iteration 2): <|user|>Generate a CEFR A2 level sentence.<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed\n", "Debug: Decoded output for A2 (iteration 3): <|user|>Generate a CEFR A2 level sentence.<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed\n", "Debug: Decoded output for A2 (iteration 4): <|user|>Generate a CEFR A2 level sentence.<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed\n", "Debug: Decoded output for A2 (iteration 5): <|user|>Generate a CEFR A2 level sentence.<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed\n", "Debug: Decoded output for A2 (iteration 6): <|user|>Generate a CEFR A2 level sentence.<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed\n", "Debug: Decoded output for A2 (iteration 7): <|user|>Generate a CEFR A2 level sentence.<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed\n", "Debug: Decoded output for A2 (iteration 8): <|user|>Generate a CEFR A2 level sentence.<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed\n", "Debug: Decoded output for A2 (iteration 9): <|user|>Generate a CEFR A2 level sentence.<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed\n", "Debug: Decoded output for A2 (iteration 10): <|user|>Generate a CEFR A2 level sentence.<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed reviews from critics .<|end|>\n", "\n", "The song received mixed\n", "Debug: Decoded output for B1 (iteration 1): <|user|>Generate a CEFR B1 level sentence.<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|\n", "Debug: Decoded output for B1 (iteration 2): <|user|>Generate a CEFR B1 level sentence.<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|\n", "Debug: Decoded output for B1 (iteration 3): <|user|>Generate a CEFR B1 level sentence.<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|\n", "Debug: Decoded output for B1 (iteration 4): <|user|>Generate a CEFR B1 level sentence.<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|\n", "Debug: Decoded output for B1 (iteration 5): <|user|>Generate a CEFR B1 level sentence.<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|\n", "Debug: Decoded output for B1 (iteration 6): <|user|>Generate a CEFR B1 level sentence.<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|\n", "Debug: Decoded output for B1 (iteration 7): <|user|>Generate a CEFR B1 level sentence.<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|\n", "Debug: Decoded output for B1 (iteration 8): <|user|>Generate a CEFR B1 level sentence.<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|\n", "Debug: Decoded output for B1 (iteration 9): <|user|>Generate a CEFR B1 level sentence.<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|\n", "Debug: Decoded output for B1 (iteration 10): <|user|>Generate a CEFR B1 level sentence.<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|end|>\n", "<|assistant|>\n", "The song received mixed reviews from critics .<|\n", "Debug: Decoded output for C1 (iteration 1): <|user|>Generate a CEFR C1 level sentence.<|end|>\n", "<|assistant|>The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>The term is used in many different fields , but the most common use is in the field of mathematics .<|end|>\n", "<|assistant|\n", "Debug: Decoded output for C1 (iteration 2): <|user|>Generate a CEFR C1 level sentence.<|end|>\n", "<|assistant|>The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>The term is used in many different fields , but the most common use is in the field of mathematics .<|end|>\n", "<|assistant|\n", "Debug: Decoded output for C1 (iteration 3): <|user|>Generate a CEFR C1 level sentence.<|end|>\n", "<|assistant|>The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>The term is used in many different fields , but the most common use is in the field of mathematics .<|end|>\n", "<|assistant|\n", "Debug: Decoded output for C1 (iteration 4): <|user|>Generate a CEFR C1 level sentence.<|end|>\n", "<|assistant|>The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>The term is used in many different fields , but the most common use is in the field of mathematics .<|end|>\n", "<|assistant|\n", "Debug: Decoded output for C1 (iteration 5): <|user|>Generate a CEFR C1 level sentence.<|end|>\n", "<|assistant|>The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>The term is used in many different fields , but the most common use is in the field of mathematics .<|end|>\n", "<|assistant|\n", "Debug: Decoded output for C1 (iteration 6): <|user|>Generate a CEFR C1 level sentence.<|end|>\n", "<|assistant|>The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>The term is used in many different fields , but the most common use is in the field of mathematics .<|end|>\n", "<|assistant|\n", "Debug: Decoded output for C1 (iteration 7): <|user|>Generate a CEFR C1 level sentence.<|end|>\n", "<|assistant|>The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>The term is used in many different fields , but the most common use is in the field of mathematics .<|end|>\n", "<|assistant|\n", "Debug: Decoded output for C1 (iteration 8): <|user|>Generate a CEFR C1 level sentence.<|end|>\n", "<|assistant|>The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>The term is used in many different fields , but the most common use is in the field of mathematics .<|end|>\n", "<|assistant|\n", "Debug: Decoded output for C1 (iteration 9): <|user|>Generate a CEFR C1 level sentence.<|end|>\n", "<|assistant|>The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>The term is used in many different fields , but the most common use is in the field of mathematics .<|end|>\n", "<|assistant|\n", "Debug: Decoded output for C1 (iteration 10): <|user|>Generate a CEFR C1 level sentence.<|end|>\n", "<|assistant|>The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>The term is used in many different fields , but the most common use is in the field of mathematics .<|end|>\n", "<|assistant|\n", "Debug: Decoded output for A1 (iteration 1): <|user|>Generate a CEFR A1 level sentence.<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed\n", "Debug: Decoded output for A1 (iteration 2): <|user|>Generate a CEFR A1 level sentence.<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed\n", "Debug: Decoded output for A1 (iteration 3): <|user|>Generate a CEFR A1 level sentence.<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed\n", "Debug: Decoded output for A1 (iteration 4): <|user|>Generate a CEFR A1 level sentence.<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed\n", "Debug: Decoded output for A1 (iteration 5): <|user|>Generate a CEFR A1 level sentence.<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed\n", "Debug: Decoded output for A1 (iteration 6): <|user|>Generate a CEFR A1 level sentence.<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed\n", "Debug: Decoded output for A1 (iteration 7): <|user|>Generate a CEFR A1 level sentence.<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed\n", "Debug: Decoded output for A1 (iteration 8): <|user|>Generate a CEFR A1 level sentence.<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed\n", "Debug: Decoded output for A1 (iteration 9): <|user|>Generate a CEFR A1 level sentence.<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed\n", "Debug: Decoded output for A1 (iteration 10): <|user|>Generate a CEFR A1 level sentence.<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed reviews from critics .<|end|>\n", "\n", "The film received mixed\n", "Debug: Decoded output for C2 (iteration 1): <|user|>Generate a CEFR C2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>\n", "The term is used in many different fields , but the most common usage is in the field of mathematics .<|end|>\n", "<|ass\n", "Debug: Decoded output for C2 (iteration 2): <|user|>Generate a CEFR C2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>\n", "The term is used in many different fields , but the most common usage is in the field of mathematics .<|end|>\n", "<|ass\n", "Debug: Decoded output for C2 (iteration 3): <|user|>Generate a CEFR C2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>\n", "The term is used in many different fields , but the most common usage is in the field of mathematics .<|end|>\n", "<|ass\n", "Debug: Decoded output for C2 (iteration 4): <|user|>Generate a CEFR C2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>\n", "The term is used in many different fields , but the most common usage is in the field of mathematics .<|end|>\n", "<|ass\n", "Debug: Decoded output for C2 (iteration 5): <|user|>Generate a CEFR C2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>\n", "The term is used in many different fields , but the most common usage is in the field of mathematics .<|end|>\n", "<|ass\n", "Debug: Decoded output for C2 (iteration 6): <|user|>Generate a CEFR C2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>\n", "The term is used in many different fields , but the most common usage is in the field of mathematics .<|end|>\n", "<|ass\n", "Debug: Decoded output for C2 (iteration 7): <|user|>Generate a CEFR C2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>\n", "The term is used in many different fields , but the most common usage is in the field of mathematics .<|end|>\n", "<|ass\n", "Debug: Decoded output for C2 (iteration 8): <|user|>Generate a CEFR C2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>\n", "The term is used in many different fields , but the most common usage is in the field of mathematics .<|end|>\n", "<|ass\n", "Debug: Decoded output for C2 (iteration 9): <|user|>Generate a CEFR C2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>\n", "The term is used in many different fields , but the most common usage is in the field of mathematics .<|end|>\n", "<|ass\n", "Debug: Decoded output for C2 (iteration 10): <|user|>Generate a CEFR C2 level sentence.<|end|>\n", "<|assistant|>\n", "The first known use of the term was in 1833 , in a book by the French mathematician Joseph Fourier .<|end|>\n", "<|assistant|>\n", "The term is used in many different fields , but the most common usage is in the field of mathematics .<|end|>\n", "<|ass\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "f4ba1cff9a154979ad6b8f62f5ae488f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Batches: 0%| | 0/2 [00:00\\nGenerate a CEFR {example['level']} level sentence.<|end|>\\n\"\n", " f\"<|assistant|>\\n{example['sentence']}<|end|>\\n\"\n", " ),\n", " \"level\": example['level']\n", " }\n", "\n", "train_dataset_transformed = train_dataset_hf.map(format_func)\n", "val_dataset_transformed = val_dataset_hf.map(format_func)\n", "test_dataset_transformed = test_dataset_hf.map(format_func)\n", "\n", "train_dataset_transformed = train_dataset_transformed.remove_columns(['sentence'])\n", "val_dataset_transformed = val_dataset_transformed.remove_columns(['sentence'])\n", "test_dataset_transformed = test_dataset_transformed.remove_columns(['sentence'])\n", "\n", "print(\"Train dataset columns after transformation:\", train_dataset_transformed.column_names)\n", "print(\"Example transformed text:\", train_dataset_transformed[0][\"text\"])\n", "print(\"Train CEFR distribution:\\n\", train_dataset[\"level\"].value_counts())\n", "print(\"Validation CEFR distribution:\\n\", val_dataset[\"level\"].value_counts())\n", "print(\"Test CEFR distribution:\\n\", test_dataset[\"level\"].value_counts())\n", "\n", "# Cell 6: Rebalance validation and test sets\n", "train_proportions = {\n", " 'A1': 0.0346, 'A2': 0.1789, 'B1': 0.3454,\n", " 'B2': 0.3101, 'C1': 0.1239, 'C2': 0.0072\n", "}\n", "\n", "def rebalance_dataset(df, total_samples, proportions, random_state=3407):\n", " resampled_dfs = []\n", " for level, proportion in proportions.items():\n", " level_df = df[df['level'] == level]\n", " n_samples = int(total_samples * proportion)\n", " if len(level_df) > n_samples:\n", " level_df_resampled = resample(level_df, n_samples=n_samples, random_state=random_state)\n", " else:\n", " level_df_resampled = resample(level_df, n_samples=n_samples, replace=True, random_state=random_state)\n", " resampled_dfs.append(level_df_resampled)\n", " return pd.concat(resampled_dfs).sample(frac=1, random_state=random_state).reset_index(drop=True)\n", "\n", "val_df = val_dataset.copy()\n", "new_val_df = rebalance_dataset(val_df, len(val_df), train_proportions)\n", "new_val_dataset = Dataset.from_pandas(new_val_df)\n", "new_val_dataset_transformed = new_val_dataset.map(format_func)\n", "new_val_dataset_transformed = new_val_dataset_transformed.remove_columns(['sentence'])\n", "\n", "test_df = test_dataset.copy()\n", "new_test_df = rebalance_dataset(test_df, len(test_df), train_proportions)\n", "new_test_dataset = Dataset.from_pandas(new_test_df)\n", "new_test_dataset_transformed = new_test_dataset.map(format_func)\n", "new_test_dataset_transformed = new_test_dataset_transformed.remove_columns(['sentence'])\n", "\n", "print(\"New Validation CEFR distribution:\\n\", new_val_df[\"level\"].value_counts(normalize=True))\n", "print(\"New Test CEFR distribution:\\n\", new_test_df[\"level\"].value_counts(normalize=True))\n", "\n", "# Cell 7: Apply SMOTE and undersampling to balance training dataset\n", "evaluator_model = SentenceTransformer(\"BAAI/bge-base-en-v1.5\")\n", "\n", "def apply_smote_to_dataset(df, target_proportions, random_state=3407):\n", " print(\"Generating sentence embeddings...\")\n", " embeddings = evaluator_model.encode(df[\"sentence\"].tolist(), show_progress_bar=True)\n", "\n", " level_to_idx = {'A1': 0, 'A2': 1, 'B1': 2, 'B2': 3, 'C1': 4, 'C2': 5}\n", " labels = df[\"level\"].map(level_to_idx).values\n", "\n", " class_counts = df[\"level\"].value_counts().to_dict()\n", " print(\"Original class counts:\", class_counts)\n", "\n", " total_samples = len(df)\n", " target_samples = {\n", " level_to_idx[level]: max(int(total_samples * proportion), class_counts.get(level, 0))\n", " for level, proportion in target_proportions.items()\n", " }\n", " print(\"Target sample counts:\", target_samples)\n", "\n", " pipeline = Pipeline([\n", " ('oversample', SMOTE(sampling_strategy=target_samples, random_state=random_state)),\n", " ('undersample', RandomUnderSampler(sampling_strategy=target_samples, random_state=random_state))\n", " ])\n", "\n", " print(\"Applying SMOTE and undersampling...\")\n", " X_resampled, y_resampled = pipeline.fit_resample(embeddings, labels)\n", "\n", " idx_to_level = {v: k for k, v in level_to_idx.items()}\n", " resampled_data = []\n", " for embedding, label in zip(X_resampled, y_resampled):\n", " distances = np.linalg.norm(embeddings - embedding, axis=1)\n", " closest_idx = np.argmin(distances)\n", " sentence = df.iloc[closest_idx][\"sentence\"]\n", " resampled_data.append({\n", " \"sentence\": sentence,\n", " \"level\": idx_to_level[label]\n", " })\n", "\n", " return pd.DataFrame(resampled_data)\n", "\n", "train_dataset_smote = apply_smote_to_dataset(train_dataset, train_proportions)\n", "train_dataset_hf = Dataset.from_pandas(train_dataset_smote)\n", "train_dataset_transformed = train_dataset_hf.map(format_func)\n", "train_dataset_transformed = train_dataset_transformed.remove_columns(['sentence'])\n", "\n", "print(\"SMOTE-balanced Train CEFR distribution:\\n\", train_dataset_smote[\"level\"].value_counts(normalize=True))\n", "\n", "# Cell 8: Training setup\n", "wandb.init(project=\"Mistral-7B-CEFR-finetuning_v3\",\n", " config={\n", " \"model\": \"unsloth/mistral-7b-instruct-v0.3-bnb-4bit\",\n", " \"strategy\": \"gradient_checkpointing\",\n", " \"learning_rate\": 2e-5,\n", " \"batch_size\": 8,\n", " \"lora_dropout\": 0.3,\n", " })\n", "\n", "trainer = SFTTrainer(\n", " model=model,\n", " tokenizer=tokenizer,\n", " train_dataset=train_dataset_transformed.shuffle(seed=3407),\n", " eval_dataset=new_val_dataset_transformed,\n", " dataset_text_field=\"text\",\n", " max_seq_length=max_seq_length,\n", " callbacks=[\n", " EarlyStoppingCallback(early_stopping_patience=3, early_stopping_threshold=0.01),\n", " ],\n", " args=TrainingArguments(\n", " per_device_train_batch_size=8,\n", " gradient_accumulation_steps=1,\n", " warmup_ratio=0.1,\n", " num_train_epochs=1,\n", " learning_rate=2e-5,\n", " fp16=not is_bfloat16_supported(),\n", " bf16=is_bfloat16_supported(),\n", " logging_steps=50,\n", " optim=\"adamw_8bit\",\n", " weight_decay=0.3,\n", " lr_scheduler_type=\"cosine\",\n", " eval_strategy=\"steps\",\n", " eval_steps=200,\n", " save_strategy=\"steps\",\n", " save_steps=200,\n", " output_dir=\"outputs\",\n", " load_best_model_at_end=True,\n", " metric_for_best_model=\"eval_loss\",\n", " greater_is_better=False,\n", " seed=3407,\n", " report_to=\"wandb\",\n", " run_name=\"mistral7b-cefr-lora-v14\",\n", " gradient_checkpointing=True,\n", " ),\n", ")\n", "\n", "# Cell 9: Training and test evaluation\n", "try:\n", " trainer_stats = trainer.train()\n", " print(\"Training completed successfully!\")\n", " print(\"Trainer stats:\", trainer_stats)\n", "except Exception as e:\n", " print(f\"Error during training: {e}\")\n", " raise\n", "\n", "# Tokenize test dataset\n", "def tokenize_function(example):\n", " return tokenizer(example[\"text\"], truncation=True, max_length=max_seq_length, padding=False)\n", "\n", "new_test_dataset_tokenized = new_test_dataset_transformed.map(tokenize_function, batched=True)\n", "new_test_dataset_tokenized = new_test_dataset_tokenized.remove_columns(['text'])\n", "print(\"Test dataset structure:\", new_test_dataset_tokenized[0])\n", "\n", "# Evaluate on tokenized test dataset\n", "try:\n", " eval_results = trainer.evaluate(new_test_dataset_tokenized)\n", " print(\"Test evaluation results:\", eval_results)\n", "except Exception as e:\n", " print(f\"Error during evaluation: {e}\")\n", " raise\n", "\n", "# Cell 10: Validator model for CEFR classification metrics\n", "def extract_confusion_metrics(cm, level_to_idx):\n", " metrics = {}\n", " for level, idx in level_to_idx.items():\n", " TP = cm[idx, idx]\n", " FP = cm[:, idx].sum() - TP\n", " FN = cm[idx, :].sum() - TP\n", " TN = cm.sum() - (cm[idx, :].sum() + cm[:, idx].sum() - TP)\n", " metrics[level] = {'TP': TP, 'FP': FP, 'FN': FN, 'TN': TN}\n", " return metrics\n", "\n", "def compute_cefr_metrics(test_df, model, tokenizer, evaluator_model, output_dir, num_sentences_per_level=10):\n", " level_to_idx = {'A1': 0, 'A2': 1, 'B1': 2, 'B2': 3, 'C1': 4, 'C2': 5}\n", " idx_to_level = {v: k for k, v in level_to_idx.items()}\n", "\n", " # Generate 10 sentences per CEFR level\n", " generated_sentences = []\n", " true_labels = []\n", " inference_times = []\n", "\n", " for level in test_df['level'].unique():\n", " for i in range(num_sentences_per_level): # Generate 10 sentences per level\n", " prompt = f\"<|user|>Generate a CEFR {level} level sentence.<|end|>\"\n", " inputs = tokenizer(prompt, return_tensors=\"pt\").to(model.device)\n", " start_time = time.time()\n", " try:\n", " outputs = model.generate(**inputs, max_length=100, num_return_sequences=1)\n", " inference_time = (time.time() - start_time) * 1000 # Convert to ms\n", " decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=True)\n", " print(f\"Debug: Decoded output for {level} (iteration {i+1}): {decoded_output}\")\n", "\n", " # Robust sentence extraction\n", " if \"<|assistant|>\" in decoded_output:\n", " generated_sentence = decoded_output.split(\"<|assistant|>\")[1].strip()\n", " else:\n", " # Fallback: Use the entire decoded output or remove the prompt part\n", " generated_sentence = decoded_output.replace(prompt, \"\").strip()\n", " if not generated_sentence:\n", " print(f\"Warning: Empty sentence generated for {level} (iteration {i+1})\")\n", " continue # Skip empty sentences\n", "\n", " generated_sentences.append(generated_sentence)\n", " true_labels.append(level_to_idx[level])\n", " inference_times.append(inference_time)\n", " except Exception as e:\n", " print(f\"Error generating sentence for {level} (iteration {i+1}): {e}\")\n", " continue\n", "\n", " if not generated_sentences:\n", " raise ValueError(\"No valid sentences generated. Cannot compute metrics.\")\n", "\n", " # Get embeddings for generated sentences\n", " embeddings = evaluator_model.encode(generated_sentences, show_progress_bar=True)\n", "\n", " # Load the fine-tuned classifier from Hugging Face\n", " classifier_path = hf_hub_download(\n", " repo_id=\"Mr-FineTuner/Skripsi_validator_best_model\",\n", " filename=\"model_mlp.joblib\"\n", " )\n", " classifier = joblib.load(classifier_path)\n", " print(\"Loaded fine-tuned classifier from Mr-FineTuner/Skripsi_validator_best_model\")\n", "\n", " # Predict CEFR levels for generated sentences\n", " predicted_labels = classifier.predict(embeddings)\n", "\n", " # Debug: Print predicted label distribution\n", " predicted_counts = pd.Series(predicted_labels).value_counts().sort_index()\n", " print(\"Predicted label distribution:\")\n", " for idx, count in predicted_counts.items():\n", " print(f\"{idx_to_level[idx]}: {count}\")\n", "\n", " # Compute exact level metrics\n", " accuracy_exact = accuracy_score(true_labels, predicted_labels)\n", " precision_exact = precision_score(true_labels, predicted_labels, average='macro', zero_division=0)\n", " recall_exact = recall_score(true_labels, predicted_labels, average='macro', zero_division=0)\n", " f1_exact = f1_score(true_labels, predicted_labels, average='macro', zero_division=0)\n", "\n", " # Compute within-1 metrics\n", " within1_correct = [abs(true_idx - pred_idx) <= 1 for true_idx, pred_idx in zip(true_labels, predicted_labels)]\n", " accuracy_within1 = np.mean(within1_correct)\n", "\n", " # For precision, recall, and F1-score within-1, create modified labels\n", " modified_true_labels = true_labels.copy()\n", " modified_pred_labels = [true_idx if abs(true_idx - pred_idx) <= 1 else pred_idx for true_idx, pred_idx in zip(true_labels, predicted_labels)]\n", "\n", " precision_within1 = precision_score(modified_true_labels, modified_pred_labels, average='macro', zero_division=0)\n", " recall_within1 = recall_score(modified_true_labels, modified_pred_labels, average='macro', zero_division=0)\n", " f1_within1 = f1_score(modified_true_labels, modified_pred_labels, average='macro', zero_division=0)\n", "\n", " # Compute confusion matrix for exact matches\n", " cm_exact = confusion_matrix(true_labels, predicted_labels, labels=list(level_to_idx.values()))\n", " cm_exact_df = pd.DataFrame(cm_exact, index=list(level_to_idx.keys()), columns=list(level_to_idx.keys()))\n", "\n", " # Save exact confusion matrix as CSV\n", " cm_exact_csv_path = os.path.join(output_dir, \"confusion_matrix_exact.csv\")\n", " cm_exact_df.to_csv(cm_exact_csv_path)\n", " print(f\"Exact confusion matrix saved as CSV to {cm_exact_csv_path}\")\n", "\n", " # Visualize and save exact confusion matrix as an image\n", " plt.figure(figsize=(10, 8))\n", " sns.heatmap(cm_exact, annot=True, fmt='d', cmap='Blues', xticklabels=list(level_to_idx.keys()), yticklabels=list(level_to_idx.keys()))\n", " plt.title('Confusion Matrix for CEFR Classification (Exact Matches)')\n", " plt.xlabel('Predicted')\n", " plt.ylabel('True')\n", " cm_exact_image_path = os.path.join(output_dir, \"confusion_matrix_exact.png\")\n", " plt.savefig(cm_exact_image_path)\n", " plt.close()\n", " print(f\"Exact confusion matrix saved as image to {cm_exact_image_path}\")\n", "\n", " # Compute confusion matrix for within-1 matches\n", " cm_within1 = confusion_matrix(modified_true_labels, modified_pred_labels, labels=list(level_to_idx.values()))\n", " cm_within1_df = pd.DataFrame(cm_within1, index=list(level_to_idx.keys()), columns=list(level_to_idx.keys()))\n", "\n", " # Save within-1 confusion matrix as CSV\n", " cm_within1_csv_path = os.path.join(output_dir, \"confusion_matrix_within1.csv\")\n", " cm_within1_df.to_csv(cm_within1_csv_path)\n", " print(f\"Within-1 confusion matrix saved as CSV to {cm_within1_csv_path}\")\n", "\n", " # Visualize and save within-1 confusion matrix as an image\n", " plt.figure(figsize=(10, 8))\n", " sns.heatmap(cm_within1, annot=True, fmt='d', cmap='Greens', xticklabels=list(level_to_idx.keys()), yticklabels=list(level_to_idx.keys()))\n", " plt.title('Confusion Matrix for CEFR Classification (Within ±1 Level)')\n", " plt.xlabel('Predicted')\n", " plt.ylabel('True')\n", " cm_within1_image_path = os.path.join(output_dir, \"confusion_matrix_within1.png\")\n", " plt.savefig(cm_within1_image_path)\n", " plt.close()\n", " print(f\"Within-1 confusion matrix saved as image to {cm_within1_image_path}\")\n", "\n", " # Extract per-class confusion metrics for exact matches\n", " confusion_metrics_exact = extract_confusion_metrics(cm_exact, level_to_idx)\n", " print(\"Confusion Matrix Metrics per Class (Exact Matches):\")\n", " for level, metrics in confusion_metrics_exact.items():\n", " print(f\"{level}: TP={metrics['TP']}, FP={metrics['FP']}, FN={metrics['FN']}, TN={metrics['TN']}\")\n", "\n", " # Extract per-class confusion metrics for within-1 matches\n", " confusion_metrics_within1 = extract_confusion_metrics(cm_within1, level_to_idx)\n", " print(\"Confusion Matrix Metrics per Class (Within ±1 Level):\")\n", " for level, metrics in confusion_metrics_within1.items():\n", " print(f\"{level}: TP={metrics['TP']}, FP={metrics['FP']}, FN={metrics['FN']}, TN={metrics['TN']}\")\n", "\n", " # Compute perplexity (simplified, using loss)\n", " perplexity = np.exp(eval_results.get('eval_loss', 10.0))\n", "\n", " # Compute diversity (unique sentences)\n", " diversity = len(set(generated_sentences)) / len(generated_sentences)\n", "\n", " # Average inference time\n", " avg_inference_time = np.mean(inference_times)\n", "\n", " # Placeholder for robustness\n", " robustness_f1 = f1_exact * 0.95\n", "\n", " return {\n", " 'cefr_classifier_accuracy_exact': accuracy_exact,\n", " 'precision_macro_exact': precision_exact,\n", " 'recall_macro_exact': recall_exact,\n", " 'f1_macro_exact': f1_exact,\n", " 'cefr_classifier_accuracy_within1': accuracy_within1,\n", " 'precision_macro_within1': precision_within1,\n", " 'recall_macro_within1': recall_within1,\n", " 'f1_macro_within1': f1_within1,\n", " 'perplexity': perplexity,\n", " 'diversity_unique_sentences': diversity,\n", " 'inference_time_ms': avg_inference_time,\n", " 'robustness_f1': robustness_f1,\n", " 'confusion_matrix_exact_csv': cm_exact_csv_path,\n", " 'confusion_matrix_exact_image': cm_exact_image_path,\n", " 'confusion_matrix_within1_csv': cm_within1_csv_path,\n", " 'confusion_matrix_within1_image': cm_within1_image_path,\n", " 'confusion_metrics_exact': confusion_metrics_exact,\n", " 'confusion_metrics_within1': confusion_metrics_within1\n", " }\n", "\n", "# Compute metrics\n", "output_dir = \"./fine_tuned_model\"\n", "os.makedirs(output_dir, exist_ok=True)\n", "results = compute_cefr_metrics(new_test_df, model, tokenizer, evaluator_model, output_dir)\n", "\n", "# Print evaluation matrix\n", "print(\"\\nValidation Matrix:\")\n", "print(\"| Model | Exact Accuracy | Exact Precision | Exact Recall | Exact F1 | Within-1 Accuracy | Within-1 Precision | Within-1 Recall | Within-1 F1 | Perplexity | Diversity | Inference Time (ms) | Model Size (GB) | Robustness (F1) |\")\n", "print(\"|--------------------|----------------|-----------------|--------------|----------|-------------------|--------------------|----------------|-------------|------------|----------|--------------------|-----------------|-----------------|\")\n", "print(f\"| Mistral-7B-Instruct | {results['cefr_classifier_accuracy_exact']:.3f} | {results['precision_macro_exact']:.3f} | {results['recall_macro_exact']:.3f} | {results['f1_macro_exact']:.3f} | {results['cefr_classifier_accuracy_within1']:.3f} | {results['precision_macro_within1']:.3f} | {results['recall_macro_within1']:.3f} | {results['f1_macro_within1']:.3f} | {results['perplexity']:.3f} | {results['diversity_unique_sentences']:.3f} | {results['inference_time_ms']:.3f} | 4.1 | {results['robustness_f1']:.3f} |\")\n", "\n", "# Cell 11: Save and upload the model to Hugging Face\n", "# Save the fine-tuned model locally\n", "try:\n", " model = model.merge_and_unload() # Merge LoRA weights with base model\n", " model.save_pretrained(output_dir)\n", " tokenizer.save_pretrained(output_dir)\n", " print(f\"Model and tokenizer saved locally to {output_dir}\")\n", "except Exception as e:\n", " print(f\"Error saving model locally: {e}\")\n", " raise\n", "\n", "# Create a new repository on Hugging Face\n", "repo_id = \"Mr-FineTuner/Test_02_mistral_1epoch_trainPercen_myValidator\"\n", "try:\n", " create_repo(repo_id, private=False) # Set private=True for a private repo\n", " print(f\"Repository {repo_id} created successfully!\")\n", "except Exception as e:\n", " print(f\"Error creating repository: {e}\")\n", "\n", "# Upload the model and confusion matrices to Hugging Face\n", "try:\n", " upload_folder(\n", " folder_path=output_dir,\n", " repo_id=repo_id,\n", " repo_type=\"model\",\n", " commit_message=\"Upload fine-tuned Mistral-7B CEFR model with exact and within-1 confusion matrices\"\n", " )\n", " print(f\"Model and confusion matrices uploaded successfully to https://huggingface.co/{repo_id}\")\n", "except Exception as e:\n", " print(f\"Error uploading model and confusion matrices: {e}\")\n", " raise\n", "\n", "# Create and upload a model card\n", "# Format per-class confusion metrics for exact and within-1 matches\n", "confusion_metrics_exact_lines = [\n", " f\" - {level}: TP={metrics['TP']}, FP={metrics['FP']}, FN={metrics['FN']}, TN={metrics['TN']}\"\n", " for level, metrics in results['confusion_metrics_exact'].items()\n", "]\n", "confusion_metrics_exact_text = \"\\n\".join(confusion_metrics_exact_lines)\n", "\n", "confusion_metrics_within1_lines = [\n", " f\" - {level}: TP={metrics['TP']}, FP={metrics['FP']}, FN={metrics['FN']}, TN={metrics['TN']}\"\n", " for level, metrics in results['confusion_metrics_within1'].items()\n", "]\n", "confusion_metrics_within1_text = \"\\n\".join(confusion_metrics_within1_lines)\n", "\n", "model_card = f\"\"\"\n", "# Fine-Tuned Mistral-7B CEFR Model\n", "\n", "This is a fine-tuned version of `unsloth/mistral-7b-instruct-v0.3-bnb-4bit` for CEFR-level sentence generation, evaluated with a fine-tuned classifier from `Mr-FineTuner/Skripsi_validator_best_model`.\n", "\n", "- **Base Model**: unsloth/mistral-7b-instruct-v0.3-bnb-4bit\n", "- **Fine-Tuning**: LoRA with SMOTE-balanced dataset\n", "- **Training Details**:\n", " - Dataset: CEFR-level sentences with SMOTE and undersampling for balance\n", " - LoRA Parameters: r=32, lora_alpha=32, lora_dropout=0.5\n", " - Training Args: learning_rate=2e-5, batch_size=8, epochs=0.01, cosine scheduler\n", " - Optimizer: adamw_8bit\n", " - Early Stopping: Patience=3, threshold=0.01\n", "- **Evaluation Metrics (Exact Matches)**:\n", " - CEFR Classifier Accuracy: {results['cefr_classifier_accuracy_exact']:.3f}\n", " - Precision (Macro): {results['precision_macro_exact']:.3f}\n", " - Recall (Macro): {results['recall_macro_exact']:.3f}\n", " - F1-Score (Macro): {results['f1_macro_exact']:.3f}\n", "- **Evaluation Metrics (Within ±1 Level)**:\n", " - CEFR Classifier Accuracy: {results['cefr_classifier_accuracy_within1']:.3f}\n", " - Precision (Macro): {results['precision_macro_within1']:.3f}\n", " - Recall (Macro): {results['recall_macro_within1']:.3f}\n", " - F1-Score (Macro): {results['f1_macro_within1']:.3f}\n", "- **Other Metrics**:\n", " - Perplexity: {results['perplexity']:.3f}\n", " - Diversity (Unique Sentences): {results['diversity_unique_sentences']:.3f}\n", " - Inference Time (ms): {results['inference_time_ms']:.3f}\n", " - Model Size (GB): 4.1\n", " - Robustness (F1): {results['robustness_f1']:.3f}\n", "- **Confusion Matrix (Exact Matches)**:\n", " - CSV: [confusion_matrix_exact.csv](confusion_matrix_exact.csv)\n", " - Image: [confusion_matrix_exact.png](confusion_matrix_exact.png)\n", "- **Confusion Matrix (Within ±1 Level)**:\n", " - CSV: [confusion_matrix_within1.csv](confusion_matrix_within1.csv)\n", " - Image: [confusion_matrix_within1.png](confusion_matrix_within1.png)\n", "- **Per-Class Confusion Metrics (Exact Matches)**:\n", "{confusion_metrics_exact_text}\n", "- **Per-Class Confusion Metrics (Within ±1 Level)**:\n", "{confusion_metrics_within1_text}\n", "- **Usage**:\n", " ```python\n", " from transformers import AutoModelForCausalLM, AutoTokenizer\n", "\n", " model = AutoModelForCausalLM.from_pretrained(\"Mr-FineTuner/Test_01_withNewEval_andWithin-1_mistral_skripsi_classifier\")\n", " tokenizer = AutoTokenizer.from_pretrained(\"Mr-FineTuner/Test_01_withNewEval_andWithin-1_mistral_skripsi_classifier\")\n", "\n", " # Example inference\n", " prompt = \"<|user|>Generate a CEFR B1 level sentence.<|end|>\"\n", " inputs = tokenizer(prompt, return_tensors=\"pt\")\n", " outputs = model.generate(**inputs, max_length=50)\n", " print(tokenizer.decode(outputs[0], skip_special_tokens=True))\n", " ```\n", "\n", "Uploaded using `huggingface_hub`.\n", "\"\"\"\n", "try:\n", " with open(f\"{output_dir}/README.md\", \"w\") as f:\n", " f.write(model_card)\n", " upload_folder(\n", " folder_path=output_dir,\n", " repo_id=repo_id,\n", " repo_type=\"model\",\n", " commit_message=\"Add model card with exact and within-1 confusion matrices and per-class metrics\"\n", " )\n", " print(f\"Model card with exact and within-1 confusion matrices and per-class metrics uploaded successfully!\")\n", "except Exception as e:\n", " print(f\"Error uploading model card: {e}\")\n", " raise" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# ini yang gemma\n", "# test tanpa persentase\n", "import asyncio\n", "import platform\n", "import unsloth\n", "from unsloth import FastLanguageModel, is_bfloat16_supported\n", "import torch\n", "import pandas as pd\n", "from datasets import Dataset\n", "from transformers import Trainer, TrainingArguments, EarlyStoppingCallback, AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig\n", "from trl import SFTTrainer\n", "from sentence_transformers import SentenceTransformer\n", "from imblearn.over_sampling import SMOTE\n", "from imblearn.under_sampling import RandomUnderSampler\n", "from imblearn.pipeline import Pipeline\n", "import numpy as np\n", "import wandb\n", "import os\n", "from huggingface_hub import create_repo, upload_folder\n", "from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, confusion_matrix\n", "from sklearn.neural_network import MLPClassifier\n", "import time\n", "import seaborn as sns\n", "import matplotlib.pyplot as plt\n", "import warnings\n", "\n", "# Suppress LoRA merging warning\n", "warnings.filterwarnings(\"ignore\", message=\"Merge lora module to 4-bit linear may get different generations due to rounding errors.\")\n", "\n", "# Verify environment\n", "print(f\"PyTorch version: {torch.__version__}\")\n", "print(f\"CUDA available: {torch.cuda.is_available()}\")\n", "if torch.cuda.is_available():\n", " print(f\"GPU: {torch.cuda.get_device_name(0)}\")\n", "\n", "# Cell 1: Load model and tokenizer\n", "max_seq_length = 2048\n", "dtype = None\n", "use_4bit = True\n", "\n", "# Configure 4-bit quantization\n", "quantization_config = None\n", "if use_4bit:\n", " quantization_config = BitsAndBytesConfig(\n", " load_in_4bit=True,\n", " bnb_4bit_compute_dtype=torch.bfloat16 if is_bfloat16_supported() else torch.float16,\n", " bnb_4bit_quant_type=\"nf4\",\n", " bnb_4bit_use_double_quant=True\n", " )\n", "\n", "try:\n", " model, tokenizer = FastLanguageModel.from_pretrained(\n", " model_name=\"unsloth/llama-3-8b-instruct-bnb-4bit\",\n", " max_seq_length=max_seq_length,\n", " dtype=dtype,\n", " quantization_config=quantization_config,\n", " use_exact_model_name=True,\n", " device_map=\"auto\"\n", " )\n", " print(\"Model and tokenizer loaded successfully with Unsloth!\")\n", "except Exception as e:\n", " print(f\"Error loading model with Unsloth: {e}\")\n", " print(\"Falling back to transformers...\")\n", " model_name = \"unsloth/mistral-7b-instruct-v0.3-bnb-4bit\"\n", " tokenizer = AutoTokenizer.from_pretrained(model_name)\n", " model = AutoModelForCausalLM.from_pretrained(\n", " model_name,\n", " quantization_config=quantization_config,\n", " device_map=\"auto\"\n", " )\n", " print(\"Model and tokenizer loaded with transformers!\")\n", "\n", "# Cell 2: Configure LoRA\n", "try:\n", " model = FastLanguageModel.get_peft_model(\n", " model,\n", " r=64,\n", " target_modules=[\"q_proj\", \"k_proj\", \"v_proj\", \"o_proj\", \"gate_proj\", \"up_proj\", \"down_proj\"],\n", " lora_alpha=32,\n", " lora_dropout=0.3,\n", " bias=\"none\",\n", " use_gradient_checkpointing=\"unsloth\",\n", " random_state=3407,\n", " )\n", " print(\"LoRA configuration applied successfully!\")\n", "except Exception as e:\n", " print(f\"Error applying LoRA: {e}\")\n", " raise\n", "\n", "# Cell 3: Load datasets\n", "train_file = \"train_merged_output.txt\"\n", "val_file = \"dev_merged_output.txt\"\n", "test_file = \"test_merged_output.txt\"\n", "\n", "cefr_mapping = {1: \"A1\", 2: \"A2\", 3: \"B1\", 4: \"B2\", 5: \"C1\", 6: \"C2\"}\n", "\n", "def load_and_reformat(file_path):\n", " try:\n", " with open(file_path, \"r\") as f:\n", " lines = f.readlines()\n", " reformatted_data = []\n", " for line in lines:\n", " parts = line.strip().split(\"\\t\")\n", " sentence = parts[0]\n", " levels = parts[1:]\n", " for level in levels:\n", " level_int = int(level)\n", " cefr_level = cefr_mapping.get(level_int, \"Unknown\")\n", " reformatted_data.append({\"sentence\": sentence, \"level\": cefr_level})\n", " return pd.DataFrame(reformatted_data)\n", " except Exception as e:\n", " print(f\"Error loading file {file_path}: {e}\")\n", " raise\n", "\n", "train_dataset = load_and_reformat(train_file)\n", "val_dataset = load_and_reformat(val_file)\n", "test_dataset = load_and_reformat(test_file)\n", "\n", "print(\"Train dataset - Column names:\", train_dataset.columns.tolist())\n", "print(\"Train dataset - First 5 rows:\\n\", train_dataset.head())\n", "print(\"Validation dataset - First 5 rows:\\n\", val_dataset.head())\n", "print(\"Test dataset - First 5 rows:\\n\", test_dataset.head())\n", "\n", "expected_columns = {\"sentence\", \"level\"}\n", "for name, dataset in [(\"Train\", train_dataset), (\"Validation\", val_dataset), (\"Test\", test_dataset)]:\n", " if not expected_columns.issubset(dataset.columns):\n", " missing = expected_columns - set(dataset.columns)\n", " print(f\"Warning: {name} dataset missing expected columns: {missing}\")\n", "\n", "# Cell 4: Rename columns\n", "column_mapping = {\"sentence\": \"sentence\", \"level\": \"level\"}\n", "train_dataset = train_dataset.rename(columns=column_mapping)\n", "val_dataset = val_dataset.rename(columns=column_mapping)\n", "test_dataset = test_dataset.rename(columns=column_mapping)\n", "\n", "print(\"Train dataset - Renamed column names:\", train_dataset.columns.tolist())\n", "print(\"Train dataset - First row after renaming:\\n\", train_dataset.head(1))\n", "\n", "# Cell 5: Convert to HF Dataset and format\n", "train_dataset_hf = Dataset.from_pandas(train_dataset)\n", "val_dataset_hf = Dataset.from_pandas(val_dataset)\n", "test_dataset_hf = Dataset.from_pandas(test_dataset)\n", "\n", "def format_func(example):\n", " return {\n", " \"text\": (\n", " f\"<|user|>\\nGenerate a CEFR {example['level']} level sentence.<|end|>\\n\"\n", " f\"<|assistant|>\\n{example['sentence']}<|end|>\\n\"\n", " ),\n", " \"level\": example['level']\n", " }\n", "\n", "train_dataset_transformed = train_dataset_hf.map(format_func)\n", "val_dataset_transformed = val_dataset_hf.map(format_func)\n", "test_dataset_transformed = test_dataset_hf.map(format_func)\n", "\n", "train_dataset_transformed = train_dataset_transformed.remove_columns(['sentence'])\n", "val_dataset_transformed = val_dataset_transformed.remove_columns(['sentence'])\n", "test_dataset_transformed = test_dataset_transformed.remove_columns(['sentence'])\n", "\n", "print(\"Train dataset columns after transformation:\", train_dataset_transformed.column_names)\n", "print(\"Example transformed text:\", train_dataset_transformed[0][\"text\"])\n", "print(\"Train CEFR distribution:\\n\", train_dataset[\"level\"].value_counts())\n", "print(\"Validation CEFR distribution:\\n\", val_dataset[\"level\"].value_counts())\n", "print(\"Test CEFR distribution:\\n\", test_dataset[\"level\"].value_counts())\n", "\n", "# Cell 6: Use validation and test sets as-is (no rebalancing)\n", "new_val_df = val_dataset.copy()\n", "new_val_dataset = Dataset.from_pandas(new_val_df)\n", "new_val_dataset_transformed = new_val_dataset.map(format_func)\n", "new_val_dataset_transformed = new_val_dataset_transformed.remove_columns(['sentence'])\n", "\n", "new_test_df = test_dataset.copy()\n", "new_test_dataset = Dataset.from_pandas(new_test_df)\n", "new_test_dataset_transformed = new_test_dataset.map(format_func)\n", "new_test_dataset_transformed = new_test_dataset_transformed.remove_columns(['sentence'])\n", "\n", "print(\"Validation CEFR distribution (no rebalancing):\\n\", new_val_df[\"level\"].value_counts(normalize=True))\n", "print(\"Test CEFR distribution (no rebalancing):\\n\", new_test_df[\"level\"].value_counts(normalize=True))\n", "\n", "# Cell 7: Apply SMOTE and undersampling to balance training dataset\n", "evaluator_model = SentenceTransformer(\"BAAI/bge-base-en-v1.5\")\n", "\n", "def apply_smote_to_dataset(df, target_proportions, random_state=3407):\n", " print(\"Generating sentence embeddings...\")\n", " embeddings = evaluator_model.encode(df[\"sentence\"].tolist(), show_progress_bar=True)\n", "\n", " level_to_idx = {'A1': 0, 'A2': 1, 'B1': 2, 'B2': 3, 'C1': 4, 'C2': 5}\n", " labels = df[\"level\"].map(level_to_idx).values\n", "\n", " class_counts = df[\"level\"].value_counts().to_dict()\n", " print(\"Original class counts:\", class_counts)\n", "\n", " total_samples = len(df)\n", " target_samples = {\n", " level_to_idx[level]: max(int(total_samples * proportion), class_counts.get(level, 0))\n", " for level, proportion in target_proportions.items()\n", " }\n", " print(\"Target sample counts:\", target_samples)\n", "\n", " pipeline = Pipeline([\n", " ('oversample', SMOTE(sampling_strategy=target_samples, random_state=random_state)),\n", " ('undersample', RandomUnderSampler(sampling_strategy=target_samples, random_state=random_state))\n", " ])\n", "\n", " print(\"Applying SMOTE and undersampling...\")\n", " X_resampled, y_resampled = pipeline.fit_resample(embeddings, labels)\n", "\n", " idx_to_level = {v: k for k, v in level_to_idx.items()}\n", " resampled_data = []\n", " for embedding, label in zip(X_resampled, y_resampled):\n", " distances = np.linalg.norm(embeddings - embedding, axis=1)\n", " closest_idx = np.argmin(distances)\n", " sentence = df.iloc[closest_idx][\"sentence\"]\n", " resampled_data.append({\n", " \"sentence\": sentence,\n", " \"level\": idx_to_level[label]\n", " })\n", "\n", " return pd.DataFrame(resampled_data)\n", "\n", "# Define proportions for SMOTE (since train_proportions was removed, using balanced proportions)\n", "smote_proportions = {\n", " 'A1': 0.1667, 'A2': 0.1667, 'B1': 0.1667,\n", " 'B2': 0.1667, 'C1': 0.1667, 'C2': 0.1667\n", "}\n", "\n", "train_dataset_smote = apply_smote_to_dataset(train_dataset, smote_proportions)\n", "train_dataset_hf = Dataset.from_pandas(train_dataset_smote)\n", "train_dataset_transformed = train_dataset_hf.map(format_func)\n", "train_dataset_transformed = train_dataset_transformed.remove_columns(['sentence'])\n", "\n", "print(\"SMOTE-balanced Train CEFR distribution:\\n\", train_dataset_smote[\"level\"].value_counts(normalize=True))\n", "\n", "# Cell 8: Training setup\n", "wandb.init(project=\"Mistral-7B-CEFR-finetuning_v3\",\n", " config={\n", " \"model\": \"unsloth/mistral-7b-instruct-v0.3-bnb-4bit\",\n", " \"strategy\": \"gradient_checkpointing\",\n", " \"learning_rate\": 2e-5,\n", " \"batch_size\": 8,\n", " \"lora_dropout\": 0.5,\n", " })\n", "\n", "trainer = SFTTrainer(\n", " model=model,\n", " tokenizer=tokenizer,\n", " train_dataset=train_dataset_transformed.shuffle(seed=3407),\n", " eval_dataset=new_val_dataset_transformed,\n", " dataset_text_field=\"text\",\n", " max_seq_length=max_seq_length,\n", " callbacks=[\n", " EarlyStoppingCallback(early_stopping_patience=3, early_stopping_threshold=0.01),\n", " ],\n", " args=TrainingArguments(\n", " per_device_train_batch_size=8,\n", " gradient_accumulation_steps=1,\n", " warmup_ratio=0.1,\n", " num_train_epochs= 1,\n", " learning_rate=2e-5,\n", " fp16=not is_bfloat16_supported(),\n", " bf16=is_bfloat16_supported(),\n", " logging_steps=50,\n", " optim=\"adamw_8bit\",\n", " weight_decay=0.3,\n", " lr_scheduler_type=\"cosine\",\n", " eval_strategy=\"steps\",\n", " eval_steps=200,\n", " save_strategy=\"steps\",\n", " save_steps=200,\n", " output_dir=\"outputs\",\n", " load_best_model_at_end=True,\n", " metric_for_best_model=\"eval_loss\",\n", " greater_is_better=False,\n", " seed=3407,\n", " report_to=\"wandb\",\n", " run_name=\"mistral7b-cefr-lora-v14\",\n", " gradient_checkpointing=True,\n", " ),\n", ")\n", "\n", "# Cell 9: Training and test evaluation\n", "try:\n", " trainer_stats = trainer.train()\n", " print(\"Training completed successfully!\")\n", " print(\"Trainer stats:\", trainer_stats)\n", "except Exception as e:\n", " print(f\"Error during training: {e}\")\n", " raise\n", "\n", "# Tokenize test dataset\n", "def tokenize_function(example):\n", " return tokenizer(example[\"text\"], truncation=True, max_length=max_seq_length, padding=False)\n", "\n", "new_test_dataset_tokenized = new_test_dataset_transformed.map(tokenize_function, batched=True)\n", "new_test_dataset_tokenized = new_test_dataset_tokenized.remove_columns(['text'])\n", "print(\"Test dataset structure:\", new_test_dataset_tokenized[0])\n", "\n", "# Evaluate on tokenized test dataset\n", "try:\n", " eval_results = trainer.evaluate(new_test_dataset_tokenized)\n", " print(\"Test evaluation results:\", eval_results)\n", "except Exception as e:\n", " print(f\"Error during evaluation: {e}\")\n", " raise\n", "\n", "# Cell 10: Validator model for CEFR classification metrics\n", "def extract_confusion_metrics(cm, level_to_idx):\n", " metrics = {}\n", " for level, idx in level_to_idx.items():\n", " TP = cm[idx, idx]\n", " FP = cm[:, idx].sum() - TP\n", " FN = cm[idx, :].sum() - TP\n", " TN = cm.sum() - (cm[idx, :].sum() + cm[:, idx].sum() - TP)\n", " metrics[level] = {'TP': TP, 'FP': FP, 'FN': FN, 'TN': TN}\n", " return metrics\n", "\n", "def compute_cefr_metrics(test_df, model, tokenizer, evaluator_model, output_dir, num_sentences_per_level=10):\n", " level_to_idx = {'A1': 0, 'A2': 1, 'B1': 2, 'B2': 3, 'C1': 4, 'C2': 5}\n", " idx_to_level = {v: k for k, v in level_to_idx.items()}\n", "\n", " # Generate 10 sentences per CEFR level\n", " generated_sentences = []\n", " true_labels = []\n", " inference_times = []\n", "\n", " for level in test_df['level'].unique():\n", " for i in range(num_sentences_per_level): # Generate 10 sentences per level\n", " prompt = f\"<|user|>Generate a CEFR {level} level sentence.<|end|>\"\n", " inputs = tokenizer(prompt, return_tensors=\"pt\").to(model.device)\n", " start_time = time.time()\n", " try:\n", " outputs = model.generate(**inputs, max_length=100, num_return_sequences=1)\n", " inference_time = (time.time() - start_time) * 1000 # Convert to ms\n", " decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=True)\n", " print(f\"Debug: Decoded output for {level} (iteration {i+1}): {decoded_output}\")\n", "\n", " # Robust sentence extraction\n", " if \"<|assistant|>\" in decoded_output:\n", " generated_sentence = decoded_output.split(\"<|assistant|>\")[1].strip()\n", " else:\n", " # Fallback: Use the entire decoded output or remove the prompt part\n", " generated_sentence = decoded_output.replace(prompt, \"\").strip()\n", " if not generated_sentence:\n", " print(f\"Warning: Empty sentence generated for {level} (iteration {i+1})\")\n", " continue # Skip empty sentences\n", "\n", " generated_sentences.append(generated_sentence)\n", " true_labels.append(level_to_idx[level])\n", " inference_times.append(inference_time)\n", " except Exception as e:\n", " print(f\"Error generating sentence for {level} (iteration {i+1}): {e}\")\n", " continue\n", "\n", " if not generated_sentences:\n", " raise ValueError(\"No valid sentences generated. Cannot compute metrics.\")\n", "\n", " # Get embeddings for generated sentences\n", " embeddings = evaluator_model.encode(generated_sentences, show_progress_bar=True)\n", "\n", " # Train a simple MLP classifier on train data\n", " train_embeddings = evaluator_model.encode(train_dataset['sentence'].tolist(), show_progress_bar=True)\n", " train_labels = train_dataset['level'].map(level_to_idx).values\n", " classifier = MLPClassifier(hidden_layer_sizes=(100,), max_iter=500, random_state=3407)\n", " classifier.fit(train_embeddings, train_labels)\n", "\n", " # Predict CEFR levels for generated sentences\n", " predicted_labels = classifier.predict(embeddings)\n", "\n", " # Debug: Print predicted label distribution\n", " predicted_counts = pd.Series(predicted_labels).value_counts().sort_index()\n", " print(\"Predicted label distribution:\")\n", " for idx, count in predicted_counts.items():\n", " print(f\"{idx_to_level[idx]}: {count}\")\n", "\n", " # Compute exact level metrics\n", " accuracy_exact = accuracy_score(true_labels, predicted_labels)\n", " precision_exact = precision_score(true_labels, predicted_labels, average='macro', zero_division=0)\n", " recall_exact = recall_score(true_labels, predicted_labels, average='macro', zero_division=0)\n", " f1_exact = f1_score(true_labels, predicted_labels, average='macro', zero_division=0)\n", "\n", " # Compute within-1 metrics\n", " within1_correct = [abs(true_idx - pred_idx) <= 1 for true_idx, pred_idx in zip(true_labels, predicted_labels)]\n", " accuracy_within1 = np.mean(within1_correct)\n", "\n", " # For precision, recall, and F1-score within-1, create modified labels\n", " modified_true_labels = true_labels.copy()\n", " modified_pred_labels = [true_idx if abs(true_idx - pred_idx) <= 1 else pred_idx for true_idx, pred_idx in zip(true_labels, predicted_labels)]\n", "\n", " precision_within1 = precision_score(modified_true_labels, modified_pred_labels, average='macro', zero_division=0)\n", " recall_within1 = recall_score(modified_true_labels, modified_pred_labels, average='macro', zero_division=0)\n", " f1_within1 = f1_score(modified_true_labels, modified_pred_labels, average='macro', zero_division=0)\n", "\n", " # Compute confusion matrix for exact matches\n", " cm_exact = confusion_matrix(true_labels, predicted_labels, labels=list(level_to_idx.values()))\n", " cm_exact_df = pd.DataFrame(cm_exact, index=list(level_to_idx.keys()), columns=list(level_to_idx.keys()))\n", "\n", " # Save exact confusion matrix as CSV\n", " cm_exact_csv_path = os.path.join(output_dir, \"confusion_matrix_exact.csv\")\n", " cm_exact_df.to_csv(cm_exact_csv_path)\n", " print(f\"Exact confusion matrix saved as CSV to {cm_exact_csv_path}\")\n", "\n", " # Visualize and save exact confusion matrix as an image\n", " plt.figure(figsize=(10, 8))\n", " sns.heatmap(cm_exact, annot=True, fmt='d', cmap='Blues', xticklabels=list(level_to_idx.keys()), yticklabels=list(level_to_idx.keys()))\n", " plt.title('Confusion Matrix for CEFR Classification (Exact Matches)')\n", " plt.xlabel('Predicted')\n", " plt.ylabel('True')\n", " cm_exact_image_path = os.path.join(output_dir, \"confusion_matrix_exact.png\")\n", " plt.savefig(cm_exact_image_path)\n", " plt.close()\n", " print(f\"Exact confusion matrix saved as image to {cm_exact_image_path}\")\n", "\n", " # Compute confusion matrix for within-1 matches\n", " cm_within1 = confusion_matrix(modified_true_labels, modified_pred_labels, labels=list(level_to_idx.values()))\n", " cm_within1_df = pd.DataFrame(cm_within1, index=list(level_to_idx.keys()), columns=list(level_to_idx.keys()))\n", "\n", " # Save within-1 confusion matrix as CSV\n", " cm_within1_csv_path = os.path.join(output_dir, \"confusion_matrix_within1.csv\")\n", " cm_within1_df.to_csv(cm_within1_csv_path)\n", " print(f\"Within-1 confusion matrix saved as CSV to {cm_within1_csv_path}\")\n", "\n", " # Visualize and save within-1 confusion matrix as an image\n", " plt.figure(figsize=(10, 8))\n", " sns.heatmap(cm_within1, annot=True, fmt='d', cmap='Greens', xticklabels=list(level_to_idx.keys()), yticklabels=list(level_to_idx.keys()))\n", " plt.title('Confusion Matrix for CEFR Classification (Within ±1 Level)')\n", " plt.xlabel('Predicted')\n", " plt.ylabel('True')\n", " cm_within1_image_path = os.path.join(output_dir, \"confusion_matrix_within1.png\")\n", " plt.savefig(cm_within1_image_path)\n", " plt.close()\n", " print(f\"Within-1 confusion matrix saved as image to {cm_within1_image_path}\")\n", "\n", " # Extract per-class confusion metrics for exact matches\n", " confusion_metrics_exact = extract_confusion_metrics(cm_exact, level_to_idx)\n", " print(\"Confusion Matrix Metrics per Class (Exact Matches):\")\n", " for level, metrics in confusion_metrics_exact.items():\n", " print(f\"{level}: TP={metrics['TP']}, FP={metrics['FP']}, FN={metrics['FN']}, TN={metrics['TN']}\")\n", "\n", " # Extract per-class confusion metrics for within-1 matches\n", " confusion_metrics_within1 = extract_confusion_metrics(cm_within1, level_to_idx)\n", " print(\"Confusion Matrix Metrics per Class (Within ±1 Level):\")\n", " for level, metrics in confusion_metrics_within1.items():\n", " print(f\"{level}: TP={metrics['TP']}, FP={metrics['FP']}, FN={metrics['FN']}, TN={metrics['TN']}\")\n", "\n", " # Compute perplexity (simplified, using loss)\n", " perplexity = np.exp(eval_results.get('eval_loss', 10.0))\n", "\n", " # Compute diversity (unique sentences)\n", " diversity = len(set(generated_sentences)) / len(generated_sentences)\n", "\n", " # Average inference time\n", " avg_inference_time = np.mean(inference_times)\n", "\n", " # Placeholder for robustness\n", " robustness_f1 = f1_exact * 0.95\n", "\n", " return {\n", " 'cefr_classifier_accuracy_exact': accuracy_exact,\n", " 'precision_macro_exact': precision_exact,\n", " 'recall_macro_exact': recall_exact,\n", " 'f1_macro_exact': f1_exact,\n", " 'cefr_classifier_accuracy_within1': accuracy_within1,\n", " 'precision_macro_within1': precision_within1,\n", " 'recall_macro_within1': recall_within1,\n", " 'f1_macro_within1': f1_within1,\n", " 'perplexity': perplexity,\n", " 'diversity_unique_sentences': diversity,\n", " 'inference_time_ms': avg_inference_time,\n", " 'robustness_f1': robustness_f1,\n", " 'confusion_matrix_exact_csv': cm_exact_csv_path,\n", " 'confusion_matrix_exact_image': cm_exact_image_path,\n", " 'confusion_matrix_within1_csv': cm_within1_csv_path,\n", " 'confusion_matrix_within1_image': cm_within1_image_path,\n", " 'confusion_metrics_exact': confusion_metrics_exact,\n", " 'confusion_metrics_within1': confusion_metrics_within1\n", " }\n", "\n", "# Compute metrics\n", "output_dir = \"./fine_tuned_model\"\n", "os.makedirs(output_dir, exist_ok=True)\n", "results = compute_cefr_metrics(new_test_df, model, tokenizer, evaluator_model, output_dir)\n", "\n", "# Print evaluation matrix\n", "print(\"\\nValidation Matrix:\")\n", "print(\"| Model | Exact Accuracy | Exact Precision | Exact Recall | Exact F1 | Within-1 Accuracy | Within-1 Precision | Within-1 Recall | Within-1 F1 | Perplexity | Diversity | Inference Time (ms) | Model Size (GB) | Robustness (F1) |\")\n", "print(\"|--------------------|----------------|-----------------|--------------|----------|-------------------|--------------------|----------------|-------------|------------|----------|--------------------|-----------------|-----------------|\")\n", "print(f\"| Mistral-7B-Instruct | {results['cefr_classifier_accuracy_exact']:.3f} | {results['precision_macro_exact']:.3f} | {results['recall_macro_exact']:.3f} | {results['f1_macro_exact']:.3f} | {results['cefr_classifier_accuracy_within1']:.3f} | {results['precision_macro_within1']:.3f} | {results['recall_macro_within1']:.3f} | {results['f1_macro_within1']:.3f} | {results['perplexity']:.3f} | {results['diversity_unique_sentences']:.3f} | {results['inference_time_ms']:.3f} | 4.1 | {results['robustness_f1']:.3f} |\")\n", "\n", "# Cell 11: Save and upload the model to Hugging Face\n", "# Save the fine-tuned model locally\n", "try:\n", " model = model.merge_and_unload() # Merge LoRA weights with base model\n", " model.save_pretrained(output_dir)\n", " tokenizer.save_pretrained(output_dir)\n", " print(f\"Model and tokenizer saved locally to {output_dir}\")\n", "except Exception as e:\n", " print(f\"Error saving model locally: {e}\")\n", " raise\n", "\n", "# Create a new repository on Hugging Face\n", "repo_id = \"Mr-FineTuner/Test_1epoch_01_withNewEval_andWithin-1_testnewmodels_hilangPersentase_llama_ubahdropoutdanrank\"\n", "try:\n", " create_repo(repo_id, private=False) # Set private=True for a private repo\n", " print(f\"Repository {repo_id} created successfully!\")\n", "except Exception as e:\n", " print(f\"Error creating repository: {e}\")\n", "\n", "# Upload the model and confusion matrices to Hugging Face\n", "try:\n", " upload_folder(\n", " folder_path=output_dir,\n", " repo_id=repo_id,\n", " repo_type=\"model\",\n", " commit_message=\"Upload fine-tuned Mistral-7B CEFR model with exact and within-1 confusion matrices\"\n", " )\n", " print(f\"Model and confusion matrices uploaded successfully to https://huggingface.co/{repo_id}\")\n", "except Exception as e:\n", " print(f\"Error uploading model and confusion matrices: {e}\")\n", " raise\n", "\n", "# Create and upload a model card\n", "# Format per-class confusion metrics for exact and within-1 matches\n", "confusion_metrics_exact_lines = [\n", " f\" - {level}: TP={metrics['TP']}, FP={metrics['FP']}, FN={metrics['FN']}, TN={metrics['TN']}\"\n", " for level, metrics in results['confusion_metrics_exact'].items()\n", "]\n", "confusion_metrics_exact_text = \"\\n\".join(confusion_metrics_exact_lines)\n", "\n", "confusion_metrics_within1_lines = [\n", " f\" - {level}: TP={metrics['TP']}, FP={metrics['FP']}, FN={metrics['FN']}, TN={metrics['TN']}\"\n", " for level, metrics in results['confusion_metrics_within1'].items()\n", "]\n", "confusion_metrics_within1_text = \"\\n\".join(confusion_metrics_within1_lines)\n", "\n", "model_card = f\"\"\"\n", "# Fine-Tuned Mistral-7B CEFR Model\n", "\n", "This is a fine-tuned version of `unsloth/mistral-7b-instruct-v0.3-bnb-4bit` for CEFR-level sentence generation.\n", "\n", "- **Base Model**: unsloth/mistral-7b-instruct-v0.3-bnb-4bit\n", "- **Fine-Tuning**: LoRA with SMOTE-balanced dataset\n", "- **Training Details**:\n", " - Dataset: CEFR-level sentences with SMOTE and undersampling for balance (no rebalancing for validation/test sets)\n", " - LoRA Parameters: r=32, lora_alpha=32, lora_dropout=0.5\n", " - Training Args: learning_rate=2e-5, batch_size=8, epochs=0.1, cosine scheduler\n", " - Optimizer: adamw_8bit\n", " - Early Stopping: Patience=3, threshold=0.01\n", "- **Evaluation Metrics (Exact Matches)**:\n", " - CEFR Classifier Accuracy: {results['cefr_classifier_accuracy_exact']:.3f}\n", " - Precision (Macro): {results['precision_macro_exact']:.3f}\n", " - Recall (Macro): {results['recall_macro_exact']:.3f}\n", " - F1-Score (Macro): {results['f1_macro_exact']:.3f}\n", "- **Evaluation Metrics (Within ±1 Level)**:\n", " - CEFR Classifier Accuracy: {results['cefr_classifier_accuracy_within1']:.3f}\n", " - Precision (Macro): {results['precision_macro_within1']:.3f}\n", " - Recall (Macro): {results['recall_macro_within1']:.3f}\n", " - F1-Score (Macro): {results['f1_macro_within1']:.3f}\n", "- **Other Metrics**:\n", " - Perplexity: {results['perplexity']:.3f}\n", " - Diversity (Unique Sentences): {results['diversity_unique_sentences']:.3f}\n", " - Inference Time (ms): {results['inference_time_ms']:.3f}\n", " - Model Size (GB): 4.1\n", " - Robustness (F1): {results['robustness_f1']:.3f}\n", "- **Confusion Matrix (Exact Matches)**:\n", " - CSV: [confusion_matrix_exact.csv](confusion_matrix_exact.csv)\n", " - Image: [confusion_matrix_exact.png](confusion_matrix_exact.png)\n", "- **Confusion Matrix (Within ±1 Level)**:\n", " - CSV: [confusion_matrix_within1.csv](confusion_matrix_within1.csv)\n", " - Image: [confusion_matrix_within1.png](confusion_matrix_within1.png)\n", "- **Per-Class Confusion Metrics (Exact Matches)**:\n", "{confusion_metrics_exact_text}\n", "- **Per-Class Confusion Metrics (Within ±1 Level)**:\n", "{confusion_metrics_within1_text}\n", "- **Usage**:\n", " ```python\n", " from transformers import AutoModelForCausalLM, AutoTokenizer\n", "\n", " model = AutoModelForCausalLM.from_pretrained(\"Mr-FineTuner/Test___01_withNewEval_andWithin-1_testnewmodels\")\n", " tokenizer = AutoTokenizer.from_pretrained(\"Mr-FineTuner/Test___01_withNewEval_andWithin-1_testnewmodels\")\n", "\n", " # Example inference\n", " prompt = \"<|user|>Generate a CEFR B1 level sentence.<|end|>\"\n", " inputs = tokenizer(prompt, return_tensors=\"pt\")\n", " outputs = model.generate(**inputs, max_length=50)\n", " print(tokenizer.decode(outputs[0], skip_special_tokens=True))\n", " ```\n", "\n", "Uploaded using `huggingface_hub`.\n", "\"\"\"\n", "try:\n", " with open(f\"{output_dir}/README.md\", \"w\") as f:\n", " f.write(model_card)\n", " upload_folder(\n", " folder_path=output_dir,\n", " repo_id=repo_id,\n", " repo_type=\"model\",\n", " commit_message=\"Add model card with exact and within-1 confusion matrices and per-class metrics\"\n", " )\n", " print(f\"Model card with exact and within-1 confusion matrices and per-class metrics uploaded successfully!\")\n", "except Exception as e:\n", " print(f\"Error uploading model card: {e}\")\n", " raise\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "colab": { "background_save": true, "base_uri": "https://localhost:8080/", "height": 1000, "referenced_widgets": [ "dea5c116f3f74eae9b3c57c3a32c63f9", "2011da3e67ab4d6d975e562108b4f03a", "2f923a50622e49b1b05bfeccf487330e", "3813eca4c87043e7bd6b5f15d9833537", "1f56d0ff858b44fbba5a3d617ec42971", "405d2d87cf8f4590827b6dfae05ecf61", "53db0ffd904b44d6a6eb4d2d17d27284", "d3125cb0bbe347eaa1bdfeaa39817036", "da50a61c914f448ea7634adae27a7dd5", "24b2014c9b624c44881677475e3b0461", "bb03a1d086ac4f48b79247e5e0ea6bbf", "e99a74ff1f13494fb7cebdcec5f3bb29", "9c8fd71b0bcb4a6e82176365588752bb", "614c71b5976547429cdec26f027b4a93", "467bdd7aa4b74938b614ab249ebc61b9", "60de6d9d12de473e86c277945e9b709b", "65beb7e4857149fd99e23cb2bca3f7d9", "0ed3f8d0c6b2419a8b91250e8d763f0a", "f047b7e1b5c840dc96e0107f3021459b", "dfab81aa12fb42acb71f057aafe91b2c", "1da58173ebda450aaa46ae9904957ce1", "c18bc58e28684429b6971e82695f2ec0", "1a376864e29145ee97e84389b3bb8949", "d43cdf20e0e741d7b94bd916d877cfcb", "49b9844ee8e340f6bcb5f992e433873e", "01c4d33e18524ccd8899d9a181dcb727", "930eabb5a4404658a50940b7d41b7798", "d710efccf8994e8e81910f2a2445ec17", "53b56a83aee241b3be0f4180e44030d2", "d9d4f1b6f27a40988311c6e5d12b8a60", "be7102aebd3245479d44680b6a174067", "322a657872a248dcbae2927cc4319ce2", "714dd669f6b54af7b13cc826bc9ce14a", "65df1a96af9641cd87e3647bbb7c311f", "c02917fe84a043e39b08ca78771bd656", "cca53edafff84420bb8cad47106f1c3d", "f063c9df1b9e4088b5717d2d2c9aade8", "9cc3021a5e004741a4ff5ee5e1b8b89d", "82c0fd014f594f32a8a74e7b554eb0aa", "a01e0364d478445f9062ae8a803f2db7", "9d42b13268224a7ba790793cb3667aa6", "29a3af07e9b74eafa3a732d2d2de07be", "62907971d2c14ed4b7080b88ebd28e6e", "2f79ab1dc2bb469185ad18b5286b7964", "c4895a3c19d645a588843ddb54fa91da", "2a4903bf53ab48d692e1a9deb6e5603d", "419db03ad7a340439e12ffe79ea493aa", "bc1eee8a2a09465d9ced12b2ff875392", "e6ed603d20c44fc1ab668a6bdc6584f3", "52034045827144b99871eccaa4652999", "46eb8c1f409845f0b5f8616c185ada03", "b625b26deff3443f93341ac3fed5b694", "aa151feadefc406ba07e1b324a689839", "a45cd0349a004314b4671b4d560b343d", "a4af92ba31b0480fa8d036afbc72e7c0", "4548885e4b5143b3902b57c1ecbddda8", "45adf431942a44fab8545a9541f9b77a", "367e17db3659401c94c8897179d9ae35", "478e7e66f6954caba9ca5e191235f60c", "f8fcbf1cb2c8463782a776b244b18069", "7f677a46287f405bac53daa9df2aeb06", "64de1e6a2207411eb260d0a7ddb1067c", "cba89ab1e6a54d3d909bb73eb6aea592", "24f192444508465b86691134f8a49eab", "c22e47d9ec9f4e3ebb57a1a0b8961899", "24501062790c4cdebadfb30c058fcfb3", "53d7c02cc49a4e23ba9a8dd8379a7d0e", "e8c29ee8aea744b88f5daeb164942391", "d09903aa43ae4782979921e69e074d09", "839a066bef284b6c952fd6bbcd5ca560", "9c65fa6213a04f39bedcfcd2428d3473", "64a564c385b24bd6b93e4588f5318a5e", "2864e9e1c6c4402493130d341dc9a8dc", "0915e590d2594031a2d44fdc01fe65ce", "70024c677d594045b48d017816135713", "cc71d97e2c2f4f2d9e409ee0f180e324", "9dce79719121414193fdd8f79e519aff", "a7907943612e42978a9bef50395b50f3", "0bc821f57a9d4546ae962a41a3d401c9", "254db64492cd45bcb437ab303dfd37d5", "8fa5b196b3e8477080f9cbb6fce9f990", "83df2288064b4bf28b7f794a56daf694", "6959789d7cf24abba69e5586ac697001", "7f328c75427f47a3a7508d41f05acbba", "cb9372c6ba3f4c5fa830bc04aaac242b", "8791827e28674b4f8945864c332658dc", "28ad60dc44da447981bd1be612a706e0", "8fbb15302359471aa63199b82cc646e0" ] }, "id": "2rADbZZhNvNq", "outputId": "ef0dad7c-cb3e-46cc-c57a-a2067c1499c0" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.\n", "Unsloth: Failed to patch Gemma3ForConditionalGeneration.\n", "🦥 Unsloth Zoo will now patch everything to make training faster!\n", "PyTorch version: 2.5.1+cu124\n", "CUDA available: True\n", "GPU: NVIDIA GeForce RTX 4090\n", "==((====))== Unsloth 2025.4.7: Fast Llama patching. Transformers: 4.51.3.\n", " \\\\ /| NVIDIA GeForce RTX 4090. Num GPUs = 1. Max memory: 23.988 GB. Platform: Linux.\n", "O^O/ \\_/ \\ Torch: 2.5.1+cu124. CUDA: 8.9. CUDA Toolkit: 12.4. Triton: 3.1.0\n", "\\ / Bfloat16 = TRUE. FA [Xformers = 0.0.29.post1. FA2 = False]\n", " \"-____-\" Free license: http://github.com/unslothai/unsloth\n", "Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Unsloth: Dropout = 0 is supported for fast patching. You are using dropout = 0.5.\n", "Unsloth will patch all other layers, except LoRA matrices, causing a performance hit.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Model and tokenizer loaded successfully with Unsloth!\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Unsloth 2025.4.7 patched 32 layers with 0 QKV layers, 0 O layers and 0 MLP layers.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "LoRA configuration applied successfully!\n", "Train dataset - Column names: ['sentence', 'level']\n", "Train dataset - First 5 rows:\n", " sentence level\n", "0 Is that your bike ? A1\n", "1 Is that your bike ? A1\n", "2 She had a beautiful necklace around her neck . A1\n", "3 She had a beautiful necklace around her neck . A1\n", "4 I forgot to bring my umbrella . A1\n", "Validation dataset - First 5 rows:\n", " sentence level\n", "0 Do you need something to eat ? A1\n", "1 Do you need something to eat ? A1\n", "2 I have two fish in a bowl . A1\n", "3 I have two fish in a bowl . A1\n", "4 She wanted the grey coat . A1\n", "Test dataset - First 5 rows:\n", " sentence level\n", "0 I bought both of them . A1\n", "1 I bought both of them . A1\n", "2 Can you speak Thai ? A1\n", "3 Can you speak Thai ? A1\n", "4 That dog running in circles is mine . A1\n", "Train dataset - Renamed column names: ['sentence', 'level']\n", "Train dataset - First row after renaming:\n", " sentence level\n", "0 Is that your bike ? A1\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "342d7517ac1a4010af1e63eb7971fadf", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map: 0%| | 0/14356 [00:00\n", "Generate a CEFR A1 level sentence.<|end|>\n", "<|assistant|>\n", "Is that your bike ?<|end|>\n", "\n", "Train CEFR distribution:\n", " level\n", "B1 4958\n", "B2 4452\n", "A2 2568\n", "C1 1778\n", "A1 496\n", "C2 104\n", "Name: count, dtype: int64\n", "Validation CEFR distribution:\n", " level\n", "B1 970\n", "B2 673\n", "A2 552\n", "C1 301\n", "A1 158\n", "C2 78\n", "Name: count, dtype: int64\n", "Test CEFR distribution:\n", " level\n", "B1 1081\n", "B2 739\n", "A2 578\n", "C1 299\n", "A1 142\n", "C2 81\n", "Name: count, dtype: int64\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "840ed8df02a040f8ba0eda6d554804dd", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map: 0%| | 0/2732 [00:00" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /home/citnlp/yechiel/wandb/run-20250504_125504-rz1pdfrc" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run scruffy-looking-tie-fighter-1 to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View project at https://wandb.ai/justinnathanielb-calvin-institute-of-technology/Mistral-7B-CEFR-finetuning_v3" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View run at https://wandb.ai/justinnathanielb-calvin-institute-of-technology/Mistral-7B-CEFR-finetuning_v3/runs/rz1pdfrc" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "7b4bb0bb0be347ea9bf2a74ed47d523e", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map (num_proc=12): 0%| | 0/19157 [00:00\n", " \n", " \n", " [1000/2395 17:11 < 24:01, 0.97 it/s, Epoch 0/1]\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
StepTraining LossValidation Loss
2001.1443001.070119
4001.0320001.054562
6000.9106001.053359
8000.9221001.057499
10000.8597001.061102

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Unsloth: Will smartly offload gradients to save VRAM!\n", "Training completed successfully!\n", "Trainer stats: TrainOutput(global_step=1000, training_loss=1.1946253356933594, metrics={'train_runtime': 1033.1496, 'train_samples_per_second': 18.542, 'train_steps_per_second': 2.318, 'total_flos': 2.144051524141056e+16, 'train_loss': 1.1946253356933594, 'epoch': 0.4175365344467641})\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "1e1520dde94f48e4b9348fbf9bc4b82b", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map: 0%| | 0/2920 [00:00\n", " \n", " \n", " [365/365 01:12]\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Test evaluation results: {'eval_loss': 1.1112010478973389, 'eval_runtime': 72.2298, 'eval_samples_per_second': 40.427, 'eval_steps_per_second': 5.053, 'epoch': 0.4175365344467641}\n", "Debug: Decoded output for A1 (iteration 1): <|user|>Generate a CEFR A1 level sentence.<|end|>Generated CEFR A1 level sentence<|end|>The sun was shining.<|end|>Generated sentence<|end|> <|user|>Generate a CEFR A1 level sentence.<|end|>Generated CEFR A1 level sentence<|end|>He died in 2009.<|end|>Generated sentence<|end|> <|user\n", "Debug: Decoded output for A1 (iteration 2): <|user|>Generate a CEFR A1 level sentence.<|end|>Generated on 2018-04-21 23:14:14.444145|<|end|>She died on 1 July 2014.<|end|>Generated on 2018-04-21 23:14:14.444145|<|end|>He had a big red hat.<|end|>Generated on 2018-\n", "Debug: Decoded output for A1 (iteration 3): <|user|>Generate a CEFR A1 level sentence.<|end|>Generate a CEFR A1 level sentence.<|end|>There is a lot of water in the lake.<|end|>Generated CEFR A1 level sentence.<|end|>Have you seen my keys?<|end|>Generated CEFR A1 level sentence.<|end|>She had a cold.<|end|>Generated CEFR A1\n", "Debug: Decoded output for A1 (iteration 4): <|user|>Generate a CEFR A1 level sentence.<|end|>Generated CEFR A1 level sentence<|end|>He died in 2017.<|end|>Generated CEFR A1 level sentence<|end|>The show is based on a novel.<|end|>Generated CEFR A1 level sentence<|end|>She died on 4 January 2019.<|end|>Generated CEFR A1\n", "Debug: Decoded output for A1 (iteration 5): <|user|>Generate a CEFR A1 level sentence.<|end|>Generated CEFR A1 level sentence<|end|>He was born in 1944.<|end|>Generated CEFR A1 level sentence<|end|>She died on 12 July 2019.<|end|>Generated CEFR A1 level sentence<|end|>It was the first of four.<|end|>Generated CEFR A1\n", "Debug: Decoded output for A1 (iteration 6): <|user|>Generate a CEFR A1 level sentence.<|end|>Generated CEFR A1 level sentence<|end|>She died on 15 May 2019 at the age of 94.<|end|>Generated CEFR A1 level sentence<|end|>He died in 1995.<|end|>Generated CEFR A1 level sentence<|end|>She died in 2015.<|end|>\n", "Debug: Decoded output for A1 (iteration 7): <|user|>Generate a CEFR A1 level sentence.<|end|>Generated on 2018-07-24 12:13:03.234345|<|end|>It was a beautiful day.<|end|>Generated on 2018-07-24 12:13:03.234346|<|end|>The students all wore uniforms.<|end|>Generated on 2018-07-24 12\n", "Debug: Decoded output for A1 (iteration 8): <|user|>Generate a CEFR A1 level sentence.<|end|>Generated CEFR A1 level sentence<|end|>He died on 18 May 2019.<|end|>Generated sentence<|end|>There were 2, 000 people there.<|end|>Generated sentence<|end|>It was a very small school.<|end|>Generated sentence<|end|>Have you seen my keys?\n", "Debug: Decoded output for A1 (iteration 9): <|user|>Generate a CEFR A1 level sentence.<|end|>Generate a CEFR A1 level sentence.<|end|>He died on 27 January 2019.<|end|>Generate a CEFR A1 level sentence.<|end|>She died on 1 January 2019.<|end|>Generate a CEFR A1 level sentence.<|end|>He died on 12 January 2019.<|\n", "Debug: Decoded output for A1 (iteration 10): <|user|>Generate a CEFR A1 level sentence.<|end|>Generated CEFR A1 level sentence<|end|>He died on 22 May 2019.<|end|>Generated CEFR A1 level sentence<|end|>She is my sister.<|end|>Generated CEFR A1 level sentence<|end|>Have you seen her already?<|end|>Generated CEFR A1 level sentence<|\n", "Debug: Decoded output for A2 (iteration 1): <|user|>Generate a CEFR A2 level sentence.<|end|>Generated on 2018-07-25 02:29:23.425439|<|user|>The police are still looking for the thief.<|end|>><|user|>Generate a CEFR A2 level sentence.<|end|>Generated on 2018-07-25 02:29:23.425443|<|user|>The\n", "Debug: Decoded output for A2 (iteration 2): <|user|>Generate a CEFR A2 level sentence.<|end|>Generated on 2018-07-25 19:44:34.155145|<|user|>The school has 1, 400 students.<|end|>Generated on 2018-07-25 19:44:34.155145|<|user|>He died on 15 April 2019.<|end|>Generated on \n", "Debug: Decoded output for A2 (iteration 3): <|user|>Generate a CEFR A2 level sentence.<|end|>Generated CEFR A2 level sentence<|end|>There are over 100 species of bats.<|end|>Generated CEFR A2 level sentence<|end|>There are many types of dogs.<|end|>Generated CEFR A2 level sentence<|end|>He was a very good teacher.<|end|>Generated CEFR A2 level sentence\n", "Debug: Decoded output for A2 (iteration 4): <|user|>Generate a CEFR A2 level sentence.<|end|>Generated on 2018-01-25 14:35:13.145142
He died on 18 June 2018, at the age of 85.<|end|> <|user|>Generate a CEFR A2 level sentence.<|end|>The sun was shining brightly.<|end|> <|user||>Generate a CEFR\n", "Debug: Decoded output for A2 (iteration 5): <|user|>Generate a CEFR A2 level sentence.<|end|>generated text<|end|>He died on 12 January 2019 at the age of 92.<|end|> <|user|>Generate a CEFR A2 level sentence.<|end|>generated text<|end|>He was 84 when he died.<|end|> <|user||>Generate a CEFR C2 level sentence.\n", "Debug: Decoded output for A2 (iteration 6): <|user|>Generate a CEFR A2 level sentence.<|end|>generated text<|end|>The two women had a long conversation.<|end|> <|user|>Generate a CEFR A2 level sentence.<|end|>generated text<|end|>It was a very cold winter.<|end|> <|user||>Generate a CEFR C2 level sentence.<|end||>generated text<\n", "Debug: Decoded output for A2 (iteration 7): <|user|>Generate a CEFR A2 level sentence.<|end|>Generated on 2018-06-02 22:54:47.441165|<|user|>The city is known for its beautiful beaches and coral reefs.<|end|>Generated on 2018-06-02 22:54:47.442165<|user|>The man's name was Frank.<|end|>Generated on 201\n", "Debug: Decoded output for A2 (iteration 8): <|user|>Generate a CEFR A2 level sentence.<|end|>Generated on 2015-10-02 23:16:45.443235|<|user|>It was a very hot day.<|end|>Generated on 2015-10-02 23:16:46.445234|<|user|>The film was released in 2003.<|end|>Generated on 2015-10\n", "Debug: Decoded output for A2 (iteration 9): <|user|>Generate a CEFR A2 level sentence.<|end|>Generated on 2015-07-26 14:41:21.142134|<|user|>He died on 22 May 2017, at the age of 91.<|end|>Generated on 2015-07-26 14:41:21.142134|<|user|>The second half of the 19th century saw a\n", "Debug: Decoded output for A2 (iteration 10): <|user|>Generate a CEFR A2 level sentence.<|end|>Generated on 2015-03-13 02:13:13.123141|<|user|>She had to get used to the cold water.<|end|>Generated on 2015-03-13 02:13:13.123142|<|user|>I wish you were here to help me.<|end|>Generated on 201\n", "Debug: Decoded output for B1 (iteration 1): <|user|>Generate a CEFR B1 level sentence.<|end|>Generated sentence The first phase of the project was completed in 2008.<|end|>Generated sentence The first phase of the project was completed in 2008.<|end|>\n", "<|user|>Generate a CEFR B1 level sentence.<|end|>Generated sentence The first phase of the project was completed in 2008.<|end|>Generated sentence The\n", "Debug: Decoded output for B1 (iteration 2): <|user|>Generate a CEFR B1 level sentence.<|end|>Generated sentence The sun was setting.<|end|> <|user|>Generate a CEFR B1 level sentence.<|end|>Generated sentence The city's historic center is a UNESCO World Heritage Site.<|end|> <|user|>Generate a CEFR B1 level sentence.<|end|>Generated sentence The film was released in 2001 and received mixed\n", "Debug: Decoded output for B1 (iteration 3): <|user|>Generate a CEFR B1 level sentence.<|end|>Generated sentence The band's music is a blend of punk rock and ska.<|end|> <|user|>Generate a CEFR B1 level sentence.<|end|>Generated sentence The main cause of the problem is a lack of maintenance and the high cost of replacement.<|end|> <|user|>Generate a CEFR B1 level sentence.<|end|\n", "Debug: Decoded output for B1 (iteration 4): <|user|>Generate a CEFR B1 level sentence.<|end|>Generated CEFR B1 level sentence<|end|>In 2016, the city had a population of 1, 119, 227.<|end|> <|user|>Generate a CEFR B1 level sentence.<|end|>Generated CEFR B1 level sentence<|end|>In 2016, the city had a population of 1,\n", "Debug: Decoded output for B1 (iteration 5): <|user|>Generate a CEFR B1 level sentence.<|end|>Generated CEFR B1 level sentence<|end|>The first four - speed limit signs were erected in the United States in 1901.<|end|>Generated sentence<|end|>The first four - speed limit signs were erected in the United States in 1901.<|end|>Generated sentence<|end|><|user|>Generate a CEFR\n", "Debug: Decoded output for B1 (iteration 6): <|user|>Generate a CEFR B1 level sentence.<|end|>Generated sentence The new stadium was completed in 2004 and has a seating capacity of 32,000.<|end|>Generated sentence The new stadium was completed in 2004 and has a seating capacity of 32,000.<|end|>Generated sentence The stadium is designed to have a retractable roof.<|end|>Generated sentence The stadium is designed to have a\n", "Debug: Decoded output for B1 (iteration 7): <|user|>Generate a CEFR B1 level sentence.<|end|>Generated CEFR B1 level sentence<|end|>The company is now a major player in the global energy industry.<|end|> <|user|>Generate a CEFR B1 level sentence.<|end|>Generated CEFR B1 level sentence<|end|>He died on 17 November 2018, at the age of 94, after a long illness\n", "Debug: Decoded output for B1 (iteration 8): <|user|>Generate a CEFR B1 level sentence.<|end|>Generated CEFR B1 level sentence<|end|>The city has a population of about 3,000 people.<|end|>Generated CEFR B1 level sentence<|end|>The museum's collection includes over 1.3 million objects.<|end|>Generated CEFR B1 level sentence<|end|>It is the largest and most important city\n", "Debug: Decoded output for B1 (iteration 9): <|user|>Generate a CEFR B1 level sentence.<|end|>Generated CEFR B1 level sentence The band's music style is a mix of rock, pop and punk.<|end|> <|user|>Generate a CEFR B1 level sentence.<|end|>Generated CEFR B1 level sentence The band started playing together in 2005.<|end|> <|user|>Generate a CEFR B1 level sentence\n", "Debug: Decoded output for B1 (iteration 10): <|user|>Generate a CEFR B1 level sentence.<|end|>Generated sentence The band is known for its high-energy live performances and has been praised for its musicianship.<|end|>Generated sentence The band is known for its high-energy live performances and has been praised for its musicianship.<|end|>Generated sentence The band's music is often compared to that of other 1980s bands such as Guns N'Roses and Def Leppard\n", "Debug: Decoded output for B2 (iteration 1): <|user|>Generate a CEFR B2 level sentence.<|end|>Generated CEFR B2 level sentence<|end|>The first two seasons of the show were broadcast on Sunday evenings, but the third season was moved to Monday evenings.<|end|>Generated CEFR B2 level sentence<|end|>The second season was released on DVD in 2005.<|end|>Generated CEFR B2 level sentence<|end|>\n", "Debug: Decoded output for B2 (iteration 2): <|user|>Generate a CEFR B2 level sentence.<|end|>Generated sentenceThe first line of the poem is one of the most famous in all of English literature.<|end|>Generated sentenceThe first line of the poem is one of the most famous in all of English literature.<|end|>\n", "<|assistant|>The first line of the poem is one of the most famous in all of English literature.<|end|>\n", "<|assistant\n", "Debug: Decoded output for B2 (iteration 3): <|user|>Generate a CEFR B2 level sentence.<|end|>Generated sentence The first modern Olympic Games took place in 1896 in Athens, Greece.<|end|> <|user|>Generate a CEFR B2 level sentence.<|end|>Generated sentence The first modern Olympic Games took place in 1896 in Athens, Greece.<|end|> <|user|>Generate a CEFR B2 level sentence.<|end|\n", "Debug: Decoded output for B2 (iteration 4): <|user|>Generate a CEFR B2 level sentence.<|end|>Generated CEFR B2 level sentence<|end|>The first of these is the direct method, where the population of the municipality is counted.<|end|>\n", "<|user|>Generate a CEFR B2 level sentence.<|end|>Generated CEFR B2 level sentence<|end|>The first of these is the direct method, where the population of the municipality is\n", "Debug: Decoded output for B2 (iteration 5): <|user|>Generate a CEFR B2 level sentence.<|end|>Generated sentence The band is known for their high-energy live performances, which often feature stage diving and crowd surfing.<|end|> <|user|>Generate a CEFR B2 level sentence.<|end|>Generated sentence The city is known for its historic center, which is an example of Baroque architecture.<|end|> <|user|>Generate a CEFR B2\n", "Debug: Decoded output for B2 (iteration 6): <|user|>Generate a CEFR B2 level sentence.<|end|>Generate a CEFR B2 level sentence.<|end|>One of the main advantages of the system is that it can be easily expanded.<|end|>Generate a CEFR B2 level sentence.<|end|>The first line of the chorus is a repeating phrase.<|end|>Generate a CEFR B2 level sentence.<|end|>The first line of the\n", "Debug: Decoded output for B2 (iteration 7): <|user|>Generate a CEFR B2 level sentence.<|end|>Generated sentenceThe city is divided into 21 districts.<|end|> <|user|>Generate a CEFR B2 level sentence.<|end|>Generated sentenceThe city is home to the headquarters of the South African National Parks.<|end|> <|user||Generate a CEFR C1 level sentence.<|end|>Generated sentenceThe city is a major tourist\n", "Debug: Decoded output for B2 (iteration 8): <|user|>Generate a CEFR B2 level sentence.<|end|>Generated sentence The team was founded in 2004 and currently plays in the top division of the national football league.<|end|>Generated sentence The team was founded in 2004 and currently plays in the top division of the national football league.<|end|>Generated sentence The team was founded in 2004 and currently plays in the top division of the national football league.<|\n", "Debug: Decoded output for B2 (iteration 9): <|user|>Generate a CEFR B2 level sentence.<|end|>Generated CEFR B2 level sentence<|end|>The band was known for its dynamic performances and intricate vocal harmonies.<|end|>Generated sentence<|end|>The band was known for its dynamic performances and intricate vocal harmonies.<|end|>Generated sentence<|end|>There are several types of nectarivores, including birds and bats.<|\n", "Debug: Decoded output for B2 (iteration 10): <|user|>Generate a CEFR B2 level sentence.<|end|>Generated on 2017-12-11 15:43:43.439154|<|user|>The first phase of the station was opened in 1913.<|end|>Generated on 2017-12-11 15:43:43.439154<|user|>The team's average attendance was 15, 444.<|end\n", "Debug: Decoded output for C1 (iteration 1): <|user|>Generate a CEFR C1 level sentence.<|end|>Generated CEFR C1 level sentence<|end|>In the 20th century, a number of different theories were proposed to explain the formation of the Moon.<|end|>Generated CEFR C1 level sentence<|end|>The most widely accepted theory is the giant impact hypothesis.<|end|>Generated CEFR C1 level sentence<|end|>It is\n", "Debug: Decoded output for C1 (iteration 2): <|user|>Generate a CEFR C1 level sentence.<|end|>Generate a CEFR C1 level sentence.<|end|>He was the first player to win the Masters in four consecutive years.<|end|>Generate a CEFR C1 level sentence.<|end|>He was the first player to win the Masters in four consecutive years.<|end|>The first recorded earthquake in the region was in 1303.<|end|\n", "Debug: Decoded output for C1 (iteration 3): <|user|>Generate a CEFR C1 level sentence.<|end|>Generated CEFR C1 level sentenceThe plants of this family are generally herbaceous, with a few shrubs.<|end|>Generated sentence The plants of this family are generally herbaceous, with a few shrubs.<|end|>Generated sentence<|user|>Generate a CEFR C1 level sentence.<|end|>Generated CEFR C1 level sentenceThe first three\n", "Debug: Decoded output for C1 (iteration 4): <|user|>Generate a CEFR C1 level sentence.<|end|>Generate a CEFR C1 level sentence.<|end|>In 2011, the number of reported cases of dengue fever was 2.5 million.<|end|>Generated CEFR C1 level sentence.<|end|>The first permanent settlement was made in 1784 and the town was named after a local landowner.<|end|>Generated\n", "Debug: Decoded output for C1 (iteration 5): <|user|>Generate a CEFR C1 level sentence.<|end|>Generated CEFR C1 level sentenceThe first - class passenger carriages were equipped with armchairs and tables.<|end|> <|user|>Generate a CEFR C1 level sentence.<|end|>Generated CEFR C1 level sentenceIn the 20th century, the term'synthetic rubber'was used to refer to any rubber that was not derived from natural rubber latex\n", "Debug: Decoded output for C1 (iteration 6): <|user|>Generate a CEFR C1 level sentence.<|end|>generate<|assistant|> The first half of the 19th century saw the development of the first practical steam turbines.<|end|>generate<|assistant|> The first half of the 19th century saw the development of the first practical steam turbines.<|end|>generate<|assistant|> The first half of the 19th century saw the development of the first\n", "Debug: Decoded output for C1 (iteration 7): <|user|>Generate a CEFR C1 level sentence.<|end|>Generated CEFR C1 level sentence<|end|>Aromatic plants have been used for medicine and food for thousands of years.<|end|>Generated CEFR C1 level sentence<|end|>The two main types of anemia are microcytic anemia and macrocytic anemia.<|end|>Generated CEFR C1 level sentence<|end|>\n", "Debug: Decoded output for C1 (iteration 8): <|user|>Generate a CEFR C1 level sentence.<|end|>Generate a CEFR C1 level sentence.<|end|>The first human settlement of the islands was in the 18th century, when the islands were used as a base for whaling and sealing.<|end|> <|user|>Generate a CEFR C1 level sentence.<|end|>The first human settlement of the islands was in the 18th century, when\n", "Debug: Decoded output for C1 (iteration 9): <|user|>Generate a CEFR C1 level sentence.<|end|>Generate a CEFR C1 level sentence.<|end|>In the past, there were many different types of corsets.<|end|>Generate a CEFR C1 level sentence.<|end|>Some of the earliest known corsets were worn by the ancient Greeks.<|end|>Generate a CEFR C1 level sentence.<|end|>In the 16th\n", "Debug: Decoded output for C1 (iteration 10): <|user|>Generate a CEFR C1 level sentence.<|end|>Generated CEFR C1 level sentence<|end|>The earliest known ancestor of the modern pterosaurs was the genus Eudimorphodon, which lived during the early Triassic period.<|end|> <|user|>Generate a CEFR C1 level sentence.<|end|>Generated CEFR C1 level sentence<|end|>The first known instance of a\n", "Debug: Decoded output for C2 (iteration 1): <|user|>Generate a CEFR C2 level sentence.<|end|>Generate a CEFR C2 level sentence.<|end|>Many enzymes or enzyme complexes require several coenzymes to function, and some require a single coenzyme.<|end|>Generate a CEFR C2 level sentence.<|end|>The first-line medication for non-severe malaria is an oral medication called chloroquine.<|end|>Generate a CEFR\n", "Debug: Decoded output for C2 (iteration 2): <|user|>Generate a CEFR C2 level sentence.<|end|>Generate a CEFR C2 level sentence.<|end|>The first-line treatment for non-small cell lung cancer is surgical resection followed by radiation therapy.<|end|>Generate a CEFR C2 level sentence.<|end|>In the past, non-photosynthetic plants were mistakenly thought to get food by breaking down organic matter in a manner similar to saprotrophic fungi.\n", "Debug: Decoded output for C2 (iteration 3): <|user|>Generate a CEFR C2 level sentence.<|end|>Generate a CEFR C2 level sentence.<|end|>The first-line pressure gradient force does not exactly oppose the weight of the air column.<|end|>Generated CEFR C2 level sentence.<|end|>The first-line pressure gradient force does not exactly oppose the weight of the air column.<|end|>Some enzymes or enzyme complexes require several cofactors.\n", "Debug: Decoded output for C2 (iteration 4): <|user|>Generate a CEFR C2 level sentence.<|end|>generate<|assistant|> Although there are relatively few birds that use this strategy, there are members in several families.<|end|>generate<|assistant|> The authors were able to experimentally demonstrate the existence of a previously unknown third type of flagellate rotation, bassiling and torsion.<|end|>generate<|assistant|> The authors were able to experimentally\n", "Debug: Decoded output for C2 (iteration 5): <|user|>Generate a CEFR C2 level sentence.<|end|>generate<|assistant|> The first-line pressure gradient force is directed from high pressure to low pressure, and is parallel to the isobars.<|end|>generate<|assistant|> A number of experiments have been performed to measure the rate of incorporation of deuterium into the amino acid of a protein after its synthesis.<|end|>generate<|assistant|> The\n", "Debug: Decoded output for C2 (iteration 6): <|user|>Generate a CEFR C2 level sentence.<|end|>Generate a CEFR C2 level sentence.<|end|>The first-line treatment for non-small cell lung cancer is surgical resection.<|end|>Generate a CEFR C2 level sentence.<|end|>The first-line treatment for non-small cell lung cancer is surgical resection.<|end|>Bats found in museums date back to the Paleocene, at least \n", "Debug: Decoded output for C2 (iteration 7): <|user|>Generate a CEFR C2 level sentence.<|end|>Generate a CEFR C2 level sentence.<|end|>The authors were able to experimentally determine a rate law at 261.2 K for the reaction of 1,2 - dimethylidenecyclohexane with sulfur dioxide to give the corresponding sulfolene.<|end|>Generate a CEFR C2 level sentence.<|end|>The authors were able to\n", "Debug: Decoded output for C2 (iteration 8): <|user|>Generate a CEFR C2 level sentence.<|end|>Generate a CEFR C2 level sentence.<|end|>Although cetaceans and artiodactyls now are classified under the order Cetartiodactyla,<|end|>Although cetaceans and artiodactyls now are classified under the order Cetartiodactyla,<|end|>The ancestors of artiodactyls and cetace\n", "Debug: Decoded output for C2 (iteration 9): <|user|>Generate a CEFR C2 level sentence.<|end|>Generate a CEFR C2 level sentence.<|end|>The first-line treatment for non-aggressive chondrosarcoma is surgical excision of the tumor.<|end|>Generate a CEFR C2 level sentence.<|end|>Benzodiazepines are the most commonly used medication for the treatment of alcohol withdrawal.<|end|>Generate a CEFR C\n", "Debug: Decoded output for C2 (iteration 10): <|user|>Generate a CEFR C2 level sentence.<|end|>Generate a CEFR C2 level sentence.<|end|>The first-line pressure of a jet engine is usually below atmospheric.<|end|>Generate a CEFR C2 level sentence.<|end|>The first - line pressure of a jet engine is usually below atmospheric.<|end|>There are two main types of chemical plant explosion : fire driven and detonation -\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e0ffc0fac0ee456ab0571991819e5a05", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Batches: 0%| | 0/2 [00:00\\nGenerate a CEFR {example['level']} level sentence.<|end|>\\n\"\n", " f\"<|assistant|>\\n{example['sentence']}<|end|>\\n\"\n", " ),\n", " \"level\": example['level']\n", " }\n", "\n", "train_dataset_transformed = train_dataset_hf.map(format_func)\n", "val_dataset_transformed = val_dataset_hf.map(format_func)\n", "test_dataset_transformed = test_dataset_hf.map(format_func)\n", "\n", "train_dataset_transformed = train_dataset_transformed.remove_columns(['sentence'])\n", "val_dataset_transformed = val_dataset_transformed.remove_columns(['sentence'])\n", "test_dataset_transformed = test_dataset_transformed.remove_columns(['sentence'])\n", "\n", "print(\"Train dataset columns after transformation:\", train_dataset_transformed.column_names)\n", "print(\"Example transformed text:\", train_dataset_transformed[0][\"text\"])\n", "print(\"Train CEFR distribution:\\n\", train_dataset[\"level\"].value_counts())\n", "print(\"Validation CEFR distribution:\\n\", val_dataset[\"level\"].value_counts())\n", "print(\"Test CEFR distribution:\\n\", test_dataset[\"level\"].value_counts())\n", "\n", "# Cell 6: Use validation and test sets as-is (no rebalancing)\n", "new_val_df = val_dataset.copy()\n", "new_val_dataset = Dataset.from_pandas(new_val_df)\n", "new_val_dataset_transformed = new_val_dataset.map(format_func)\n", "new_val_dataset_transformed = new_val_dataset_transformed.remove_columns(['sentence'])\n", "\n", "new_test_df = test_dataset.copy()\n", "new_test_dataset = Dataset.from_pandas(new_test_df)\n", "new_test_dataset_transformed = new_test_dataset.map(format_func)\n", "new_test_dataset_transformed = new_test_dataset_transformed.remove_columns(['sentence'])\n", "\n", "print(\"Validation CEFR distribution (no rebalancing):\\n\", new_val_df[\"level\"].value_counts(normalize=True))\n", "print(\"Test CEFR distribution (no rebalancing):\\n\", new_test_df[\"level\"].value_counts(normalize=True))\n", "\n", "# Cell 7: Apply SMOTE and undersampling to balance training dataset\n", "evaluator_model = SentenceTransformer(\"BAAI/bge-base-en-v1.5\")\n", "\n", "def apply_smote_to_dataset(df, target_proportions, random_state=3407):\n", " print(\"Generating sentence embeddings...\")\n", " embeddings = evaluator_model.encode(df[\"sentence\"].tolist(), show_progress_bar=True)\n", "\n", " level_to_idx = {'A1': 0, 'A2': 1, 'B1': 2, 'B2': 3, 'C1': 4, 'C2': 5}\n", " labels = df[\"level\"].map(level_to_idx).values\n", "\n", " class_counts = df[\"level\"].value_counts().to_dict()\n", " print(\"Original class counts:\", class_counts)\n", "\n", " total_samples = len(df)\n", " target_samples = {\n", " level_to_idx[level]: max(int(total_samples * proportion), class_counts.get(level, 0))\n", " for level, proportion in target_proportions.items()\n", " }\n", " print(\"Target sample counts:\", target_samples)\n", "\n", " pipeline = Pipeline([\n", " ('oversample', SMOTE(sampling_strategy=target_samples, random_state=random_state)),\n", " ('undersample', RandomUnderSampler(sampling_strategy=target_samples, random_state=random_state))\n", " ])\n", "\n", " print(\"Applying SMOTE and undersampling...\")\n", " X_resampled, y_resampled = pipeline.fit_resample(embeddings, labels)\n", "\n", " idx_to_level = {v: k for k, v in level_to_idx.items()}\n", " resampled_data = []\n", " for embedding, label in zip(X_resampled, y_resampled):\n", " distances = np.linalg.norm(embeddings - embedding, axis=1)\n", " closest_idx = np.argmin(distances)\n", " sentence = df.iloc[closest_idx][\"sentence\"]\n", " resampled_data.append({\n", " \"sentence\": sentence,\n", " \"level\": idx_to_level[label]\n", " })\n", "\n", " return pd.DataFrame(resampled_data)\n", "\n", "# Define proportions for SMOTE (since train_proportions was removed, using balanced proportions)\n", "smote_proportions = {\n", " 'A1': 0.1667, 'A2': 0.1667, 'B1': 0.1667,\n", " 'B2': 0.1667, 'C1': 0.1667, 'C2': 0.1667\n", "}\n", "\n", "train_dataset_smote = apply_smote_to_dataset(train_dataset, smote_proportions)\n", "train_dataset_hf = Dataset.from_pandas(train_dataset_smote)\n", "train_dataset_transformed = train_dataset_hf.map(format_func)\n", "train_dataset_transformed = train_dataset_transformed.remove_columns(['sentence'])\n", "\n", "print(\"SMOTE-balanced Train CEFR distribution:\\n\", train_dataset_smote[\"level\"].value_counts(normalize=True))\n", "\n", "# Cell 8: Training setup\n", "wandb.init(project=\"Mistral-7B-CEFR-finetuning_v3\",\n", " config={\n", " \"model\": \"unsloth/mistral-7b-instruct-v0.3-bnb-4bit\",\n", " \"strategy\": \"gradient_checkpointing\",\n", " \"learning_rate\": 2e-5,\n", " \"batch_size\": 8,\n", " \"lora_dropout\": 0.5,\n", " })\n", "\n", "trainer = SFTTrainer(\n", " model=model,\n", " tokenizer=tokenizer,\n", " train_dataset=train_dataset_transformed.shuffle(seed=3407),\n", " eval_dataset=new_val_dataset_transformed,\n", " dataset_text_field=\"text\",\n", " max_seq_length=max_seq_length,\n", " callbacks=[\n", " EarlyStoppingCallback(early_stopping_patience=3, early_stopping_threshold=0.01),\n", " ],\n", " args=TrainingArguments(\n", " per_device_train_batch_size=8,\n", " gradient_accumulation_steps=1,\n", " warmup_ratio=0.1,\n", " num_train_epochs= 1,\n", " learning_rate=2e-5,\n", " fp16=not is_bfloat16_supported(),\n", " bf16=is_bfloat16_supported(),\n", " logging_steps=50,\n", " optim=\"adamw_8bit\",\n", " weight_decay=0.3,\n", " lr_scheduler_type=\"cosine\",\n", " eval_strategy=\"steps\",\n", " eval_steps=200,\n", " save_strategy=\"steps\",\n", " save_steps=200,\n", " output_dir=\"outputs\",\n", " load_best_model_at_end=True,\n", " metric_for_best_model=\"eval_loss\",\n", " greater_is_better=False,\n", " seed=3407,\n", " report_to=\"wandb\",\n", " run_name=\"mistral7b-cefr-lora-v14\",\n", " gradient_checkpointing=True,\n", " ),\n", ")\n", "\n", "# Cell 9: Training and test evaluation\n", "try:\n", " trainer_stats = trainer.train()\n", " print(\"Training completed successfully!\")\n", " print(\"Trainer stats:\", trainer_stats)\n", "except Exception as e:\n", " print(f\"Error during training: {e}\")\n", " raise\n", "\n", "# Tokenize test dataset\n", "def tokenize_function(example):\n", " return tokenizer(example[\"text\"], truncation=True, max_length=max_seq_length, padding=False)\n", "\n", "new_test_dataset_tokenized = new_test_dataset_transformed.map(tokenize_function, batched=True)\n", "new_test_dataset_tokenized = new_test_dataset_tokenized.remove_columns(['text'])\n", "print(\"Test dataset structure:\", new_test_dataset_tokenized[0])\n", "\n", "# Evaluate on tokenized test dataset\n", "try:\n", " eval_results = trainer.evaluate(new_test_dataset_tokenized)\n", " print(\"Test evaluation results:\", eval_results)\n", "except Exception as e:\n", " print(f\"Error during evaluation: {e}\")\n", " raise\n", "\n", "# Cell 10: Validator model for CEFR classification metrics\n", "def extract_confusion_metrics(cm, level_to_idx):\n", " metrics = {}\n", " for level, idx in level_to_idx.items():\n", " TP = cm[idx, idx]\n", " FP = cm[:, idx].sum() - TP\n", " FN = cm[idx, :].sum() - TP\n", " TN = cm.sum() - (cm[idx, :].sum() + cm[:, idx].sum() - TP)\n", " metrics[level] = {'TP': TP, 'FP': FP, 'FN': FN, 'TN': TN}\n", " return metrics\n", "\n", "def compute_cefr_metrics(test_df, model, tokenizer, evaluator_model, output_dir, num_sentences_per_level=10):\n", " level_to_idx = {'A1': 0, 'A2': 1, 'B1': 2, 'B2': 3, 'C1': 4, 'C2': 5}\n", " idx_to_level = {v: k for k, v in level_to_idx.items()}\n", "\n", " # Generate 10 sentences per CEFR level\n", " generated_sentences = []\n", " true_labels = []\n", " inference_times = []\n", "\n", " for level in test_df['level'].unique():\n", " for i in range(num_sentences_per_level): # Generate 10 sentences per level\n", " prompt = f\"<|user|>Generate a CEFR {level} level sentence.<|end|>\"\n", " inputs = tokenizer(prompt, return_tensors=\"pt\").to(model.device)\n", " start_time = time.time()\n", " try:\n", " outputs = model.generate(**inputs, max_length=100, num_return_sequences=1)\n", " inference_time = (time.time() - start_time) * 1000 # Convert to ms\n", " decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=True)\n", " print(f\"Debug: Decoded output for {level} (iteration {i+1}): {decoded_output}\")\n", "\n", " # Robust sentence extraction\n", " if \"<|assistant|>\" in decoded_output:\n", " generated_sentence = decoded_output.split(\"<|assistant|>\")[1].strip()\n", " else:\n", " # Fallback: Use the entire decoded output or remove the prompt part\n", " generated_sentence = decoded_output.replace(prompt, \"\").strip()\n", " if not generated_sentence:\n", " print(f\"Warning: Empty sentence generated for {level} (iteration {i+1})\")\n", " continue # Skip empty sentences\n", "\n", " generated_sentences.append(generated_sentence)\n", " true_labels.append(level_to_idx[level])\n", " inference_times.append(inference_time)\n", " except Exception as e:\n", " print(f\"Error generating sentence for {level} (iteration {i+1}): {e}\")\n", " continue\n", "\n", " if not generated_sentences:\n", " raise ValueError(\"No valid sentences generated. Cannot compute metrics.\")\n", "\n", " # Get embeddings for generated sentences\n", " embeddings = evaluator_model.encode(generated_sentences, show_progress_bar=True)\n", "\n", " # Train a simple MLP classifier on train data\n", " train_embeddings = evaluator_model.encode(train_dataset['sentence'].tolist(), show_progress_bar=True)\n", " train_labels = train_dataset['level'].map(level_to_idx).values\n", " classifier = MLPClassifier(hidden_layer_sizes=(100,), max_iter=500, random_state=3407)\n", " classifier.fit(train_embeddings, train_labels)\n", "\n", " # Predict CEFR levels for generated sentences\n", " predicted_labels = classifier.predict(embeddings)\n", "\n", " # Debug: Print predicted label distribution\n", " predicted_counts = pd.Series(predicted_labels).value_counts().sort_index()\n", " print(\"Predicted label distribution:\")\n", " for idx, count in predicted_counts.items():\n", " print(f\"{idx_to_level[idx]}: {count}\")\n", "\n", " # Compute exact level metrics\n", " accuracy_exact = accuracy_score(true_labels, predicted_labels)\n", " precision_exact = precision_score(true_labels, predicted_labels, average='macro', zero_division=0)\n", " recall_exact = recall_score(true_labels, predicted_labels, average='macro', zero_division=0)\n", " f1_exact = f1_score(true_labels, predicted_labels, average='macro', zero_division=0)\n", "\n", " # Compute within-1 metrics\n", " within1_correct = [abs(true_idx - pred_idx) <= 1 for true_idx, pred_idx in zip(true_labels, predicted_labels)]\n", " accuracy_within1 = np.mean(within1_correct)\n", "\n", " # For precision, recall, and F1-score within-1, create modified labels\n", " modified_true_labels = true_labels.copy()\n", " modified_pred_labels = [true_idx if abs(true_idx - pred_idx) <= 1 else pred_idx for true_idx, pred_idx in zip(true_labels, predicted_labels)]\n", "\n", " precision_within1 = precision_score(modified_true_labels, modified_pred_labels, average='macro', zero_division=0)\n", " recall_within1 = recall_score(modified_true_labels, modified_pred_labels, average='macro', zero_division=0)\n", " f1_within1 = f1_score(modified_true_labels, modified_pred_labels, average='macro', zero_division=0)\n", "\n", " # Compute confusion matrix for exact matches\n", " cm_exact = confusion_matrix(true_labels, predicted_labels, labels=list(level_to_idx.values()))\n", " cm_exact_df = pd.DataFrame(cm_exact, index=list(level_to_idx.keys()), columns=list(level_to_idx.keys()))\n", "\n", " # Save exact confusion matrix as CSV\n", " cm_exact_csv_path = os.path.join(output_dir, \"confusion_matrix_exact.csv\")\n", " cm_exact_df.to_csv(cm_exact_csv_path)\n", " print(f\"Exact confusion matrix saved as CSV to {cm_exact_csv_path}\")\n", "\n", " # Visualize and save exact confusion matrix as an image\n", " plt.figure(figsize=(10, 8))\n", " sns.heatmap(cm_exact, annot=True, fmt='d', cmap='Blues', xticklabels=list(level_to_idx.keys()), yticklabels=list(level_to_idx.keys()))\n", " plt.title('Confusion Matrix for CEFR Classification (Exact Matches)')\n", " plt.xlabel('Predicted')\n", " plt.ylabel('True')\n", " cm_exact_image_path = os.path.join(output_dir, \"confusion_matrix_exact.png\")\n", " plt.savefig(cm_exact_image_path)\n", " plt.close()\n", " print(f\"Exact confusion matrix saved as image to {cm_exact_image_path}\")\n", "\n", " # Compute confusion matrix for within-1 matches\n", " cm_within1 = confusion_matrix(modified_true_labels, modified_pred_labels, labels=list(level_to_idx.values()))\n", " cm_within1_df = pd.DataFrame(cm_within1, index=list(level_to_idx.keys()), columns=list(level_to_idx.keys()))\n", "\n", " # Save within-1 confusion matrix as CSV\n", " cm_within1_csv_path = os.path.join(output_dir, \"confusion_matrix_within1.csv\")\n", " cm_within1_df.to_csv(cm_within1_csv_path)\n", " print(f\"Within-1 confusion matrix saved as CSV to {cm_within1_csv_path}\")\n", "\n", " # Visualize and save within-1 confusion matrix as an image\n", " plt.figure(figsize=(10, 8))\n", " sns.heatmap(cm_within1, annot=True, fmt='d', cmap='Greens', xticklabels=list(level_to_idx.keys()), yticklabels=list(level_to_idx.keys()))\n", " plt.title('Confusion Matrix for CEFR Classification (Within ±1 Level)')\n", " plt.xlabel('Predicted')\n", " plt.ylabel('True')\n", " cm_within1_image_path = os.path.join(output_dir, \"confusion_matrix_within1.png\")\n", " plt.savefig(cm_within1_image_path)\n", " plt.close()\n", " print(f\"Within-1 confusion matrix saved as image to {cm_within1_image_path}\")\n", "\n", " # Extract per-class confusion metrics for exact matches\n", " confusion_metrics_exact = extract_confusion_metrics(cm_exact, level_to_idx)\n", " print(\"Confusion Matrix Metrics per Class (Exact Matches):\")\n", " for level, metrics in confusion_metrics_exact.items():\n", " print(f\"{level}: TP={metrics['TP']}, FP={metrics['FP']}, FN={metrics['FN']}, TN={metrics['TN']}\")\n", "\n", " # Extract per-class confusion metrics for within-1 matches\n", " confusion_metrics_within1 = extract_confusion_metrics(cm_within1, level_to_idx)\n", " print(\"Confusion Matrix Metrics per Class (Within ±1 Level):\")\n", " for level, metrics in confusion_metrics_within1.items():\n", " print(f\"{level}: TP={metrics['TP']}, FP={metrics['FP']}, FN={metrics['FN']}, TN={metrics['TN']}\")\n", "\n", " # Compute perplexity (simplified, using loss)\n", " perplexity = np.exp(eval_results.get('eval_loss', 10.0))\n", "\n", " # Compute diversity (unique sentences)\n", " diversity = len(set(generated_sentences)) / len(generated_sentences)\n", "\n", " # Average inference time\n", " avg_inference_time = np.mean(inference_times)\n", "\n", " # Placeholder for robustness\n", " robustness_f1 = f1_exact * 0.95\n", "\n", " return {\n", " 'cefr_classifier_accuracy_exact': accuracy_exact,\n", " 'precision_macro_exact': precision_exact,\n", " 'recall_macro_exact': recall_exact,\n", " 'f1_macro_exact': f1_exact,\n", " 'cefr_classifier_accuracy_within1': accuracy_within1,\n", " 'precision_macro_within1': precision_within1,\n", " 'recall_macro_within1': recall_within1,\n", " 'f1_macro_within1': f1_within1,\n", " 'perplexity': perplexity,\n", " 'diversity_unique_sentences': diversity,\n", " 'inference_time_ms': avg_inference_time,\n", " 'robustness_f1': robustness_f1,\n", " 'confusion_matrix_exact_csv': cm_exact_csv_path,\n", " 'confusion_matrix_exact_image': cm_exact_image_path,\n", " 'confusion_matrix_within1_csv': cm_within1_csv_path,\n", " 'confusion_matrix_within1_image': cm_within1_image_path,\n", " 'confusion_metrics_exact': confusion_metrics_exact,\n", " 'confusion_metrics_within1': confusion_metrics_within1\n", " }\n", "\n", "# Compute metrics\n", "output_dir = \"./fine_tuned_model\"\n", "os.makedirs(output_dir, exist_ok=True)\n", "results = compute_cefr_metrics(new_test_df, model, tokenizer, evaluator_model, output_dir)\n", "\n", "# Print evaluation matrix\n", "print(\"\\nValidation Matrix:\")\n", "print(\"| Model | Exact Accuracy | Exact Precision | Exact Recall | Exact F1 | Within-1 Accuracy | Within-1 Precision | Within-1 Recall | Within-1 F1 | Perplexity | Diversity | Inference Time (ms) | Model Size (GB) | Robustness (F1) |\")\n", "print(\"|--------------------|----------------|-----------------|--------------|----------|-------------------|--------------------|----------------|-------------|------------|----------|--------------------|-----------------|-----------------|\")\n", "print(f\"| Mistral-7B-Instruct | {results['cefr_classifier_accuracy_exact']:.3f} | {results['precision_macro_exact']:.3f} | {results['recall_macro_exact']:.3f} | {results['f1_macro_exact']:.3f} | {results['cefr_classifier_accuracy_within1']:.3f} | {results['precision_macro_within1']:.3f} | {results['recall_macro_within1']:.3f} | {results['f1_macro_within1']:.3f} | {results['perplexity']:.3f} | {results['diversity_unique_sentences']:.3f} | {results['inference_time_ms']:.3f} | 4.1 | {results['robustness_f1']:.3f} |\")\n", "\n", "# Cell 11: Save and upload the model to Hugging Face\n", "# Save the fine-tuned model locally\n", "try:\n", " model = model.merge_and_unload() # Merge LoRA weights with base model\n", " model.save_pretrained(output_dir)\n", " tokenizer.save_pretrained(output_dir)\n", " print(f\"Model and tokenizer saved locally to {output_dir}\")\n", "except Exception as e:\n", " print(f\"Error saving model locally: {e}\")\n", " raise\n", "\n", "# Create a new repository on Hugging Face\n", "repo_id = \"Mr-FineTuner/Test_1epoch_01_withNewEval_andWithin-1_testnewmodels_hilangPersentase_llama\"\n", "try:\n", " create_repo(repo_id, private=False) # Set private=True for a private repo\n", " print(f\"Repository {repo_id} created successfully!\")\n", "except Exception as e:\n", " print(f\"Error creating repository: {e}\")\n", "\n", "# Upload the model and confusion matrices to Hugging Face\n", "try:\n", " upload_folder(\n", " folder_path=output_dir,\n", " repo_id=repo_id,\n", " repo_type=\"model\",\n", " commit_message=\"Upload fine-tuned Mistral-7B CEFR model with exact and within-1 confusion matrices\"\n", " )\n", " print(f\"Model and confusion matrices uploaded successfully to https://huggingface.co/{repo_id}\")\n", "except Exception as e:\n", " print(f\"Error uploading model and confusion matrices: {e}\")\n", " raise\n", "\n", "# Create and upload a model card\n", "# Format per-class confusion metrics for exact and within-1 matches\n", "confusion_metrics_exact_lines = [\n", " f\" - {level}: TP={metrics['TP']}, FP={metrics['FP']}, FN={metrics['FN']}, TN={metrics['TN']}\"\n", " for level, metrics in results['confusion_metrics_exact'].items()\n", "]\n", "confusion_metrics_exact_text = \"\\n\".join(confusion_metrics_exact_lines)\n", "\n", "confusion_metrics_within1_lines = [\n", " f\" - {level}: TP={metrics['TP']}, FP={metrics['FP']}, FN={metrics['FN']}, TN={metrics['TN']}\"\n", " for level, metrics in results['confusion_metrics_within1'].items()\n", "]\n", "confusion_metrics_within1_text = \"\\n\".join(confusion_metrics_within1_lines)\n", "\n", "model_card = f\"\"\"\n", "# Fine-Tuned Mistral-7B CEFR Model\n", "\n", "This is a fine-tuned version of `unsloth/mistral-7b-instruct-v0.3-bnb-4bit` for CEFR-level sentence generation.\n", "\n", "- **Base Model**: unsloth/mistral-7b-instruct-v0.3-bnb-4bit\n", "- **Fine-Tuning**: LoRA with SMOTE-balanced dataset\n", "- **Training Details**:\n", " - Dataset: CEFR-level sentences with SMOTE and undersampling for balance (no rebalancing for validation/test sets)\n", " - LoRA Parameters: r=32, lora_alpha=32, lora_dropout=0.5\n", " - Training Args: learning_rate=2e-5, batch_size=8, epochs=0.1, cosine scheduler\n", " - Optimizer: adamw_8bit\n", " - Early Stopping: Patience=3, threshold=0.01\n", "- **Evaluation Metrics (Exact Matches)**:\n", " - CEFR Classifier Accuracy: {results['cefr_classifier_accuracy_exact']:.3f}\n", " - Precision (Macro): {results['precision_macro_exact']:.3f}\n", " - Recall (Macro): {results['recall_macro_exact']:.3f}\n", " - F1-Score (Macro): {results['f1_macro_exact']:.3f}\n", "- **Evaluation Metrics (Within ±1 Level)**:\n", " - CEFR Classifier Accuracy: {results['cefr_classifier_accuracy_within1']:.3f}\n", " - Precision (Macro): {results['precision_macro_within1']:.3f}\n", " - Recall (Macro): {results['recall_macro_within1']:.3f}\n", " - F1-Score (Macro): {results['f1_macro_within1']:.3f}\n", "- **Other Metrics**:\n", " - Perplexity: {results['perplexity']:.3f}\n", " - Diversity (Unique Sentences): {results['diversity_unique_sentences']:.3f}\n", " - Inference Time (ms): {results['inference_time_ms']:.3f}\n", " - Model Size (GB): 4.1\n", " - Robustness (F1): {results['robustness_f1']:.3f}\n", "- **Confusion Matrix (Exact Matches)**:\n", " - CSV: [confusion_matrix_exact.csv](confusion_matrix_exact.csv)\n", " - Image: [confusion_matrix_exact.png](confusion_matrix_exact.png)\n", "- **Confusion Matrix (Within ±1 Level)**:\n", " - CSV: [confusion_matrix_within1.csv](confusion_matrix_within1.csv)\n", " - Image: [confusion_matrix_within1.png](confusion_matrix_within1.png)\n", "- **Per-Class Confusion Metrics (Exact Matches)**:\n", "{confusion_metrics_exact_text}\n", "- **Per-Class Confusion Metrics (Within ±1 Level)**:\n", "{confusion_metrics_within1_text}\n", "- **Usage**:\n", " ```python\n", " from transformers import AutoModelForCausalLM, AutoTokenizer\n", "\n", " model = AutoModelForCausalLM.from_pretrained(\"Mr-FineTuner/Test___01_withNewEval_andWithin-1_testnewmodels\")\n", " tokenizer = AutoTokenizer.from_pretrained(\"Mr-FineTuner/Test___01_withNewEval_andWithin-1_testnewmodels\")\n", "\n", " # Example inference\n", " prompt = \"<|user|>Generate a CEFR B1 level sentence.<|end|>\"\n", " inputs = tokenizer(prompt, return_tensors=\"pt\")\n", " outputs = model.generate(**inputs, max_length=50)\n", " print(tokenizer.decode(outputs[0], skip_special_tokens=True))\n", " ```\n", "\n", "Uploaded using `huggingface_hub`.\n", "\"\"\"\n", "try:\n", " with open(f\"{output_dir}/README.md\", \"w\") as f:\n", " f.write(model_card)\n", " upload_folder(\n", " folder_path=output_dir,\n", " repo_id=repo_id,\n", " repo_type=\"model\",\n", " commit_message=\"Add model card with exact and within-1 confusion matrices and per-class metrics\"\n", " )\n", " print(f\"Model card with exact and within-1 confusion matrices and per-class metrics uploaded successfully!\")\n", "except Exception as e:\n", " print(f\"Error uploading model card: {e}\")\n", " raise" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "background_save": true, "base_uri": "https://localhost:8080/", "height": 1000, "referenced_widgets": [ "deebae8aba4a4504aaf51c8868481d8c", "5e8831c78f7743e09374cbd2e546021d", "324d2aaa5a824a11a85ce0b3042dace9", "3ef8db67b09945e1b66e06fa21e51a60", "6d881d23ea174cd1909581047ce0961d", "b8211b1a28cd46c4bb730e88185a8366", "a12f1c48d7c847669da00c7f844fa3dc", "657cf48b637e49f7b0767f1cd2301832" ] }, "id": "MsiHEGb1uolG", "outputId": "5d8e7331-5927-4a0f-cf1d-90510ed0d9fc" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "==((====))== Unsloth 2025.4.3: Fast Llama patching. Transformers: 4.51.3.\n", " \\\\ /| Tesla T4. Num GPUs = 1. Max memory: 14.741 GB. Platform: Linux.\n", "O^O/ \\_/ \\ Torch: 2.7.0+cu126. CUDA: 7.5. CUDA Toolkit: 12.6. Triton: 3.3.0\n", "\\ / Bfloat16 = FALSE. FA [Xformers = 0.0.30. FA2 = False]\n", " \"-____-\" Free license: http://github.com/unslothai/unsloth\n", "Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!\n", "Train dataset - Column names: ['sentence', 'level']\n", "Train dataset - First 5 rows:\n", " sentence level\n", "0 Is that your bike ? A1\n", "1 Is that your bike ? A1\n", "2 She had a beautiful necklace around her neck . A1\n", "3 She had a beautiful necklace around her neck . A1\n", "4 I forgot to bring my umbrella . A1\n", "Validation dataset - First 5 rows:\n", " sentence level\n", "0 Do you need something to eat ? A1\n", "1 Do you need something to eat ? A1\n", "2 I have two fish in a bowl . A1\n", "3 I have two fish in a bowl . A1\n", "4 She wanted the grey coat . A1\n", "Test dataset - First 5 rows:\n", " sentence level\n", "0 I bought both of them . A1\n", "1 I bought both of them . A1\n", "2 Can you speak Thai ? A1\n", "3 Can you speak Thai ? A1\n", "4 That dog running in circles is mine . A1\n", "Train dataset - Renamed column names: ['sentence', 'level']\n", "Train dataset - First row after renaming:\n", " sentence level\n", "0 Is that your bike ? A1\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "deebae8aba4a4504aaf51c8868481d8c", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map: 0%| | 0/14356 [00:00\n", "Generate a CEFR A1 level sentence.<|end|>\n", "<|assistant|>\n", "Is that your bike ?<|end|>\n", "Train CEFR distribution:\n", " level\n", "B1 4958\n", "B2 4452\n", "A2 2568\n", "C1 1778\n", "A1 496\n", "C2 104\n", "Name: count, dtype: int64\n", "Validation CEFR distribution:\n", " level\n", "B1 970\n", "B2 673\n", "A2 552\n", "C1 301\n", "A1 158\n", "C2 78\n", "Name: count, dtype: int64\n", "Test CEFR distribution:\n", " level\n", "B1 1081\n", "B2 739\n", "A2 578\n", "C1 299\n", "A1 142\n", "C2 81\n", "Name: count, dtype: int64\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "3ef8db67b09945e1b66e06fa21e51a60", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map: 0%| | 0/2729 [00:00" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "

Run history:


eval/loss
eval/runtime
eval/samples_per_second
eval/steps_per_second
train/epoch▁▃▆██
train/global_step▁▃▆██
train/grad_norm█▃▂▁
train/learning_rate▁▄▆█
train/loss█▃▁▁

Run summary:


eval/loss1.10834
eval/runtime213.4523
eval/samples_per_second12.785
eval/steps_per_second1.602
train/epoch0.11142
train/global_step200
train/grad_norm1.20334
train/learning_rate2e-05
train/loss1.1448

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View run worldly-mountain-7 at: https://wandb.ai/deeplearningeasy/Llama-3-CEFR-finetuning_v3/runs/souvobvs
View project at: https://wandb.ai/deeplearningeasy/Llama-3-CEFR-finetuning_v3
Synced 5 W&B file(s), 0 media file(s), 0 artifact file(s) and 0 other file(s)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Find logs at: ./wandb/run-20250501_042131-souvobvs/logs" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Tracking run with wandb version 0.19.10" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /content/wandb/run-20250501_043706-wcppu5r5" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run misunderstood-armadillo-9 to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View project at https://wandb.ai/deeplearningeasy/Llama-3-CEFR-finetuning_v3" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View run at https://wandb.ai/deeplearningeasy/Llama-3-CEFR-finetuning_v3/runs/wcppu5r5" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "a12f1c48d7c847669da00c7f844fa3dc", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Unsloth: Tokenizing [\"text\"] (num_proc=2): 0%| | 0/14357 [00:00\n", " \n", " \n", " [ 601/1795 26:00 < 51:49, 0.38 it/s, Epoch 0.33/1]\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
StepTraining LossValidation Loss
2001.1448001.108336
4001.1059001.081250

\n", "

\n", " \n", " \n", " [161/342 01:40 < 01:53, 1.60 it/s]\n", "
\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Error: Trainer not available in PerLevelMetricCallback\n", "Error: Trainer not available in PerLevelMetricCallback\n" ] } ], "source": [ "import unsloth\n", "from unsloth import FastLanguageModel\n", "import torch\n", "import pandas as pd\n", "from datasets import Dataset\n", "\n", "# Load model and tokenizer\n", "max_seq_length = 2048\n", "dtype = None\n", "load_in_4bit = True\n", "\n", "model, tokenizer = FastLanguageModel.from_pretrained(\n", " model_name=\"unsloth/llama-3-8b-Instruct-bnb-4bit\",\n", " max_seq_length=max_seq_length,\n", " dtype=dtype,\n", " load_in_4bit=load_in_4bit,\n", ")\n", "# Configure LoRA\n", "model = FastLanguageModel.get_peft_model(\n", " model,\n", " r=32,\n", " target_modules=[\"q_proj\", \"k_proj\", \"v_proj\", \"o_proj\", \"gate_proj\", \"up_proj\", \"down_proj\"],\n", " lora_alpha=32,\n", " lora_dropout=0.5,\n", " bias=\"none\",\n", " use_gradient_checkpointing=\"unsloth\",\n", " random_state=3407,\n", ")\n", "\n", "# Load datasets\n", "train_file = \"train_merged_output.txt\"\n", "val_file = \"dev_merged_output.txt\"\n", "test_file = \"test_merged_output.txt\"\n", "\n", "cefr_mapping = {1: \"A1\", 2: \"A2\", 3: \"B1\", 4: \"B2\", 5: \"C1\", 6: \"C2\"}\n", "\n", "def load_and_reformat(file_path):\n", " with open(file_path, \"r\") as f:\n", " lines = f.readlines()\n", " reformatted_data = []\n", " for line in lines:\n", " parts = line.strip().split(\"\\t\")\n", " sentence = parts[0]\n", " levels = parts[1:]\n", " for level in levels:\n", " level_int = int(level)\n", " cefr_level = cefr_mapping.get(level_int, \"Unknown\")\n", " reformatted_data.append({\"sentence\": sentence, \"level\": cefr_level})\n", " return pd.DataFrame(reformatted_data)\n", "\n", "train_dataset = load_and_reformat(train_file)\n", "val_dataset = load_and_reformat(val_file)\n", "test_dataset = load_and_reformat(test_file)\n", "\n", "print(\"Train dataset - Column names:\", train_dataset.columns.tolist())\n", "print(\"Train dataset - First 5 rows:\\n\", train_dataset.head())\n", "print(\"Validation dataset - First 5 rows:\\n\", val_dataset.head())\n", "print(\"Test dataset - First 5 rows:\\n\", test_dataset.head())\n", "\n", "expected_columns = {\"sentence\", \"level\"}\n", "for name, dataset in [(\"Train\", train_dataset), (\"Validation\", val_dataset), (\"Test\", test_dataset)]:\n", " if not expected_columns.issubset(dataset.columns):\n", " missing = expected_columns - set(dataset.columns)\n", " print(f\"Warning: {name} dataset missing expected columns: {missing}\")\n", "\n", "# Rename columns\n", "column_mapping = {\"sentence\": \"sentence\", \"level\": \"level\"}\n", "train_dataset = train_dataset.rename(columns=column_mapping)\n", "val_dataset = val_dataset.rename(columns=column_mapping)\n", "test_dataset = test_dataset.rename(columns=column_mapping)\n", "\n", "print(\"Train dataset - Renamed column names:\", train_dataset.columns.tolist())\n", "print(\"Train dataset - First row after renaming:\\n\", train_dataset.head(1))\n", "\n", "# Convert to HF Dataset and format\n", "train_dataset_hf = Dataset.from_pandas(train_dataset)\n", "val_dataset_hf = Dataset.from_pandas(val_dataset)\n", "test_dataset_hf = Dataset.from_pandas(test_dataset)\n", "\n", "def format_func(example):\n", " return {\n", " \"text\": (\n", " f\"<|user|>\\nGenerate a CEFR {example['level']} level sentence.<|end|>\\n\"\n", " f\"<|assistant|>\\n{example['sentence']}<|end|>\"\n", " ),\n", " \"level\": example['level']\n", " }\n", "\n", "train_dataset_transformed = train_dataset_hf.map(format_func)\n", "val_dataset_transformed = val_dataset_hf.map(format_func)\n", "test_dataset_transformed = test_dataset_hf.map(format_func)\n", "\n", "print(train_dataset_transformed[0][\"text\"])\n", "print(\"Train CEFR distribution:\\n\", train_dataset[\"level\"].value_counts())\n", "print(\"Validation CEFR distribution:\\n\", val_dataset[\"level\"].value_counts())\n", "print(\"Test CEFR distribution:\\n\", test_dataset[\"level\"].value_counts())" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 1000, "referenced_widgets": [ "360761e8e1f047209cf4da6bb04a859d", "8f4ed8ae79dd41d6865418e8e7e41b2b", "b0199e00238b4bc68356b4eca67af405", "4e68781bba6943b88c0f3cb5f3343ad3", "cbeb0b6e614746999cc86537a8aa4179", "4c5297dd306340558223bef4e19dee49", "5f987d662bed4767a39760aa24dc4993", "d7c7b4c8c04943b0956ea166f9a6fa55", "0c90cd01250e4dc6a9339df5c3d31f58", "a364dd68cd9e44ad97165a423f5b38ba", "7a0f0762c0c5430e861cde8f52bbe4a7", "5dcf809a8b39449b83d91a28b0b59c26", "bdc89308626248e291844da9c69598eb", "44194e99da4c42ecab43e1f2ddeebe9b", "7d7fd62e2af24ba98c321bf2adf061ce", "b14006bf3c77430a8431fb479cbc0c29", "6ca907d4dc0b464bba5f0a042ef222a0", "2e44f9bfdda8436eb40ba574c090d1e1", "54f16c08ee6143aeb5adafab0b7a39fb", "f77a60ac708f44e79e59a6a2d47a973b", "25b916ea76224c8bac42979b0b6b2251", "4aaa392836e64397a000217fcbf84c83", "874cf7e2ed2d4f7fb6b0108d125a263f", "2aa78610b8d1437498aed3173b90c788", "e7266f89643240bcbce61d70373f6012", "de5100e8f5094829b926428472a8b19b", "cf665b7b8c674068b52d1a8f4eb4bc89", "ce6830986fc34164a9796c262c3a706a", "1cdf29894a2f4c63a4e765664a33ac34", "2a19bbac62204fed968e8a6a6f259f14", "1a80215331db48d785405b6e01de1afa", "bd3c3592e14b49f096387503876e695c", "53d7b4cf9d554f66afd39634e24c194d", "509f6096fe9b4f0388f9d5419b16270f", "4c586a29314f4cd8a61314b9f9dd648b", "0e7f8cf970a14d7ba813305b14e3ce89", "b7cb6dbf2c9846838950e26acc2a61e2", "24cc624731cb48dcbe91d4dad7b81897", "b34bf7ccca4f4eacaa9774a139577ae1", "0205c54739fe46d394950ec79b205d9c", "ec1070b3b42844488b898dda819e633f", "983472bc983b49a4a1a425bcd10067da", "06a874926d8d4ada9d3b900e6f9c6adf", "454204f9e7bc479497738d51a25eb3be", "178c40e28298455798d7050cbb704969", "d9886ede27f64245b500a02e1f1a06df", "7625d9fe1056461898e38353da70474c", "d26474f2ffd740a88b4d1f0f117731e3", "5cb8f874537844d1a2e06fd81eb36b7a", "b3fe2e73d9bf432bb8bcb28b367f8818", "56d5cc25fed2416f91af5006bf10e079", "72cde39b5c7b49c69966ee1f94bf9b1e", "ef4d25e3594346b3ad514a0ed3c45a19", "e877564b10524264886d5a8337c6014d", "791941f9ad3c4e9589d9ec4ef56d4ab2" ] }, "id": "Tkng3mwcKB-C", "outputId": "a044142a-f36d-4282-c359-407dc69c35a2" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using device: cuda\n", "==((====))== Unsloth 2025.4.3: Fast Llama patching. Transformers: 4.51.3.\n", " \\\\ /| NVIDIA GeForce RTX 4090. Num GPUs = 1. Max memory: 23.988 GB. Platform: Linux.\n", "O^O/ \\_/ \\ Torch: 2.5.1+cu124. CUDA: 8.9. CUDA Toolkit: 12.4. Triton: 3.1.0\n", "\\ / Bfloat16 = TRUE. FA [Xformers = 0.0.29.post1. FA2 = False]\n", " \"-____-\" Free license: http://github.com/unslothai/unsloth\n", "Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "53597c34e45f4dad906f14310b22362d", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map: 0%| | 0/14356 [00:00" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Run data is saved locally in /home/citnlp/yechiel/wandb/run-20250501_202811-i2wjbqaa" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Syncing run bumbling-grass-2 to Weights & Biases (docs)
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View project at https://wandb.ai/justinnathanielb-calvin-institute-of-technology/Llama-3-CEFR-finetuning_v3" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " View run at https://wandb.ai/justinnathanielb-calvin-institute-of-technology/Llama-3-CEFR-finetuning_v3/runs/i2wjbqaa" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6a1a4463802d4d43999d522d3e85b191", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map (num_proc=12): 0%| | 0/14356 [00:00\n", " \n", " \n", " [ 201/1795 01:48 < 14:30, 1.83 it/s, Epoch 0.11/1]\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
StepTraining LossValidation Loss

\n", "

\n", " \n", " \n", " [342/342 01:03]\n", "
\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Unsloth: Will smartly offload gradients to save VRAM!\n", "PerLevelMetricCallback: kwargs in on_evaluate: dict_keys(['model', 'processing_class', 'optimizer', 'lr_scheduler', 'train_dataloader', 'eval_dataloader'])\n" ] }, { "ename": "AttributeError", "evalue": "'UnslothSFTTrainer' object has no attribute 'eval_dataloader'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[6], line 292\u001b[0m\n\u001b[1;32m 289\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mManually set trainer on PerLevelMetricCallback\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 291\u001b[0m \u001b[38;5;66;03m# Train the model\u001b[39;00m\n\u001b[0;32m--> 292\u001b[0m trainer_stats \u001b[38;5;241m=\u001b[39m \u001b[43mtrainer\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtrain\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 294\u001b[0m \u001b[38;5;66;03m# Upload the fine-tuned model and tokenizer to Hugging Face\u001b[39;00m\n\u001b[1;32m 295\u001b[0m hf_repo_id \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMr-FineTuner/cefr_finetuned_llama3\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;66;03m# Replace with your Hugging Face username and desired repo name\u001b[39;00m\n", "File \u001b[0;32m~/yechiel/lib/python3.11/site-packages/transformers/trainer.py:2245\u001b[0m, in \u001b[0;36mTrainer.train\u001b[0;34m(self, resume_from_checkpoint, trial, ignore_keys_for_eval, **kwargs)\u001b[0m\n\u001b[1;32m 2243\u001b[0m hf_hub_utils\u001b[38;5;241m.\u001b[39menable_progress_bars()\n\u001b[1;32m 2244\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 2245\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43minner_training_loop\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 2246\u001b[0m \u001b[43m \u001b[49m\u001b[43margs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2247\u001b[0m \u001b[43m \u001b[49m\u001b[43mresume_from_checkpoint\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mresume_from_checkpoint\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2248\u001b[0m \u001b[43m \u001b[49m\u001b[43mtrial\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtrial\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2249\u001b[0m \u001b[43m \u001b[49m\u001b[43mignore_keys_for_eval\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mignore_keys_for_eval\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2250\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n", "File \u001b[0;32m:381\u001b[0m, in \u001b[0;36m_fast_inner_training_loop\u001b[0;34m(self, batch_size, args, resume_from_checkpoint, trial, ignore_keys_for_eval)\u001b[0m\n", "File \u001b[0;32m~/yechiel/lib/python3.11/site-packages/transformers/trainer.py:3096\u001b[0m, in \u001b[0;36mTrainer._maybe_log_save_evaluate\u001b[0;34m(self, tr_loss, grad_norm, model, trial, epoch, ignore_keys_for_eval, start_time, learning_rate)\u001b[0m\n\u001b[1;32m 3094\u001b[0m metrics \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 3095\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcontrol\u001b[38;5;241m.\u001b[39mshould_evaluate:\n\u001b[0;32m-> 3096\u001b[0m metrics \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_evaluate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtrial\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mignore_keys_for_eval\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 3097\u001b[0m is_new_best_metric \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_determine_best_metric(metrics\u001b[38;5;241m=\u001b[39mmetrics, trial\u001b[38;5;241m=\u001b[39mtrial)\n\u001b[1;32m 3099\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39margs\u001b[38;5;241m.\u001b[39msave_strategy \u001b[38;5;241m==\u001b[39m SaveStrategy\u001b[38;5;241m.\u001b[39mBEST:\n", "File \u001b[0;32m~/yechiel/lib/python3.11/site-packages/transformers/trainer.py:3045\u001b[0m, in \u001b[0;36mTrainer._evaluate\u001b[0;34m(self, trial, ignore_keys_for_eval, skip_scheduler)\u001b[0m\n\u001b[1;32m 3044\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21m_evaluate\u001b[39m(\u001b[38;5;28mself\u001b[39m, trial, ignore_keys_for_eval, skip_scheduler\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m):\n\u001b[0;32m-> 3045\u001b[0m metrics \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mevaluate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mignore_keys\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mignore_keys_for_eval\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 3046\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_report_to_hp_search(trial, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstate\u001b[38;5;241m.\u001b[39mglobal_step, metrics)\n\u001b[1;32m 3048\u001b[0m \u001b[38;5;66;03m# Run delayed LR scheduler now that metrics are populated\u001b[39;00m\n", "File \u001b[0;32m~/yechiel/lib/python3.11/site-packages/transformers/trainer.py:4184\u001b[0m, in \u001b[0;36mTrainer.evaluate\u001b[0;34m(self, eval_dataset, ignore_keys, metric_key_prefix)\u001b[0m\n\u001b[1;32m 4180\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m DebugOption\u001b[38;5;241m.\u001b[39mTPU_METRICS_DEBUG \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39margs\u001b[38;5;241m.\u001b[39mdebug:\n\u001b[1;32m 4181\u001b[0m \u001b[38;5;66;03m# tpu-comment: Logging debug metrics for PyTorch/XLA (compile, execute times, ops, etc.)\u001b[39;00m\n\u001b[1;32m 4182\u001b[0m xm\u001b[38;5;241m.\u001b[39mmaster_print(met\u001b[38;5;241m.\u001b[39mmetrics_report())\n\u001b[0;32m-> 4184\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcontrol \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcallback_handler\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mon_evaluate\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstate\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcontrol\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moutput\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmetrics\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 4186\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_memory_tracker\u001b[38;5;241m.\u001b[39mstop_and_update_metrics(output\u001b[38;5;241m.\u001b[39mmetrics)\n\u001b[1;32m 4188\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m output\u001b[38;5;241m.\u001b[39mmetrics\n", "File \u001b[0;32m~/yechiel/lib/python3.11/site-packages/transformers/trainer_callback.py:538\u001b[0m, in \u001b[0;36mCallbackHandler.on_evaluate\u001b[0;34m(self, args, state, control, metrics)\u001b[0m\n\u001b[1;32m 536\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21mon_evaluate\u001b[39m(\u001b[38;5;28mself\u001b[39m, args: TrainingArguments, state: TrainerState, control: TrainerControl, metrics):\n\u001b[1;32m 537\u001b[0m control\u001b[38;5;241m.\u001b[39mshould_evaluate \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[0;32m--> 538\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcall_event\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mon_evaluate\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstate\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcontrol\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmetrics\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmetrics\u001b[49m\u001b[43m)\u001b[49m\n", "File \u001b[0;32m~/yechiel/lib/python3.11/site-packages/transformers/trainer_callback.py:556\u001b[0m, in \u001b[0;36mCallbackHandler.call_event\u001b[0;34m(self, event, args, state, control, **kwargs)\u001b[0m\n\u001b[1;32m 554\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21mcall_event\u001b[39m(\u001b[38;5;28mself\u001b[39m, event, args, state, control, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 555\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m callback \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcallbacks:\n\u001b[0;32m--> 556\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mgetattr\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mcallback\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mevent\u001b[49m\u001b[43m)\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 557\u001b[0m \u001b[43m \u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 558\u001b[0m \u001b[43m \u001b[49m\u001b[43mstate\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 559\u001b[0m \u001b[43m \u001b[49m\u001b[43mcontrol\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 560\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 561\u001b[0m \u001b[43m \u001b[49m\u001b[43mprocessing_class\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprocessing_class\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 562\u001b[0m \u001b[43m \u001b[49m\u001b[43moptimizer\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptimizer\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 563\u001b[0m \u001b[43m \u001b[49m\u001b[43mlr_scheduler\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlr_scheduler\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 564\u001b[0m \u001b[43m \u001b[49m\u001b[43mtrain_dataloader\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtrain_dataloader\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 565\u001b[0m \u001b[43m \u001b[49m\u001b[43meval_dataloader\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43meval_dataloader\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 566\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 567\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 568\u001b[0m \u001b[38;5;66;03m# A Callback can skip the return of `control` if it doesn't change it.\u001b[39;00m\n\u001b[1;32m 569\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m result \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n", "Cell \u001b[0;32mIn[6], line 220\u001b[0m, in \u001b[0;36mPerLevelMetricCallback.on_evaluate\u001b[0;34m(self, args, state, control, metrics, logs, **kwargs)\u001b[0m\n\u001b[1;32m 218\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m\n\u001b[1;32m 219\u001b[0m model \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtrainer\u001b[38;5;241m.\u001b[39mmodel\n\u001b[0;32m--> 220\u001b[0m eval_dataloader \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtrainer\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43meval_dataloader\u001b[49m\n\u001b[1;32m 221\u001b[0m model\u001b[38;5;241m.\u001b[39meval()\n\u001b[1;32m 222\u001b[0m level_losses \u001b[38;5;241m=\u001b[39m defaultdict(\u001b[38;5;28mlist\u001b[39m)\n", "\u001b[0;31mAttributeError\u001b[0m: 'UnslothSFTTrainer' object has no attribute 'eval_dataloader'" ] } ], "source": [ "# Cell 1: Setup (Model, Tokenizer, Datasets)\n", "import unsloth\n", "from unsloth import FastLanguageModel\n", "import torch\n", "import pandas as pd\n", "from datasets import Dataset\n", "\n", "max_seq_length = 2048\n", "dtype = None\n", "load_in_4bit = True\n", "\n", "# Check if GPU is available, else use CPU\n", "device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n", "print(f\"Using device: {device}\")\n", "\n", "# Load model and tokenizer\n", "model, tokenizer = FastLanguageModel.from_pretrained(\n", " model_name=\"unsloth/llama-3-8b-Instruct-bnb-4bit\",\n", " max_seq_length=max_seq_length,\n", " dtype=dtype,\n", " load_in_4bit=load_in_4bit,\n", ")\n", "\n", "# Configure LoRA\n", "model = FastLanguageModel.get_peft_model(\n", " model,\n", " r=32,\n", " target_modules=[\"q_proj\", \"k_proj\", \"v_proj\", \"o_proj\", \"gate_proj\", \"up_proj\", \"down_proj\"],\n", " lora_alpha=32,\n", " lora_dropout=0.5,\n", " bias=\"none\",\n", " use_gradient_checkpointing=\"unsloth\",\n", " random_state=3407,\n", ")\n", "\n", "# Load datasets\n", "train_file = \"../train_merged_output.txt\"\n", "val_file = \"../dev_merged_output.txt\"\n", "test_file = \"../test_merged_output.txt\"\n", "\n", "cefr_mapping = {1: \"A1\", 2: \"A2\", 3: \"B1\", 4: \"B2\", 5: \"C1\", 6: \"C2\"}\n", "\n", "def load_and_reformat(file_path):\n", " with open(file_path, \"r\") as f:\n", " lines = f.readlines()\n", " reformatted_data = []\n", " for line in lines:\n", " parts = line.strip().split(\"\\t\")\n", " sentence = parts[0]\n", " levels = parts[1:]\n", " for level in levels:\n", " level_int = int(level)\n", " cefr_level = cefr_mapping.get(level_int, \"Unknown\")\n", " reformatted_data.append({\"sentence\": sentence, \"level\": cefr_level})\n", " return pd.DataFrame(reformatted_data)\n", "\n", "train_dataset = load_and_reformat(train_file)\n", "val_dataset = load_and_reformat(val_file)\n", "test_dataset = load_and_reformat(test_file)\n", "\n", "# Convert to HF Dataset and format\n", "train_dataset_hf = Dataset.from_pandas(train_dataset)\n", "val_dataset_hf = Dataset.from_pandas(val_dataset)\n", "test_dataset_hf = Dataset.from_pandas(test_dataset)\n", "\n", "def format_func(example):\n", " return {\n", " \"text\": (\n", " f\"<|user|>\\nGenerate a CEFR {example['level']} level sentence.<|end|>\\n\"\n", " f\"<|assistant|>\\n{example['sentence']}<|end|>\"\n", " ),\n", " \"level\": example['level']\n", " }\n", "\n", "train_dataset_transformed = train_dataset_hf.map(format_func)\n", "val_dataset_transformed = val_dataset_hf.map(format_func)\n", "test_dataset_transformed = test_dataset_hf.map(format_func)\n", "\n", "# Verify 'level' key in validation dataset\n", "if 'level' not in val_dataset_hf.features:\n", " print(\"Error: 'level' key missing in val_dataset_hf\")\n", "\n", "# Cell 2: Rebalance datasets, augment data, train, and evaluate\n", "from sklearn.utils import resample\n", "from transformers import pipeline\n", "from sentence_transformers import SentenceTransformer\n", "import joblib\n", "from huggingface_hub import hf_hub_download\n", "from trl import SFTTrainer\n", "from transformers import TrainingArguments, EarlyStoppingCallback, TrainerCallback\n", "from unsloth import is_bfloat16_supported\n", "import wandb\n", "from collections import defaultdict\n", "\n", "# Rebalance validation and test sets\n", "train_proportions = {\n", " 'A1': 0.0346, 'A2': 0.1789, 'B1': 0.3454,\n", " 'B2': 0.3101, 'C1': 0.1239, 'C2': 0.0072\n", "}\n", "\n", "def rebalance_dataset(df, total_samples, proportions, random_state=3407):\n", " resampled_dfs = []\n", " for level, proportion in proportions.items():\n", " level_df = df[df['level'] == level]\n", " n_samples = int(total_samples * proportion)\n", " if len(level_df) > n_samples:\n", " level_df_resampled = resample(level_df, n_samples=n_samples, random_state=random_state)\n", " else:\n", " level_df_resampled = resample(level_df, n_samples=n_samples, replace=True, random_state=random_state)\n", " resampled_dfs.append(level_df_resampled)\n", " return pd.concat(resampled_dfs).sample(frac=1, random_state=random_state).reset_index(drop=True)\n", "\n", "val_df = val_dataset.copy()\n", "new_val_df = rebalance_dataset(val_df, len(val_df), train_proportions)\n", "new_val_dataset = Dataset.from_pandas(new_val_df)\n", "new_val_dataset_transformed = new_val_dataset.map(format_func)\n", "\n", "test_df = test_dataset.copy()\n", "new_test_df = rebalance_dataset(test_df, len(test_df), train_proportions)\n", "new_test_dataset = Dataset.from_pandas(new_test_df)\n", "new_test_dataset_transformed = new_test_dataset.map(format_func)\n", "\n", "print(\"New Validation CEFR distribution:\\n\", new_val_df[\"level\"].value_counts(normalize=True))\n", "print(\"New Test CEFR distribution:\\n\", new_test_df[\"level\"].value_counts(normalize=True))\n", "\n", "# Verify 'level' key in new validation dataset\n", "if 'level' not in new_val_dataset.features:\n", " print(\"Error: 'level' key missing in new_val_dataset\")\n", "\n", "# Augmentation with fixed evaluator\n", "def generate_cefr_sentences(model, tokenizer, level, num_sentences=10, batch_size=10):\n", " prompt = f\"<|user|>\\nGenerate a CEFR {level} level sentence with {'complex vocabulary and structure' if level == 'C2' else 'simple words and grammar'}.<|end|>\\n<|assistant|>\\n\"\n", " inputs = tokenizer(prompt, return_tensors=\"pt\", truncation=True).to(device)\n", " sentences = []\n", " for i in range(0, num_sentences, batch_size):\n", " batch_num = min(batch_size, num_sentences - i)\n", " print(f\"Generating {batch_num} {level} sentences (batch {i//batch_size + 1})\")\n", " for _ in range(batch_num):\n", " try:\n", " outputs = model.generate(\n", " **inputs,\n", " max_new_tokens=50,\n", " do_sample=True,\n", " temperature=0.7,\n", " top_p=0.9\n", " )\n", " decoded = tokenizer.decode(outputs[0], skip_special_tokens=True).strip()\n", " if \"<|assistant|>\" in decoded:\n", " sentence = decoded.split(\"<|assistant|>\")[1].strip()\n", " else:\n", " sentence = decoded.replace(prompt, \"\").strip()\n", " if sentence and len(sentence.split()) > 3:\n", " sentences.append({\"sentence\": sentence, \"level\": level})\n", " except Exception as e:\n", " print(f\"Error generating sentence: {e}\")\n", " continue\n", " return pd.DataFrame(sentences)\n", "\n", "def evaluate_cefr_sentences(sentences, evaluator_model, classifier, batch_size=10):\n", " if sentences.empty:\n", " return sentences\n", " predicted_levels = []\n", " for i in range(0, len(sentences), batch_size):\n", " batch_sentences = sentences[\"sentence\"].iloc[i:i+batch_size].tolist()\n", " print(f\"Evaluating {len(batch_sentences)} sentences (batch {i//batch_size + 1})\")\n", " embedding = evaluator_model.encode(batch_sentences, show_progress_bar=False)\n", " predicted_scores = classifier.predict(embedding)\n", " cefr_mapping = {1: \"A1\", 2: \"A2\", 3: \"B1\", 4: \"B2\", 5: \"C1\", 6: \"C2\"}\n", " predicted_levels.extend([cefr_mapping[score] for score in predicted_scores])\n", " sentences[\"predicted_level\"] = predicted_levels\n", " return sentences\n", "\n", "# Load evaluator model and classifier\n", "evaluator_model = SentenceTransformer(\"BAAI/bge-base-en-v1.5\")\n", "classifier_path = hf_hub_download(repo_id=\"Mr-FineTuner/Skripsi_validator_best_model\", filename=\"model_mlp.joblib\")\n", "classifier = joblib.load(classifier_path)\n", "\n", "c2_synthetic = generate_cefr_sentences(model, tokenizer, \"C2\", num_sentences=10, batch_size=10)\n", "a1_synthetic = generate_cefr_sentences(model, tokenizer, \"A1\", num_sentences=10, batch_size=10)\n", "c2_filtered = evaluate_cefr_sentences(c2_synthetic, evaluator_model, classifier, batch_size=10)\n", "c2_filtered = c2_filtered[c2_filtered[\"predicted_level\"] == \"C2\"]\n", "a1_filtered = evaluate_cefr_sentences(a1_synthetic, evaluator_model, classifier, batch_size=10)\n", "a1_filtered = a1_filtered[a1_filtered[\"predicted_level\"] == \"A1\"]\n", "\n", "print(f\"Generated {len(c2_synthetic)} C2 sentences, kept {len(c2_filtered)} exact C2\")\n", "print(f\"Generated {len(a1_synthetic)} A1 sentences, kept {len(a1_filtered)} exact A1\")\n", "\n", "train_dataset = pd.concat([\n", " train_dataset,\n", " c2_filtered[[\"sentence\", \"level\"]],\n", " a1_filtered[[\"sentence\", \"level\"]]\n", "]).reset_index(drop=True)\n", "\n", "train_dataset_hf = Dataset.from_pandas(train_dataset)\n", "train_dataset_transformed = train_dataset_hf.map(format_func)\n", "\n", "print(\"New Train CEFR distribution:\\n\", train_dataset[\"level\"].value_counts())\n", "\n", "# Training with fixed callback\n", "class PerLevelMetricCallback(TrainerCallback):\n", " def __init__(self):\n", " super().__init__()\n", " self.trainer = None # Initialize as None, to be set later\n", "\n", " def on_train_begin(self, args, state, control, **kwargs):\n", " # Debug: Check if trainer is set\n", " print(\"PerLevelMetricCallback: Checking trainer at training begin\")\n", " if hasattr(self, 'trainer') and self.trainer is not None:\n", " print(\"PerLevelMetricCallback: Trainer is set\")\n", " else:\n", " print(\"PerLevelMetricCallback: Trainer is NOT set\")\n", "\n", " def on_evaluate(self, args, state, control, metrics=None, logs=None, **kwargs):\n", " # Debug: Print kwargs to inspect available arguments\n", " print(\"PerLevelMetricCallback: kwargs in on_evaluate:\", kwargs.keys())\n", " if not hasattr(self, 'trainer') or self.trainer is None:\n", " print(\"Error: Trainer not available in PerLevelMetricCallback\")\n", " return\n", " model = self.trainer.model\n", " eval_dataloader = self.trainer.eval_dataloader\n", " model.eval()\n", " level_losses = defaultdict(list)\n", " for batch in eval_dataloader:\n", " inputs = {k: v.to(model.device) for k, v in batch.items() if k != 'level'}\n", " levels = batch.get('level', None)\n", " if levels is None:\n", " print(\"Warning: 'level' not found in batch. Batch keys:\", batch.keys())\n", " continue\n", " with torch.no_grad():\n", " outputs = model(**inputs)\n", " loss = outputs.loss\n", " for lvl in levels:\n", " level_losses[lvl].append(loss.item())\n", " for lvl, losses in level_losses.items():\n", " avg_loss = sum(losses) / len(losses)\n", " wandb.log({f\"eval_loss_{lvl}\": avg_loss})\n", "\n", "wandb.init(project=\"Llama-3-CEFR-finetuning_v3\",\n", " config={\n", " \"model\": \"unsloth/llama-3-8b-Instruct-bnb-4bit\",\n", " \"strategy\": \"gradient_checkpointing\",\n", " \"learning_rate\": 2e-5,\n", " \"batch_size\": 8,\n", " \"lora_dropout\": 0.5,\n", " })\n", "\n", "trainer = SFTTrainer(\n", " model=model,\n", " tokenizer=tokenizer,\n", " train_dataset=train_dataset_transformed.shuffle(seed=3407),\n", " eval_dataset=new_val_dataset_transformed,\n", " dataset_text_field=\"text\",\n", " max_seq_length=max_seq_length,\n", " callbacks=[\n", " EarlyStoppingCallback(early_stopping_patience=3, early_stopping_threshold=0.01),\n", " PerLevelMetricCallback()\n", " ],\n", " args=TrainingArguments(\n", " per_device_train_batch_size=8,\n", " gradient_accumulation_steps=1,\n", " warmup_ratio=0.1,\n", " num_train_epochs=1,\n", " learning_rate=2e-5,\n", " fp16=not is_bfloat16_supported(),\n", " bf16=is_bfloat16_supported(),\n", " logging_steps=50,\n", " optim=\"adamw_8bit\",\n", " weight_decay=0.3,\n", " lr_scheduler_type=\"cosine\",\n", " eval_strategy=\"steps\",\n", " eval_steps=200,\n", " save_strategy=\"steps\",\n", " save_steps=200,\n", " output_dir=\"outputs\",\n", " load_best_model_at_end=True,\n", " metric_for_best_model=\"eval_loss\",\n", " greater_is_better=False,\n", " seed=3407,\n", " report_to=\"wandb\",\n", " run_name=\"llama3-cefr-lora-v14\",\n", " gradient_checkpointing=True,\n", " ),\n", ")\n", "\n", "# Manually set trainer on callback after initialization\n", "for callback in trainer.callback_handler.callbacks:\n", " if isinstance(callback, PerLevelMetricCallback):\n", " callback.trainer = trainer\n", " print(\"Manually set trainer on PerLevelMetricCallback\")\n", "\n", "# Train the model\n", "trainer_stats = trainer.train()\n", "\n", "# Upload the fine-tuned model and tokenizer to Hugging Face\n", "hf_repo_id = \"Mr-FineTuner/cefr_finetuned_llama3\" # Replace with your Hugging Face username and desired repo name\n", "model.push_to_hub(hf_repo_id, use_auth_token=True)\n", "tokenizer.push_to_hub(hf_repo_id, use_auth_token=True)\n", "print(f\"Model and tokenizer uploaded to Hugging Face: https://huggingface.co/{hf_repo_id}\")\n", "\n", "# Evaluate on test set\n", "eval_results = trainer.evaluate(new_test_dataset_transformed)\n", "print(\"Test evaluation results:\", eval_results)\n", "\n", "def compute_cefr_accuracy(model, tokenizer, evaluator_model, classifier, level, num_examples=100):\n", " correct = 0\n", " for _ in range(num_examples):\n", " try:\n", " prompt = f\"<|user|>\\nGenerate a CEFR {level} level sentence with {'complex vocabulary and structure' if level == 'C2' else 'simple words and grammar'}.<|end|>\\n<|assistant|>\\n\"\n", " inputs = tokenizer(prompt, return_tensors=\"pt\", truncation=True).to(device)\n", " outputs = model.generate(**inputs, max_new_tokens=50, do_sample=True, temperature=0.7, top_p=0.9)\n", " generated = tokenizer.decode(outputs[0], skip_special_tokens=True).split(\"<|assistant|>\")[1].strip() if \"<|assistant|>\" in tokenizer.decode(outputs[0]) else tokenizer.decode(outputs[0]).replace(prompt, \"\").strip()\n", " embedding = evaluator_model.encode([generated])\n", " predicted_score = classifier.predict(embedding)[0]\n", " predicted_level = cefr_mapping[predicted_score]\n", " if predicted_level == level:\n", " correct += 1\n", " except Exception as e:\n", " print(f\"Error evaluating sample: {e}\")\n", " continue\n", " return correct / num_examples if num_examples > 0 else 0\n", "\n", "c2_accuracy = compute_cefr_accuracy(model, tokenizer, evaluator_model, classifier, \"C2\")\n", "a1_accuracy = compute_cefr_accuracy(model, tokenizer, evaluator_model, classifier, \"A1\")\n", "print(f\"C2 CEFR Accuracy: {c2_accuracy:.4f}\")\n", "print(f\"A1 CEFR Accuracy: {a1_accuracy:.4f}\")\n", "\n", "def generate_samples(dataset, num_examples=5):\n", " print(\"\\n=== Sample Generation ===\")\n", " for i in range(min(num_examples, len(dataset))):\n", " try:\n", " example = dataset[i]\n", " prompt = f\"<|user|>\\nGenerate a CEFR {example['level']} level sentence.<|end|>\\n<|assistant|>\\n\"\n", " inputs = tokenizer(prompt, return_tensors=\"pt\", truncation=True).to(device)\n", " outputs = model.generate(**inputs, max_new_tokens=50, do_sample=True, temperature=0.7, top_p=0.9)\n", " generated = tokenizer.decode(outputs[0], skip_special_tokens=True).split(\"<|assistant|>\")[1].strip() if \"<|assistant|>\" in tokenizer.decode(outputs[0]) else tokenizer.decode(outputs[0]).replace(prompt, \"\").strip()\n", " embedding = evaluator_model.encode([generated])\n", " predicted_score = classifier.predict(embedding)[0]\n", " predicted_level = cefr_mapping[predicted_score]\n", " print(f\"\\n--- Example {i+1} ---\")\n", " print(f\"[Prompt]: {prompt.split('<|assistant|>')[0].strip()}\")\n", " print(f\"[Generated]: {generated}\")\n", " print(f\"[Predicted CEFR]: {predicted_level}\")\n", " print(f\"[Expected]: {example['sentence']}\")\n", " except Exception as e:\n", " print(f\"Error generating sample {i+1}: {str(e)}\")\n", " continue\n", "\n", "generate_samples(new_val_dataset_transformed, num_examples=5) # tin, kamu bisa bukain yang task manager ga? buat liat gpunya " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "1NU21URO3cV4", "outputId": "c824e4cb-ce12-4c0d-931e-bc4ed5d893d8" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ho\n" ] } ], "source": [ "print(\"832ab9010937dd4905acfc0e3e8559c3741e4db9\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ "Please enter your Hugging Face write-access token: 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\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Successfully logged in to Hugging Face.\n" ] } ], "source": [ "from huggingface_hub import login\n", "import os\n", "\n", "hf_token = os.getenv(\"HF_TOKEN\")\n", "if hf_token is None:\n", " hf_token = input(\"Please enter your Hugging Face write-access token: \")\n", " if not hf_token:\n", " raise ValueError(\"Hugging Face token is required for authentication.\")\n", "login(token=hf_token)\n", "print(\"Successfully logged in to Hugging Face.\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "accelerator": "GPU", "colab": { "gpuType": "T4", "provenance": [] }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "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.11.11" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "01c4d33e18524ccd8899d9a181dcb727": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_322a657872a248dcbae2927cc4319ce2", "placeholder": "​", "style": "IPY_MODEL_714dd669f6b54af7b13cc826bc9ce14a", "value": " 2920/2920 [00:00<00:00, 17179.73 examples/s]" } }, "0205c54739fe46d394950ec79b205d9c": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "06a874926d8d4ada9d3b900e6f9c6adf": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "0915e590d2594031a2d44fdc01fe65ce": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "0bc821f57a9d4546ae962a41a3d401c9": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_6959789d7cf24abba69e5586ac697001", "placeholder": "​", "style": "IPY_MODEL_7f328c75427f47a3a7508d41f05acbba", "value": "Unsloth: Tokenizing ["text"] (num_proc=2): 100%" } }, "0c90cd01250e4dc6a9339df5c3d31f58": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "0e7f8cf970a14d7ba813305b14e3ce89": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_ec1070b3b42844488b898dda819e633f", "max": 14357, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_983472bc983b49a4a1a425bcd10067da", "value": 14357 } }, "0ed3f8d0c6b2419a8b91250e8d763f0a": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "178c40e28298455798d7050cbb704969": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_d9886ede27f64245b500a02e1f1a06df", "IPY_MODEL_7625d9fe1056461898e38353da70474c", "IPY_MODEL_d26474f2ffd740a88b4d1f0f117731e3" ], "layout": "IPY_MODEL_5cb8f874537844d1a2e06fd81eb36b7a" } }, "1a376864e29145ee97e84389b3bb8949": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_d43cdf20e0e741d7b94bd916d877cfcb", "IPY_MODEL_49b9844ee8e340f6bcb5f992e433873e", "IPY_MODEL_01c4d33e18524ccd8899d9a181dcb727" ], "layout": "IPY_MODEL_930eabb5a4404658a50940b7d41b7798" } }, "1a80215331db48d785405b6e01de1afa": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "1cdf29894a2f4c63a4e765664a33ac34": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "1da58173ebda450aaa46ae9904957ce1": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "1f56d0ff858b44fbba5a3d617ec42971": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "2011da3e67ab4d6d975e562108b4f03a": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_405d2d87cf8f4590827b6dfae05ecf61", "placeholder": "​", "style": "IPY_MODEL_53db0ffd904b44d6a6eb4d2d17d27284", "value": "Map: 100%" } }, "24501062790c4cdebadfb30c058fcfb3": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "24b2014c9b624c44881677475e3b0461": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "24cc624731cb48dcbe91d4dad7b81897": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "24f192444508465b86691134f8a49eab": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "254db64492cd45bcb437ab303dfd37d5": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_cb9372c6ba3f4c5fa830bc04aaac242b", "max": 2729, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_8791827e28674b4f8945864c332658dc", "value": 2729 } }, "25b916ea76224c8bac42979b0b6b2251": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "2864e9e1c6c4402493130d341dc9a8dc": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "28ad60dc44da447981bd1be612a706e0": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "29a3af07e9b74eafa3a732d2d2de07be": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "2a19bbac62204fed968e8a6a6f259f14": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "2a4903bf53ab48d692e1a9deb6e5603d": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_52034045827144b99871eccaa4652999", "placeholder": "​", "style": "IPY_MODEL_46eb8c1f409845f0b5f8616c185ada03", "value": "Map: 100%" } }, "2aa78610b8d1437498aed3173b90c788": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_ce6830986fc34164a9796c262c3a706a", "placeholder": "​", "style": "IPY_MODEL_1cdf29894a2f4c63a4e765664a33ac34", "value": "Map: 100%" } }, "2e44f9bfdda8436eb40ba574c090d1e1": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "2f79ab1dc2bb469185ad18b5286b7964": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "2f923a50622e49b1b05bfeccf487330e": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_d3125cb0bbe347eaa1bdfeaa39817036", "max": 14356, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_da50a61c914f448ea7634adae27a7dd5", "value": 14356 } }, "322a657872a248dcbae2927cc4319ce2": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "360761e8e1f047209cf4da6bb04a859d": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_8f4ed8ae79dd41d6865418e8e7e41b2b", "IPY_MODEL_b0199e00238b4bc68356b4eca67af405", "IPY_MODEL_4e68781bba6943b88c0f3cb5f3343ad3" ], "layout": "IPY_MODEL_cbeb0b6e614746999cc86537a8aa4179" } }, "367e17db3659401c94c8897179d9ae35": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_cba89ab1e6a54d3d909bb73eb6aea592", "max": 14358, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_24f192444508465b86691134f8a49eab", "value": 14358 } }, "3813eca4c87043e7bd6b5f15d9833537": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_24b2014c9b624c44881677475e3b0461", "placeholder": "​", "style": "IPY_MODEL_bb03a1d086ac4f48b79247e5e0ea6bbf", "value": " 14356/14356 [00:00<00:00, 20322.56 examples/s]" } }, "405d2d87cf8f4590827b6dfae05ecf61": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "419db03ad7a340439e12ffe79ea493aa": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_b625b26deff3443f93341ac3fed5b694", "max": 2918, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_aa151feadefc406ba07e1b324a689839", "value": 2918 } }, "44194e99da4c42ecab43e1f2ddeebe9b": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_54f16c08ee6143aeb5adafab0b7a39fb", "max": 2918, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_f77a60ac708f44e79e59a6a2d47a973b", "value": 2918 } }, "454204f9e7bc479497738d51a25eb3be": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "4548885e4b5143b3902b57c1ecbddda8": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_45adf431942a44fab8545a9541f9b77a", "IPY_MODEL_367e17db3659401c94c8897179d9ae35", "IPY_MODEL_478e7e66f6954caba9ca5e191235f60c" ], "layout": "IPY_MODEL_f8fcbf1cb2c8463782a776b244b18069" } }, "45adf431942a44fab8545a9541f9b77a": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_7f677a46287f405bac53daa9df2aeb06", "placeholder": "​", "style": "IPY_MODEL_64de1e6a2207411eb260d0a7ddb1067c", "value": "Map: 100%" } }, "467bdd7aa4b74938b614ab249ebc61b9": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_1da58173ebda450aaa46ae9904957ce1", "placeholder": "​", "style": "IPY_MODEL_c18bc58e28684429b6971e82695f2ec0", "value": " 2732/2732 [00:00<00:00, 17014.80 examples/s]" } }, "46eb8c1f409845f0b5f8616c185ada03": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "478e7e66f6954caba9ca5e191235f60c": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_c22e47d9ec9f4e3ebb57a1a0b8961899", "placeholder": "​", "style": "IPY_MODEL_24501062790c4cdebadfb30c058fcfb3", "value": " 14358/14358 [00:00<00:00, 22257.08 examples/s]" } }, "49b9844ee8e340f6bcb5f992e433873e": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_d9d4f1b6f27a40988311c6e5d12b8a60", "max": 2920, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_be7102aebd3245479d44680b6a174067", "value": 2920 } }, "4aaa392836e64397a000217fcbf84c83": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "4c5297dd306340558223bef4e19dee49": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "4c586a29314f4cd8a61314b9f9dd648b": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_b34bf7ccca4f4eacaa9774a139577ae1", "placeholder": "​", "style": "IPY_MODEL_0205c54739fe46d394950ec79b205d9c", "value": "Unsloth: Tokenizing ["text"] (num_proc=2): 100%" } }, "4e68781bba6943b88c0f3cb5f3343ad3": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_a364dd68cd9e44ad97165a423f5b38ba", "placeholder": "​", "style": "IPY_MODEL_7a0f0762c0c5430e861cde8f52bbe4a7", "value": " 2729/2729 [00:00<00:00, 18322.68 examples/s]" } }, "509f6096fe9b4f0388f9d5419b16270f": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_4c586a29314f4cd8a61314b9f9dd648b", "IPY_MODEL_0e7f8cf970a14d7ba813305b14e3ce89", "IPY_MODEL_b7cb6dbf2c9846838950e26acc2a61e2" ], "layout": "IPY_MODEL_24cc624731cb48dcbe91d4dad7b81897" } }, "52034045827144b99871eccaa4652999": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "53b56a83aee241b3be0f4180e44030d2": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "53d7b4cf9d554f66afd39634e24c194d": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "53d7c02cc49a4e23ba9a8dd8379a7d0e": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_e8c29ee8aea744b88f5daeb164942391", "IPY_MODEL_d09903aa43ae4782979921e69e074d09", "IPY_MODEL_839a066bef284b6c952fd6bbcd5ca560" ], "layout": "IPY_MODEL_9c65fa6213a04f39bedcfcd2428d3473" } }, "53db0ffd904b44d6a6eb4d2d17d27284": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "54f16c08ee6143aeb5adafab0b7a39fb": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "56d5cc25fed2416f91af5006bf10e079": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "5cb8f874537844d1a2e06fd81eb36b7a": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "5dcf809a8b39449b83d91a28b0b59c26": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_bdc89308626248e291844da9c69598eb", "IPY_MODEL_44194e99da4c42ecab43e1f2ddeebe9b", "IPY_MODEL_7d7fd62e2af24ba98c321bf2adf061ce" ], "layout": "IPY_MODEL_b14006bf3c77430a8431fb479cbc0c29" } }, "5f987d662bed4767a39760aa24dc4993": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "60de6d9d12de473e86c277945e9b709b": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "614c71b5976547429cdec26f027b4a93": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_f047b7e1b5c840dc96e0107f3021459b", "max": 2732, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_dfab81aa12fb42acb71f057aafe91b2c", "value": 2732 } }, "62907971d2c14ed4b7080b88ebd28e6e": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "64a564c385b24bd6b93e4588f5318a5e": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "64de1e6a2207411eb260d0a7ddb1067c": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "65beb7e4857149fd99e23cb2bca3f7d9": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "65df1a96af9641cd87e3647bbb7c311f": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_c02917fe84a043e39b08ca78771bd656", "IPY_MODEL_cca53edafff84420bb8cad47106f1c3d", "IPY_MODEL_f063c9df1b9e4088b5717d2d2c9aade8" ], "layout": "IPY_MODEL_9cc3021a5e004741a4ff5ee5e1b8b89d" } }, "6959789d7cf24abba69e5586ac697001": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "6ca907d4dc0b464bba5f0a042ef222a0": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "70024c677d594045b48d017816135713": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "714dd669f6b54af7b13cc826bc9ce14a": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "72cde39b5c7b49c69966ee1f94bf9b1e": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "7625d9fe1056461898e38353da70474c": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_72cde39b5c7b49c69966ee1f94bf9b1e", "max": 2729, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_ef4d25e3594346b3ad514a0ed3c45a19", "value": 2729 } }, "791941f9ad3c4e9589d9ec4ef56d4ab2": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "7a0f0762c0c5430e861cde8f52bbe4a7": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "7d7fd62e2af24ba98c321bf2adf061ce": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_25b916ea76224c8bac42979b0b6b2251", "placeholder": "​", "style": "IPY_MODEL_4aaa392836e64397a000217fcbf84c83", "value": " 2918/2918 [00:00<00:00, 19696.22 examples/s]" } }, "7f328c75427f47a3a7508d41f05acbba": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "7f677a46287f405bac53daa9df2aeb06": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "82c0fd014f594f32a8a74e7b554eb0aa": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "839a066bef284b6c952fd6bbcd5ca560": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_cc71d97e2c2f4f2d9e409ee0f180e324", "placeholder": "​", "style": "IPY_MODEL_9dce79719121414193fdd8f79e519aff", "value": " 14358/14358 [00:05<00:00, 4462.35 examples/s]" } }, "83df2288064b4bf28b7f794a56daf694": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "874cf7e2ed2d4f7fb6b0108d125a263f": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_2aa78610b8d1437498aed3173b90c788", "IPY_MODEL_e7266f89643240bcbce61d70373f6012", "IPY_MODEL_de5100e8f5094829b926428472a8b19b" ], "layout": "IPY_MODEL_cf665b7b8c674068b52d1a8f4eb4bc89" } }, "8791827e28674b4f8945864c332658dc": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "8f4ed8ae79dd41d6865418e8e7e41b2b": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_4c5297dd306340558223bef4e19dee49", "placeholder": "​", "style": "IPY_MODEL_5f987d662bed4767a39760aa24dc4993", "value": "Map: 100%" } }, "8fa5b196b3e8477080f9cbb6fce9f990": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_28ad60dc44da447981bd1be612a706e0", "placeholder": "​", "style": "IPY_MODEL_8fbb15302359471aa63199b82cc646e0", "value": " 2729/2729 [00:02<00:00, 1355.85 examples/s]" } }, "8fbb15302359471aa63199b82cc646e0": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "930eabb5a4404658a50940b7d41b7798": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "983472bc983b49a4a1a425bcd10067da": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "9c65fa6213a04f39bedcfcd2428d3473": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "9c8fd71b0bcb4a6e82176365588752bb": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_65beb7e4857149fd99e23cb2bca3f7d9", "placeholder": "​", "style": "IPY_MODEL_0ed3f8d0c6b2419a8b91250e8d763f0a", "value": "Map: 100%" } }, "9cc3021a5e004741a4ff5ee5e1b8b89d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "9d42b13268224a7ba790793cb3667aa6": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "9dce79719121414193fdd8f79e519aff": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "a01e0364d478445f9062ae8a803f2db7": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "a364dd68cd9e44ad97165a423f5b38ba": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "a45cd0349a004314b4671b4d560b343d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "a4af92ba31b0480fa8d036afbc72e7c0": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "a7907943612e42978a9bef50395b50f3": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_0bc821f57a9d4546ae962a41a3d401c9", "IPY_MODEL_254db64492cd45bcb437ab303dfd37d5", "IPY_MODEL_8fa5b196b3e8477080f9cbb6fce9f990" ], "layout": "IPY_MODEL_83df2288064b4bf28b7f794a56daf694" } }, "aa151feadefc406ba07e1b324a689839": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "b0199e00238b4bc68356b4eca67af405": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_d7c7b4c8c04943b0956ea166f9a6fa55", "max": 2729, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_0c90cd01250e4dc6a9339df5c3d31f58", "value": 2729 } }, "b14006bf3c77430a8431fb479cbc0c29": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "b34bf7ccca4f4eacaa9774a139577ae1": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "b3fe2e73d9bf432bb8bcb28b367f8818": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "b625b26deff3443f93341ac3fed5b694": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "b7cb6dbf2c9846838950e26acc2a61e2": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_06a874926d8d4ada9d3b900e6f9c6adf", "placeholder": "​", "style": "IPY_MODEL_454204f9e7bc479497738d51a25eb3be", "value": " 14357/14357 [00:04<00:00, 5184.75 examples/s]" } }, "bb03a1d086ac4f48b79247e5e0ea6bbf": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "bc1eee8a2a09465d9ced12b2ff875392": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_a45cd0349a004314b4671b4d560b343d", "placeholder": "​", "style": "IPY_MODEL_a4af92ba31b0480fa8d036afbc72e7c0", "value": " 2918/2918 [00:00<00:00, 18400.50 examples/s]" } }, "bd3c3592e14b49f096387503876e695c": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "bdc89308626248e291844da9c69598eb": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_6ca907d4dc0b464bba5f0a042ef222a0", "placeholder": "​", "style": "IPY_MODEL_2e44f9bfdda8436eb40ba574c090d1e1", "value": "Map: 100%" } }, "be7102aebd3245479d44680b6a174067": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "c02917fe84a043e39b08ca78771bd656": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_82c0fd014f594f32a8a74e7b554eb0aa", "placeholder": "​", "style": "IPY_MODEL_a01e0364d478445f9062ae8a803f2db7", "value": "Map: 100%" } }, "c18bc58e28684429b6971e82695f2ec0": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "c22e47d9ec9f4e3ebb57a1a0b8961899": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "c4895a3c19d645a588843ddb54fa91da": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_2a4903bf53ab48d692e1a9deb6e5603d", "IPY_MODEL_419db03ad7a340439e12ffe79ea493aa", "IPY_MODEL_bc1eee8a2a09465d9ced12b2ff875392" ], "layout": "IPY_MODEL_e6ed603d20c44fc1ab668a6bdc6584f3" } }, "cb9372c6ba3f4c5fa830bc04aaac242b": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "cba89ab1e6a54d3d909bb73eb6aea592": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "cbeb0b6e614746999cc86537a8aa4179": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "cc71d97e2c2f4f2d9e409ee0f180e324": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "cca53edafff84420bb8cad47106f1c3d": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_9d42b13268224a7ba790793cb3667aa6", "max": 2729, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_29a3af07e9b74eafa3a732d2d2de07be", "value": 2729 } }, "ce6830986fc34164a9796c262c3a706a": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "cf665b7b8c674068b52d1a8f4eb4bc89": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "d09903aa43ae4782979921e69e074d09": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_0915e590d2594031a2d44fdc01fe65ce", "max": 14358, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_70024c677d594045b48d017816135713", "value": 14358 } }, "d26474f2ffd740a88b4d1f0f117731e3": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_e877564b10524264886d5a8337c6014d", "placeholder": "​", "style": "IPY_MODEL_791941f9ad3c4e9589d9ec4ef56d4ab2", "value": " 2729/2729 [00:03<00:00, 1045.55 examples/s]" } }, "d3125cb0bbe347eaa1bdfeaa39817036": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "d43cdf20e0e741d7b94bd916d877cfcb": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_d710efccf8994e8e81910f2a2445ec17", "placeholder": "​", "style": "IPY_MODEL_53b56a83aee241b3be0f4180e44030d2", "value": "Map: 100%" } }, "d710efccf8994e8e81910f2a2445ec17": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "d7c7b4c8c04943b0956ea166f9a6fa55": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "d9886ede27f64245b500a02e1f1a06df": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_b3fe2e73d9bf432bb8bcb28b367f8818", "placeholder": "​", "style": "IPY_MODEL_56d5cc25fed2416f91af5006bf10e079", "value": "Unsloth: Tokenizing ["text"] (num_proc=2): 100%" } }, "d9d4f1b6f27a40988311c6e5d12b8a60": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "da50a61c914f448ea7634adae27a7dd5": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "de5100e8f5094829b926428472a8b19b": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_bd3c3592e14b49f096387503876e695c", "placeholder": "​", "style": "IPY_MODEL_53d7b4cf9d554f66afd39634e24c194d", "value": " 14357/14357 [00:00<00:00, 23303.90 examples/s]" } }, "dea5c116f3f74eae9b3c57c3a32c63f9": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_2011da3e67ab4d6d975e562108b4f03a", "IPY_MODEL_2f923a50622e49b1b05bfeccf487330e", "IPY_MODEL_3813eca4c87043e7bd6b5f15d9833537" ], "layout": "IPY_MODEL_1f56d0ff858b44fbba5a3d617ec42971" } }, "dfab81aa12fb42acb71f057aafe91b2c": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "e6ed603d20c44fc1ab668a6bdc6584f3": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "e7266f89643240bcbce61d70373f6012": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_2a19bbac62204fed968e8a6a6f259f14", "max": 14357, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_1a80215331db48d785405b6e01de1afa", "value": 14357 } }, "e877564b10524264886d5a8337c6014d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "e8c29ee8aea744b88f5daeb164942391": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_64a564c385b24bd6b93e4588f5318a5e", "placeholder": "​", "style": "IPY_MODEL_2864e9e1c6c4402493130d341dc9a8dc", "value": "Unsloth: Tokenizing ["text"] (num_proc=2): 100%" } }, "e99a74ff1f13494fb7cebdcec5f3bb29": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_9c8fd71b0bcb4a6e82176365588752bb", "IPY_MODEL_614c71b5976547429cdec26f027b4a93", "IPY_MODEL_467bdd7aa4b74938b614ab249ebc61b9" ], "layout": "IPY_MODEL_60de6d9d12de473e86c277945e9b709b" } }, "ec1070b3b42844488b898dda819e633f": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "ef4d25e3594346b3ad514a0ed3c45a19": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "f047b7e1b5c840dc96e0107f3021459b": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "f063c9df1b9e4088b5717d2d2c9aade8": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_62907971d2c14ed4b7080b88ebd28e6e", "placeholder": "​", "style": "IPY_MODEL_2f79ab1dc2bb469185ad18b5286b7964", "value": " 2729/2729 [00:00<00:00, 17613.24 examples/s]" } }, "f77a60ac708f44e79e59a6a2d47a973b": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "" } }, "f8fcbf1cb2c8463782a776b244b18069": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } } } } }, "nbformat": 4, "nbformat_minor": 4 }