Skip to content

Commit ecff050

Browse files
authored
Fixups (google#135)
* Fixups * fix json * Update tuning_quickstart_python.ipynb
1 parent 172fb02 commit ecff050

File tree

1 file changed

+30
-43
lines changed

1 file changed

+30
-43
lines changed

site/en/tutorials/tuning_quickstart_python.ipynb

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"If you want to run this notebook in Colab start by uploading your\n",
114114
"`client_secret*.json` file using the \"File > Upload\" option.\n",
115115
"\n",
116-
"![Show colab's File > Upload option](https://developers.generativeai.google/tutorials/images/colab_upload.png)"
116+
"<img width=400 src=\"https://developers.generativeai.google/tutorials/images/colab_upload.png\">"
117117
]
118118
},
119119
{
@@ -133,7 +133,7 @@
133133
],
134134
"source": [
135135
"!cp client_secret*.json client_secret.json\n",
136-
"!ls"
136+
"!ls client_secret.json"
137137
]
138138
},
139139
{
@@ -174,26 +174,13 @@
174174
},
175175
{
176176
"cell_type": "code",
177-
"execution_count": null,
177+
"execution_count": 7,
178178
"metadata": {
179-
"id": "VYetBMbknUVp"
179+
"id": "cbcf72bcb56d"
180180
},
181-
"outputs": [
182-
{
183-
"name": "stdout",
184-
"output_type": "stream",
185-
"text": [
186-
"\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/122.9 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r",
187-
"\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[90m╺\u001b[0m\u001b[90m━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.7/122.9 kB\u001b[0m \u001b[31m1.9 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r",
188-
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m122.9/122.9 kB\u001b[0m \u001b[31m2.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
189-
"\u001b[?25h\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/113.3 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r",
190-
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m113.3/113.3 kB\u001b[0m \u001b[31m5.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
191-
"\u001b[?25h"
192-
]
193-
}
194-
],
181+
"outputs": [],
195182
"source": [
196-
"!pip install google-generativeai"
183+
"!pip install -q google-generativeai"
197184
]
198185
},
199186
{
@@ -213,10 +200,7 @@
213200
},
214201
"outputs": [],
215202
"source": [
216-
"import google.generativeai as palm\n",
217-
"\n",
218-
"import google.ai.generativelanguage as glm\n",
219-
"import pprint"
203+
"import google.generativeai as palm\n"
220204
]
221205
},
222206
{
@@ -239,16 +223,17 @@
239223
"name": "stdout",
240224
"output_type": "stream",
241225
"text": [
242-
"['tunedModels/testnumbergenerator-fvitocr834l6',\n",
243-
" 'tunedModels/my-display-name-81-9wpmc1m920vq',\n",
244-
" 'tunedModels/number-generator-model-kctlevca1g3q',\n",
245-
" 'tunedModels/my-display-name-81-r9wcuda14lyy']\n"
226+
"tunedModels/my-model-8527\n",
227+
"tunedModels/my-model-7092\n",
228+
"tunedModels/my-model-2778\n",
229+
"tunedModels/my-model-1298\n",
230+
"tunedModels/my-model-3883\n"
246231
]
247232
}
248233
],
249234
"source": [
250-
"tuned_models = list(palm.list_tuned_models())\n",
251-
"pprint.pprint([m.name for m in tuned_models])"
235+
"for i, m in zip(range(5), palm.list_tuned_models()):\n",
236+
" print(m.name)"
252237
]
253238
},
254239
{
@@ -311,6 +296,7 @@
311296
"\n",
312297
"name = f'generate-num-{random.randint(0,10000)}'\n",
313298
"operation = palm.create_tuned_model(\n",
299+
" # You can use a tuned model here too. Set `source_model=\"tunedModels/...\"` \n",
314300
" source_model=base_model.name,\n",
315301
" training_data=[\n",
316302
" {\n",
@@ -387,18 +373,18 @@
387373
"name": "stdout",
388374
"output_type": "stream",
389375
"text": [
390-
"TunedModel(name='tunedModels/generate-num-4668',\n",
391-
" source_model=None,\n",
376+
"TunedModel(name='tunedModels/generate-num-9028',\n",
377+
" source_model='tunedModels/generate-num-4110',\n",
392378
" base_model='models/text-bison-001',\n",
393379
" display_name='',\n",
394380
" description='',\n",
395381
" temperature=0.7,\n",
396382
" top_p=0.95,\n",
397383
" top_k=40,\n",
398384
" state=<State.CREATING: 1>,\n",
399-
" create_time=datetime.datetime(2023, 9, 19, 19, 3, 38, 22249, tzinfo=<UTC>),\n",
400-
" update_time=datetime.datetime(2023, 9, 19, 19, 3, 38, 22249, tzinfo=<UTC>),\n",
401-
" tuning_task=TuningTask(start_time=datetime.datetime(2023, 9, 19, 19, 3, 38, 562798, tzinfo=<UTC>),\n",
385+
" create_time=datetime.datetime(2023, 9, 29, 21, 37, 32, 188028, tzinfo=datetime.timezone.utc),\n",
386+
" update_time=datetime.datetime(2023, 9, 29, 21, 37, 32, 188028, tzinfo=datetime.timezone.utc),\n",
387+
" tuning_task=TuningTask(start_time=datetime.datetime(2023, 9, 29, 21, 37, 32, 734118, tzinfo=datetime.timezone.utc),\n",
402388
" complete_time=None,\n",
403389
" snapshots=[],\n",
404390
" hyperparameters=Hyperparameters(epoch_count=100,\n",
@@ -410,12 +396,12 @@
410396
"source": [
411397
"model = palm.get_tuned_model(f'tunedModels/{name}')\n",
412398
"\n",
413-
"pprint.pprint(model)"
399+
"model"
414400
]
415401
},
416402
{
417403
"cell_type": "code",
418-
"execution_count": null,
404+
"execution_count": 40,
419405
"metadata": {
420406
"id": "EUodUwZkKPi-"
421407
},
@@ -463,11 +449,11 @@
463449
{
464450
"data": {
465451
"text/plain": [
466-
"total_steps: 375\n",
467-
"tuned_model: \"tunedModels/generate-num-4668\""
452+
"tuned_model: \"tunedModels/generate-num-9028\"\n",
453+
"total_steps: 375"
468454
]
469455
},
470-
"execution_count": 15,
456+
"execution_count": 41,
471457
"metadata": {},
472458
"output_type": "execute_result"
473459
}
@@ -487,15 +473,15 @@
487473
},
488474
{
489475
"cell_type": "code",
490-
"execution_count": null,
476+
"execution_count": 42,
491477
"metadata": {
492478
"id": "SOUowIv1HgSE"
493479
},
494480
"outputs": [
495481
{
496482
"data": {
497483
"application/vnd.jupyter.widget-view+json": {
498-
"model_id": "c07d8bb1884d460cb7e7e40aa459c2ea",
484+
"model_id": "98e4b6958bfc43c98e6e77354f7bf315",
499485
"version_major": 2,
500486
"version_minor": 0
501487
},
@@ -509,6 +495,7 @@
509495
],
510496
"source": [
511497
"import time\n",
498+
"\n",
512499
"for status in operation.wait_bar():\n",
513500
" time.sleep(30)"
514501
]
@@ -2250,7 +2237,7 @@
22502237
"source": [
22512238
"model = palm.get_tuned_model(f'tunedModels/{name}')\n",
22522239
"\n",
2253-
"pprint.pprint(model)"
2240+
"model"
22542241
]
22552242
},
22562243
{
@@ -2309,7 +2296,7 @@
23092296
"\n",
23102297
"try:\n",
23112298
" m = palm.get_tuned_model(f'tunedModels/{name}')\n",
2312-
" pprint.pprint(m)\n",
2299+
" print(m)\n",
23132300
"except Exception as e:\n",
23142301
" print(f\"{type(e)}: {e}\")"
23152302
]

0 commit comments

Comments
 (0)