Upload fine-tuning.ipynb
Browse files- fine-tuning.ipynb +46 -0
fine-tuning.ipynb
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import json\n",
|
10 |
+
"\n",
|
11 |
+
"# Save formatted_data as JSONL\n",
|
12 |
+
"with open(\"mydata.jsonl\", \"w\") as outfile:\n",
|
13 |
+
" for entry in formatted_data:\n",
|
14 |
+
" json.dump(entry, outfile)\n",
|
15 |
+
" outfile.write(\"\\n\")\n",
|
16 |
+
"\n",
|
17 |
+
"# Now use it in the provided code\n",
|
18 |
+
"import os\n",
|
19 |
+
"import openai\n",
|
20 |
+
"\n",
|
21 |
+
"openai.api_key = '' ##add API key here\n",
|
22 |
+
"openai.File.create(\n",
|
23 |
+
" file=open(\"mydata.jsonl\", \"rb\"),\n",
|
24 |
+
" purpose='fine-tune'\n",
|
25 |
+
")"
|
26 |
+
]
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"cell_type": "code",
|
30 |
+
"execution_count": null,
|
31 |
+
"metadata": {},
|
32 |
+
"outputs": [],
|
33 |
+
"source": [
|
34 |
+
"openai.FineTuningJob.create(training_file=\"file-XMpA2lwxpHwIdUYU8GehdT4C\", model=\"gpt-3.5-turbo\")\n",
|
35 |
+
"#training file will need to be updated with the id from the upload once complete"
|
36 |
+
]
|
37 |
+
}
|
38 |
+
],
|
39 |
+
"metadata": {
|
40 |
+
"language_info": {
|
41 |
+
"name": "python"
|
42 |
+
}
|
43 |
+
},
|
44 |
+
"nbformat": 4,
|
45 |
+
"nbformat_minor": 2
|
46 |
+
}
|