mirror of
https://github.com/rasbt/LLMs-from-scratch.git
synced 2025-08-09 01:02:50 +00:00
fixed code (#197)
This commit is contained in:
parent
53060dfdfc
commit
b178040b79
@ -286,8 +286,6 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"\n",
|
||||
"json_file = \"eval-example-data.json\"\n",
|
||||
"\n",
|
||||
"with open(json_file, \"r\") as file:\n",
|
||||
@ -628,6 +626,8 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from pathlib import Path\n",
|
||||
"\n",
|
||||
"for model in (\"model 1 response\", \"model 2 response\"):\n",
|
||||
"\n",
|
||||
" scores = generate_model_scores(json_data, model)\n",
|
||||
@ -636,8 +636,7 @@
|
||||
" print(f\"Average score: {sum(scores)/len(scores):.2f}\\n\")\n",
|
||||
"\n",
|
||||
" # Optionally save the scores\n",
|
||||
" from pathlib import Path\n",
|
||||
" save_path = (Path(\"scores\")/f\"llama3-8b-{model}.json\").replace(\" \", \"-\")\n",
|
||||
" save_path = Path(\"scores\") / f\"llama3-8b-{model.replace(' ', '-')}.json\"\n",
|
||||
" with open(save_path, \"w\") as file:\n",
|
||||
" json.dump(scores, file)"
|
||||
]
|
||||
|
@ -205,8 +205,6 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"\n",
|
||||
"json_file = \"eval-example-data.json\"\n",
|
||||
"\n",
|
||||
"with open(json_file, \"r\") as file:\n",
|
||||
@ -524,6 +522,8 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from pathlib import Path\n",
|
||||
"\n",
|
||||
"for model in (\"model 1 response\", \"model 2 response\"):\n",
|
||||
"\n",
|
||||
" scores = generate_model_scores(json_data, model, client)\n",
|
||||
@ -532,8 +532,7 @@
|
||||
" print(f\"Average score: {sum(scores)/len(scores):.2f}\\n\")\n",
|
||||
"\n",
|
||||
" # Optionally save the scores\n",
|
||||
" from pathlib import Path\n",
|
||||
" save_path = (Path(\"scores\")/f\"gpt4-{model}.json\").replace(\" \", \"-\")\n",
|
||||
" save_path = Path(\"scores\") / f\"gpt4-{model.replace(' ', '-')}.json\"\n",
|
||||
" with open(save_path, \"w\") as file:\n",
|
||||
" json.dump(scores, file)"
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user