Skip to content

Commit 1db1999

Browse files
authored
minor fixes (rasbt#248)
* removed duplicated numpy req * labels to array * autopep8 NBs
1 parent 7e78b52 commit 1db1999

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

.github/ISSUE_TEMPLATE/ask-a-question.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Ask a Question
33
about: Ask questions related to the book
44
title: ''
5-
labels: question
5+
labels: [question]
66
assignees: rasbt
77

88
---

ch07/03_model-evaluation/llm-instruction-eval-ollama.ipynb

+7-5
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"from importlib.metadata import version\n",
7171
"\n",
7272
"pkgs = [\"tqdm\", # Progress bar\n",
73-
" ]\n",
73+
" ]\n",
7474
"\n",
7575
"for p in pkgs:\n",
7676
" print(f\"{p} version: {version(p)}\")"
@@ -218,12 +218,13 @@
218218
"import urllib.request\n",
219219
"import json\n",
220220
"\n",
221+
"\n",
221222
"def query_model(prompt, model=\"llama3\", url=\"http://localhost:11434/api/chat\"):\n",
222223
" # Create the data payload as a dictionary\n",
223224
" data = {\n",
224225
" \"model\": model,\n",
225-
" \"seed\":123, # for deterministic responses\n",
226-
" \"temperature\":0, # for deterministic responses\n",
226+
" \"seed\": 123, # for deterministic responses\n",
227+
" \"temperature\": 0, # for deterministic responses\n",
227228
" \"messages\": [\n",
228229
" {\"role\": \"user\", \"content\": prompt}\n",
229230
" ]\n",
@@ -290,7 +291,7 @@
290291
"\n",
291292
"with open(json_file, \"r\") as file:\n",
292293
" json_data = json.load(file)\n",
293-
" \n",
294+
"\n",
294295
"print(\"Number of entries:\", len(json_data))"
295296
]
296297
},
@@ -520,7 +521,7 @@
520521
" f\"and correct output `{entry['output']}`, \"\n",
521522
" f\"score the model response `{entry['model 1 response']}`\"\n",
522523
" f\" on a scale from 0 to 100, where 100 is the best score. \"\n",
523-
" )\n",
524+
" )\n",
524525
" print(\"\\nDataset response:\")\n",
525526
" print(\">>\", entry['output'])\n",
526527
" print(\"\\nModel response:\")\n",
@@ -547,6 +548,7 @@
547548
"source": [
548549
"from tqdm import tqdm\n",
549550
"\n",
551+
"\n",
550552
"def generate_model_scores(json_data, json_key):\n",
551553
" scores = []\n",
552554
" for entry in tqdm(json_data, desc=\"Scoring entries\"):\n",

ch07/03_model-evaluation/llm-instruction-eval-openai.ipynb

+5-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"\n",
8181
"pkgs = [\"openai\", # OpenAI API\n",
8282
" \"tqdm\", # Progress bar\n",
83-
" ]\n",
83+
" ]\n",
8484
"\n",
8585
"for p in pkgs:\n",
8686
" print(f\"{p} version: {version(p)}\")"
@@ -125,7 +125,7 @@
125125
"import json\n",
126126
"from openai import OpenAI\n",
127127
"\n",
128-
"# Load API key from a JSON file. \n",
128+
"# Load API key from a JSON file.\n",
129129
"# Make sure to replace \"sk-...\" with your actual API key from https://platform.openai.com/api-keys\n",
130130
"with open(\"config.json\", \"r\") as config_file:\n",
131131
" config = json.load(config_file)\n",
@@ -209,7 +209,7 @@
209209
"\n",
210210
"with open(json_file, \"r\") as file:\n",
211211
" json_data = json.load(file)\n",
212-
" \n",
212+
"\n",
213213
"print(\"Number of entries:\", len(json_data))"
214214
]
215215
},
@@ -409,7 +409,7 @@
409409
" f\"and correct output `{entry['output']}`, \"\n",
410410
" f\"score the model response `{entry['model 1 response']}`\"\n",
411411
" f\" on a scale from 0 to 100, where 100 is the best score. \"\n",
412-
" )\n",
412+
" )\n",
413413
" print(\"\\nDataset response:\")\n",
414414
" print(\">>\", entry['output'])\n",
415415
" print(\"\\nModel response:\")\n",
@@ -436,6 +436,7 @@
436436
"source": [
437437
"from tqdm import tqdm\n",
438438
"\n",
439+
"\n",
439440
"def generate_model_scores(json_data, json_key, client):\n",
440441
" scores = []\n",
441442
" for entry in tqdm(json_data, desc=\"Scoring entries\"):\n",

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ torch >= 2.0.1 # all
22
jupyterlab >= 4.0 # all
33
tiktoken >= 0.5.1 # ch02; ch04; ch05
44
matplotlib >= 3.7.1 # ch04; ch05
5-
numpy >= 1.24.3 # ch05
65
tensorflow >= 2.15.0 # ch05
76
tqdm >= 4.66.1 # ch05; ch07
87
numpy >= 1.25, < 2.0 # dependency of several other libraries like torch and pandas

0 commit comments

Comments
 (0)