jpruzcuen
commited on
Commit
·
0485dba
1
Parent(s):
063f08a
updated read me and added eval notebook
Browse files- README.md +12 -9
- evaluation.ipynb +323 -0
README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
Overview
|
| 2 |
|
| 3 |
This project demonstrates the fine tuning of a LLaMA 3.2 3B model using the QLoRA strategy. In this method, the model's original weights are frozen and small "adapters" matrices are trained. This type of fine tuning drastrically reduces the number of parameters to train, which is significant when starting with LLMs with billions of parameters. QLoRA is an extension of this, where weights are quantized in a compress format, speeding up the entire process.
|
| 4 |
|
|
@@ -6,20 +6,23 @@ In this Lab, the LLaMA 3.2 3B model is fine tuned using the FineTome-100k datase
|
|
| 6 |
|
| 7 |
To expand the usage of the chatbot we built a quiz that helps students test their understanding of machine learning. The quiz is generated by the fine tune model. It creates 10 multiple choice questions and the answer. The user can select an option and they receive feedback about the answer being correct or not.
|
| 8 |
|
| 9 |
-
Evaluation
|
| 10 |
|
| 11 |
-
We evaluated the fine-tuned model on the ARC Challenge, a benchmark designed to test reasoning and logic rather than memorization. We used 500 questions from the dataset for practical runtime considerations.
|
| 12 |
|
| 13 |
-
|
| 14 |
-
- Baseline LLaMA 3.2 3B accuracy: 67%
|
| 15 |
|
| 16 |
-
The drop in accuracy is expected: fine-tuning encourages the model to follow instructions, which can slightly compromise raw reasoning performance. However, for an AI TA, the ability to reason and provide guided, instructive answers is more important than pure accuracy.
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
| 20 |
|
|
|
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
|
| 24 |
1. Memory constraints: Running different models with unsloth frequently ran out of RAM when saving to GGUF format. We experimented with various model sizes until one could be successfully saved.
|
| 25 |
|
|
|
|
| 1 |
+
## Overview
|
| 2 |
|
| 3 |
This project demonstrates the fine tuning of a LLaMA 3.2 3B model using the QLoRA strategy. In this method, the model's original weights are frozen and small "adapters" matrices are trained. This type of fine tuning drastrically reduces the number of parameters to train, which is significant when starting with LLMs with billions of parameters. QLoRA is an extension of this, where weights are quantized in a compress format, speeding up the entire process.
|
| 4 |
|
|
|
|
| 6 |
|
| 7 |
To expand the usage of the chatbot we built a quiz that helps students test their understanding of machine learning. The quiz is generated by the fine tune model. It creates 10 multiple choice questions and the answer. The user can select an option and they receive feedback about the answer being correct or not.
|
| 8 |
|
| 9 |
+
## Evaluation
|
| 10 |
|
| 11 |
+
We evaluated the fine-tuned model on the ARC Challenge, a benchmark designed to test reasoning and logic rather than memorization. For an AI TA, the ability to reason and provide guided, instructive answers is more important than pure accuracy, which is why we started with this dataset. We used 500 questions from the dataset for practical runtime considerations.
|
| 12 |
|
| 13 |
+
We also evaluated both models on the TruthfulQA dataset, which aligns more closely with the FineTome data by emphasizing factual and instruction-following responses.
|
|
|
|
| 14 |
|
|
|
|
| 15 |
|
| 16 |
+
| Model | ARC Accuracy | TruthfulQA |
|
| 17 |
+
| ------------- | ------------- |------------|
|
| 18 |
+
| Fine-tuned | 51% | 78% |
|
| 19 |
+
| Baseline LLaMa| 67% | 53% |
|
| 20 |
|
| 21 |
+
The drop in accuracy is expected for the ARC dataset: fine-tuning encourages the model to follow instructions, which can slightly compromise raw reasoning performance. However, on simpler question and answer format, the fine-tuned model performed much better than the baseline one. So it all depends on what you want to prioritize.
|
| 22 |
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
## Challenges
|
| 26 |
|
| 27 |
1. Memory constraints: Running different models with unsloth frequently ran out of RAM when saving to GGUF format. We experimented with various model sizes until one could be successfully saved.
|
| 28 |
|
evaluation.ipynb
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": null,
|
| 6 |
+
"metadata": {
|
| 7 |
+
"_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
|
| 8 |
+
"_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5",
|
| 9 |
+
"trusted": true
|
| 10 |
+
},
|
| 11 |
+
"outputs": [],
|
| 12 |
+
"source": [
|
| 13 |
+
"%%capture\n",
|
| 14 |
+
"!pip install huggingface_hub\n",
|
| 15 |
+
"!pip install llama-cpp-python\n",
|
| 16 |
+
"!pip install datasets\n",
|
| 17 |
+
"!pip install torch==2.2.0 torchvision==0.17.1 --index-url https://download.pytorch.org/whl/cu121\n",
|
| 18 |
+
"!pip install unsloth\n",
|
| 19 |
+
"!pip install --upgrade --no-cache-dir --no-deps git+https://github.com/unslothai/unsloth.git@nightly git+https://github.com/unslothai/unsloth-zoo.git"
|
| 20 |
+
]
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"cell_type": "code",
|
| 24 |
+
"execution_count": null,
|
| 25 |
+
"metadata": {
|
| 26 |
+
"trusted": true
|
| 27 |
+
},
|
| 28 |
+
"outputs": [],
|
| 29 |
+
"source": [
|
| 30 |
+
"from llama_cpp import Llama\n",
|
| 31 |
+
"from huggingface_hub import hf_hub_download\n",
|
| 32 |
+
"from datasets import load_dataset\n",
|
| 33 |
+
"from unsloth import FastLanguageModel\n"
|
| 34 |
+
]
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"cell_type": "code",
|
| 38 |
+
"execution_count": null,
|
| 39 |
+
"metadata": {
|
| 40 |
+
"trusted": true
|
| 41 |
+
},
|
| 42 |
+
"outputs": [],
|
| 43 |
+
"source": [
|
| 44 |
+
"# Load model (unchanged)\n",
|
| 45 |
+
"qlora_model_path = hf_hub_download(\n",
|
| 46 |
+
" repo_id=\"ebbalg/llama-finetome\",\n",
|
| 47 |
+
" filename=\"llama-3.2-1b-instruct.Q4_K_M.gguf\"\n",
|
| 48 |
+
")\n",
|
| 49 |
+
"qlora_model = Llama(model_path=qlora_model_path, \n",
|
| 50 |
+
" n_ctx=2048, n_threads=2, verbose=False, chat_format=\"llama-3\")\n"
|
| 51 |
+
]
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"cell_type": "code",
|
| 55 |
+
"execution_count": null,
|
| 56 |
+
"metadata": {
|
| 57 |
+
"trusted": true
|
| 58 |
+
},
|
| 59 |
+
"outputs": [],
|
| 60 |
+
"source": [
|
| 61 |
+
"from tqdm import tqdm # progress bar\n",
|
| 62 |
+
"import re\n",
|
| 63 |
+
"\n",
|
| 64 |
+
"def extract_choice_from_text(text):\n",
|
| 65 |
+
" \"\"\"\n",
|
| 66 |
+
" Scan the text and return the first valid choice letter that appears.\n",
|
| 67 |
+
" \"\"\"\n",
|
| 68 |
+
" text_upper = text.upper()\n",
|
| 69 |
+
"\n",
|
| 70 |
+
" # ---- 1. Strongest match: \"Answer: X\" ----\n",
|
| 71 |
+
" m = re.search(r\"ANSWER[:\\s\\-]*([A-E])\", text_upper)\n",
|
| 72 |
+
" if m:\n",
|
| 73 |
+
" return m.group(1)\n",
|
| 74 |
+
"\n",
|
| 75 |
+
" # ---- 2. Next: lines that START with the choice (allowing whitespace) ----\n",
|
| 76 |
+
" m = re.match(r\"\\s*([A-E])(\\.|\\s|$)\", text_upper)\n",
|
| 77 |
+
" if m:\n",
|
| 78 |
+
" return m.group(1)\n",
|
| 79 |
+
"\n",
|
| 80 |
+
" # ---- 3. Other patterns like \"Best answer is C\" ----\n",
|
| 81 |
+
" m = re.search(r\"BEST ANSWER.*?([A-E])\", text_upper)\n",
|
| 82 |
+
" if m:\n",
|
| 83 |
+
" return m.group(1)\n",
|
| 84 |
+
"\n",
|
| 85 |
+
" # ---- 4. Look for something like \"C.\" inside the text ----\n",
|
| 86 |
+
" m = re.search(r\"\\b([A-E])\\.\", text_upper)\n",
|
| 87 |
+
" if m:\n",
|
| 88 |
+
" return m.group(1)\n",
|
| 89 |
+
"\n",
|
| 90 |
+
" # ---- 5. Weakest fallback: first standalone letter ----\n",
|
| 91 |
+
" m = re.search(r\"\\b([A-E])\\b\", text_upper)\n",
|
| 92 |
+
" if m:\n",
|
| 93 |
+
" return m.group(1)\n",
|
| 94 |
+
" \n",
|
| 95 |
+
" print(text)\n",
|
| 96 |
+
" return None # couldn't find\n",
|
| 97 |
+
"\n",
|
| 98 |
+
"def eval_arc(model_fn, dataset_split):\n",
|
| 99 |
+
" correct = 0\n",
|
| 100 |
+
" total = len(dataset_split)\n",
|
| 101 |
+
"\n",
|
| 102 |
+
" for i, row in enumerate(dataset_split):\n",
|
| 103 |
+
" question = row[\"question\"]\n",
|
| 104 |
+
" answer = row[\"answerKey\"]\n",
|
| 105 |
+
"\n",
|
| 106 |
+
" # Build choices dicts from ARC structure\n",
|
| 107 |
+
" choices_texts = row['choices']['text']\n",
|
| 108 |
+
" choices_labels = row['choices']['label']\n",
|
| 109 |
+
" choices = [{\"label\": l, \"text\": t} for l, t in zip(choices_labels, choices_texts)]\n",
|
| 110 |
+
"\n",
|
| 111 |
+
" # Build prompt\n",
|
| 112 |
+
" prompt = (\n",
|
| 113 |
+
" f\"Question: {question}\\n\"\n",
|
| 114 |
+
" + \"\\n\".join([f\"{c['label']}. {c['text']}\" for c in choices])\n",
|
| 115 |
+
" + \"\\nAnswer:\"\n",
|
| 116 |
+
" )\n",
|
| 117 |
+
"\n",
|
| 118 |
+
" # Run model\n",
|
| 119 |
+
" out = model_fn(prompt)\n",
|
| 120 |
+
" pred = extract_choice_from_text(out)\n",
|
| 121 |
+
" \n",
|
| 122 |
+
" if pred == answer:\n",
|
| 123 |
+
" correct += 1\n",
|
| 124 |
+
" \n",
|
| 125 |
+
" if (i + 1) % 10 == 0:\n",
|
| 126 |
+
" print(f\"{i+1}/{total} Accuracy = {correct / total * 100}\")\n",
|
| 127 |
+
"\n",
|
| 128 |
+
" return correct / total"
|
| 129 |
+
]
|
| 130 |
+
},
|
| 131 |
+
{
|
| 132 |
+
"cell_type": "code",
|
| 133 |
+
"execution_count": null,
|
| 134 |
+
"metadata": {
|
| 135 |
+
"trusted": true
|
| 136 |
+
},
|
| 137 |
+
"outputs": [],
|
| 138 |
+
"source": [
|
| 139 |
+
"model, tokenizer = FastLanguageModel.from_pretrained(\n",
|
| 140 |
+
" model_name = \"unsloth/Llama-3.2-3B-Instruct\", # or choose \"unsloth/Llama-3.2-1B-Instruct\"\n",
|
| 141 |
+
" max_seq_length = 2048,\n",
|
| 142 |
+
" dtype = None,\n",
|
| 143 |
+
" load_in_4bit = True\n",
|
| 144 |
+
")\n"
|
| 145 |
+
]
|
| 146 |
+
},
|
| 147 |
+
{
|
| 148 |
+
"cell_type": "code",
|
| 149 |
+
"execution_count": null,
|
| 150 |
+
"metadata": {
|
| 151 |
+
"trusted": true
|
| 152 |
+
},
|
| 153 |
+
"outputs": [],
|
| 154 |
+
"source": [
|
| 155 |
+
"arc = load_dataset(\"allenai/ai2_arc\", \"ARC-Challenge\")\n",
|
| 156 |
+
"arc_eval = arc['test'].select(range(500))"
|
| 157 |
+
]
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
"cell_type": "code",
|
| 161 |
+
"execution_count": null,
|
| 162 |
+
"metadata": {
|
| 163 |
+
"trusted": true
|
| 164 |
+
},
|
| 165 |
+
"outputs": [],
|
| 166 |
+
"source": [
|
| 167 |
+
"# ---- GGUF QLoRA model runner ----\n",
|
| 168 |
+
"def run_gguf(llm, prompt, max_tokens=128):\n",
|
| 169 |
+
" out = llm(prompt, max_tokens=max_tokens, temperature=0)\n",
|
| 170 |
+
" return out[\"choices\"][0][\"text\"]\n",
|
| 171 |
+
" \n",
|
| 172 |
+
"score_qlora = eval_arc(lambda p: run_gguf(qlora_model, p), arc_eval)\n",
|
| 173 |
+
"print(\"QLoRA model:\", score_qlora)"
|
| 174 |
+
]
|
| 175 |
+
},
|
| 176 |
+
{
|
| 177 |
+
"cell_type": "code",
|
| 178 |
+
"execution_count": null,
|
| 179 |
+
"metadata": {
|
| 180 |
+
"trusted": true
|
| 181 |
+
},
|
| 182 |
+
"outputs": [],
|
| 183 |
+
"source": [
|
| 184 |
+
"# ---- Base Unsloth model runner ----\n",
|
| 185 |
+
"def run_unsloth(model, tokenizer, prompt, max_tokens=128):\n",
|
| 186 |
+
" inputs = tokenizer(prompt, return_tensors='pt').to(model.device)\n",
|
| 187 |
+
" out = model.generate(**inputs, max_new_tokens=max_tokens)\n",
|
| 188 |
+
" return tokenizer.decode(out[0], skip_special_tokens=True)\n",
|
| 189 |
+
" \n",
|
| 190 |
+
"score_base = eval_arc(lambda p: run_unsloth(model, tokenizer, p), arc_eval)\n",
|
| 191 |
+
"print(\"Base model:\", score_base)"
|
| 192 |
+
]
|
| 193 |
+
},
|
| 194 |
+
{
|
| 195 |
+
"cell_type": "code",
|
| 196 |
+
"execution_count": null,
|
| 197 |
+
"metadata": {
|
| 198 |
+
"trusted": true
|
| 199 |
+
},
|
| 200 |
+
"outputs": [],
|
| 201 |
+
"source": [
|
| 202 |
+
"import string \n",
|
| 203 |
+
"\n",
|
| 204 |
+
"def convert_truthfulqa_row(row):\n",
|
| 205 |
+
" target = row[\"mc1_targets\"] # or mc2_targets\n",
|
| 206 |
+
" choices = target[\"choices\"]\n",
|
| 207 |
+
" answer_idx = target[\"labels\"].index(1) # correct index\n",
|
| 208 |
+
"\n",
|
| 209 |
+
" # Generate labels dynamically\n",
|
| 210 |
+
" labels = list(string.ascii_uppercase[:len(choices)])\n",
|
| 211 |
+
" \n",
|
| 212 |
+
" # Build prompt\n",
|
| 213 |
+
" prompt = f\"Question: {row['question']}\\n\"\n",
|
| 214 |
+
" prompt += \"\\n\".join([f\"{labels[i]}. {c}\" for i, c in enumerate(choices)])\n",
|
| 215 |
+
" prompt += \"\\nAnswer (choose one letter):\"\n",
|
| 216 |
+
" \n",
|
| 217 |
+
" correct_label = labels[answer_idx]\n",
|
| 218 |
+
" return prompt, correct_label\n",
|
| 219 |
+
"\n",
|
| 220 |
+
"def eval_truthfulqa(model_fn, dataset_split):\n",
|
| 221 |
+
" i = 0\n",
|
| 222 |
+
" correct = 0\n",
|
| 223 |
+
" total = len(dataset_split)\n",
|
| 224 |
+
"\n",
|
| 225 |
+
" for prompt, correct_label in dataset_split:\n",
|
| 226 |
+
" pred_text = model_fn(prompt)\n",
|
| 227 |
+
"\n",
|
| 228 |
+
" # Extract predicted label: first uppercase letter in the output\n",
|
| 229 |
+
" pred_label = extract_choice_from_text(pred_text)\n",
|
| 230 |
+
" \n",
|
| 231 |
+
" if pred_label == correct_label:\n",
|
| 232 |
+
" correct += 1\n",
|
| 233 |
+
" \n",
|
| 234 |
+
" if (i + 1) % 20 == 0:\n",
|
| 235 |
+
" print(f\"{i+1}/{total} Accuracy = {correct / total * 100}\")\n",
|
| 236 |
+
" i += 1\n",
|
| 237 |
+
"\n",
|
| 238 |
+
" return correct / total\n"
|
| 239 |
+
]
|
| 240 |
+
},
|
| 241 |
+
{
|
| 242 |
+
"cell_type": "code",
|
| 243 |
+
"execution_count": null,
|
| 244 |
+
"metadata": {
|
| 245 |
+
"trusted": true
|
| 246 |
+
},
|
| 247 |
+
"outputs": [],
|
| 248 |
+
"source": [
|
| 249 |
+
"ds = load_dataset(\"truthful_qa\", \"multiple_choice\")\n",
|
| 250 |
+
"qa_eval_raw = ds[\"validation\"].select(range(500))"
|
| 251 |
+
]
|
| 252 |
+
},
|
| 253 |
+
{
|
| 254 |
+
"cell_type": "code",
|
| 255 |
+
"execution_count": null,
|
| 256 |
+
"metadata": {
|
| 257 |
+
"trusted": true
|
| 258 |
+
},
|
| 259 |
+
"outputs": [],
|
| 260 |
+
"source": [
|
| 261 |
+
"qa_eval = [convert_truthfulqa_row(row) for row in qa_eval_raw]\n",
|
| 262 |
+
"\n",
|
| 263 |
+
"for row in qa_eval:\n",
|
| 264 |
+
" print(row)\n",
|
| 265 |
+
" break"
|
| 266 |
+
]
|
| 267 |
+
},
|
| 268 |
+
{
|
| 269 |
+
"cell_type": "code",
|
| 270 |
+
"execution_count": null,
|
| 271 |
+
"metadata": {
|
| 272 |
+
"trusted": true
|
| 273 |
+
},
|
| 274 |
+
"outputs": [],
|
| 275 |
+
"source": [
|
| 276 |
+
"score_qlora = eval_truthfulqa(lambda p: run_gguf(qlora_model, p), qa_eval)\n",
|
| 277 |
+
"print(\"QLoRA model accuracy:\", score_qlora)\n"
|
| 278 |
+
]
|
| 279 |
+
},
|
| 280 |
+
{
|
| 281 |
+
"cell_type": "code",
|
| 282 |
+
"execution_count": null,
|
| 283 |
+
"metadata": {
|
| 284 |
+
"trusted": true
|
| 285 |
+
},
|
| 286 |
+
"outputs": [],
|
| 287 |
+
"source": [
|
| 288 |
+
"score_base = eval_truthfulqa(lambda p: run_unsloth(model, tokenizer, p), qa_eval)\n",
|
| 289 |
+
"print(\"Base model accuracy:\", score_base)"
|
| 290 |
+
]
|
| 291 |
+
}
|
| 292 |
+
],
|
| 293 |
+
"metadata": {
|
| 294 |
+
"kaggle": {
|
| 295 |
+
"accelerator": "nvidiaTeslaT4",
|
| 296 |
+
"dataSources": [],
|
| 297 |
+
"dockerImageVersionId": 31193,
|
| 298 |
+
"isGpuEnabled": true,
|
| 299 |
+
"isInternetEnabled": true,
|
| 300 |
+
"language": "python",
|
| 301 |
+
"sourceType": "notebook"
|
| 302 |
+
},
|
| 303 |
+
"kernelspec": {
|
| 304 |
+
"display_name": "Python 3",
|
| 305 |
+
"language": "python",
|
| 306 |
+
"name": "python3"
|
| 307 |
+
},
|
| 308 |
+
"language_info": {
|
| 309 |
+
"codemirror_mode": {
|
| 310 |
+
"name": "ipython",
|
| 311 |
+
"version": 3
|
| 312 |
+
},
|
| 313 |
+
"file_extension": ".py",
|
| 314 |
+
"mimetype": "text/x-python",
|
| 315 |
+
"name": "python",
|
| 316 |
+
"nbconvert_exporter": "python",
|
| 317 |
+
"pygments_lexer": "ipython3",
|
| 318 |
+
"version": "3.11.13"
|
| 319 |
+
}
|
| 320 |
+
},
|
| 321 |
+
"nbformat": 4,
|
| 322 |
+
"nbformat_minor": 4
|
| 323 |
+
}
|