Skip to content

Commit df4921a

Browse files
authored
nbfmt gemma site notebooks (#508)
This ensures notebook diffs are simple and consistent.
1 parent cf25b4f commit df4921a

File tree

2 files changed

+34
-91
lines changed

2 files changed

+34
-91
lines changed

site/en/gemma/docs/codegemma/codegemma_flax_inference.ipynb

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@
4848
"source": [
4949
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
5050
" <td>\n",
51-
" <a target=\"_blank\" href=\"https://ai.google.dev/gemma/docs/codegemma/keras_quickstart\"><img src=\"https://ai.google.dev/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" />View on ai.google.dev</a>\n",
51+
" <a target=\"_blank\" href=\"https://ai.google.dev/gemma/docs/codegemma/codegemma_flax_inference\"><img src=\"https://ai.google.dev/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" />View on ai.google.dev</a>\n",
5252
" </td>\n",
5353
" <td>\n",
54-
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/google/generative-ai-docs/blob/main/site/en/gemma/docs/codegemma/flax_quickstart.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
54+
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/google/generative-ai-docs/blob/main/site/en/gemma/docs/codegemma/codegemma_flax_inference.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
5555
" </td>\n",
5656
" <td>\n",
57-
" <a target=\"_blank\" href=\"https://github.com/google/generative-ai-docs/blob/main/site/en/gemma/docs/codegemma/flax_quickstart.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a>\n",
57+
" <a target=\"_blank\" href=\"https://github.com/google/generative-ai-docs/blob/main/site/en/gemma/docs/codegemma/codegemma_flax_inference.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a>\n",
5858
" </td>\n",
5959
"</table>"
6060
]
@@ -148,11 +148,7 @@
148148
"cell_type": "code",
149149
"execution_count": null,
150150
"metadata": {
151-
"colab": {
152-
"base_uri": "https://localhost:8080/"
153-
},
154-
"id": "XpSw-_4EEcoY",
155-
"outputId": "ff9d2cab-80e1-4e5f-b976-94769cd3e730"
151+
"id": "XpSw-_4EEcoY"
156152
},
157153
"outputs": [
158154
{
@@ -229,11 +225,7 @@
229225
"cell_type": "code",
230226
"execution_count": null,
231227
"metadata": {
232-
"colab": {
233-
"base_uri": "https://localhost:8080/"
234-
},
235-
"id": "j_QdPAGyO5zl",
236-
"outputId": "8181d17f-da02-4d1b-ce34-cbd048362007"
228+
"id": "j_QdPAGyO5zl"
237229
},
238230
"outputs": [
239231
{
@@ -257,11 +249,7 @@
257249
"cell_type": "code",
258250
"execution_count": null,
259251
"metadata": {
260-
"colab": {
261-
"base_uri": "https://localhost:8080/"
262-
},
263-
"id": "cjnXlLkWcHIy",
264-
"outputId": "79cfb87d-fef7-4eb5-f452-48294c352bd6"
252+
"id": "cjnXlLkWcHIy"
265253
},
266254
"outputs": [
267255
{
@@ -301,11 +289,7 @@
301289
"cell_type": "code",
302290
"execution_count": null,
303291
"metadata": {
304-
"colab": {
305-
"base_uri": "https://localhost:8080/"
306-
},
307-
"id": "JAwXvpzbuiB5",
308-
"outputId": "b526c792-1105-47ea-932d-3c8d3a1919bc"
292+
"id": "JAwXvpzbuiB5"
309293
},
310294
"outputs": [
311295
{
@@ -366,11 +350,7 @@
366350
"cell_type": "code",
367351
"execution_count": null,
368352
"metadata": {
369-
"colab": {
370-
"base_uri": "https://localhost:8080/"
371-
},
372-
"id": "TpyG5YW1EcoY",
373-
"outputId": "be890773-f521-45a5-d379-4036c9cbb3de"
353+
"id": "TpyG5YW1EcoY"
374354
},
375355
"outputs": [
376356
{
@@ -511,11 +491,7 @@
511491
"cell_type": "code",
512492
"execution_count": null,
513493
"metadata": {
514-
"colab": {
515-
"base_uri": "https://localhost:8080/"
516-
},
517-
"id": "S5F3fk22Ecod",
518-
"outputId": "283d6e07-1ea4-4240-ebc8-464263df9a4c"
494+
"id": "S5F3fk22Ecod"
519495
},
520496
"outputs": [
521497
{
@@ -558,11 +534,7 @@
558534
"cell_type": "code",
559535
"execution_count": null,
560536
"metadata": {
561-
"colab": {
562-
"base_uri": "https://localhost:8080/"
563-
},
564-
"id": "6zIQEruE5_FC",
565-
"outputId": "29e4e090-fd05-432d-ca13-bbc42443b958"
537+
"id": "6zIQEruE5_FC"
566538
},
567539
"outputs": [
568540
{
@@ -604,11 +576,7 @@
604576
"cell_type": "code",
605577
"execution_count": null,
606578
"metadata": {
607-
"colab": {
608-
"base_uri": "https://localhost:8080/"
609-
},
610-
"id": "SvaV4GU76M3t",
611-
"outputId": "76d55cf4-a586-4faa-cb8a-7968b7e8ada0"
579+
"id": "SvaV4GU76M3t"
612580
},
613581
"outputs": [
614582
{
@@ -675,15 +643,12 @@
675643
"metadata": {
676644
"accelerator": "TPU",
677645
"colab": {
678-
"gpuType": "V28",
679-
"provenance": []
646+
"name": "codegemma_flax_inference.ipynb",
647+
"toc_visible": true
680648
},
681649
"kernelspec": {
682650
"display_name": "Python 3",
683651
"name": "python3"
684-
},
685-
"language_info": {
686-
"name": "python"
687652
}
688653
},
689654
"nbformat": 4,

site/en/gemma/docs/paligemma/fine-tuning-paligemma.ipynb

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"cell_type": "code",
1414
"execution_count": null,
1515
"metadata": {
16+
"cellView": "form",
1617
"id": "_fEE8rM9BUfS"
1718
},
1819
"outputs": [],
@@ -38,17 +39,17 @@
3839
"source": [
3940
"# Fine-tune PaliGemma with JAX and Flax\n",
4041
"\n",
41-
"\u003ctable class=\"tfo-notebook-buttons\" align=\"left\"\u003e\n",
42-
"\u003ctd\u003e\n",
43-
"\u003ca target=\"_blank\" href=\"https://ai.google.dev/gemma/docs/paligemma/fine-tuning-paligemma\"\u003e\u003cimg src=\"https://ai.google.dev/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" /\u003eView on ai.google.dev\u003c/a\u003e\n",
44-
"\u003c/td\u003e\n",
45-
"\u003ctd\u003e\n",
46-
"\u003ca target=\"_blank\" href=\"https://colab.research.google.com/github/google/generative-ai-docs/blob/main/site/en/gemma/docs/paligemma/fine-tuning-paligemma.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" /\u003eRun in Google Colab\u003c/a\u003e\n",
47-
"\u003c/td\u003e\n",
48-
"\u003ctd\u003e\n",
49-
"\u003ca target=\"_blank\" href=\"https://github.com/google/generative-ai-docs/blob/main/site/en/gemma/docs/paligemma/fine-tuning-paligemma.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" /\u003eView source on GitHub\u003c/a\u003e\n",
50-
"\u003c/td\u003e\n",
51-
"\u003c/table\u003e\n"
42+
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
43+
"<td>\n",
44+
"<a target=\"_blank\" href=\"https://ai.google.dev/gemma/docs/paligemma/fine-tuning-paligemma\"><img src=\"https://ai.google.dev/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" />View on ai.google.dev</a>\n",
45+
"</td>\n",
46+
"<td>\n",
47+
"<a target=\"_blank\" href=\"https://colab.research.google.com/github/google/generative-ai-docs/blob/main/site/en/gemma/docs/paligemma/fine-tuning-paligemma.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
48+
"</td>\n",
49+
"<td>\n",
50+
"<a target=\"_blank\" href=\"https://github.com/google/generative-ai-docs/blob/main/site/en/gemma/docs/paligemma/fine-tuning-paligemma.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a>\n",
51+
"</td>\n",
52+
"</table>\n"
5253
]
5354
},
5455
{
@@ -117,8 +118,7 @@
117118
"\n",
118119
"To generate a Kaggle API key, open your [**Settings** page in Kaggle](https://www.kaggle.com/settings) and click **Create New Token**. This triggers the download of a `kaggle.json` file containing your API credentials.\n",
119120
"\n",
120-
"Then, in Colab, select **Secrets** (🔑) in the left pane and add your Kaggle username and Kaggle API key. Store your username under the name `KAGGLE_USERNAME` and your API key under the name `KAGGLE_KEY`.\n",
121-
"\n"
121+
"Then, in Colab, select **Secrets** (🔑) in the left pane and add your Kaggle username and Kaggle API key. Store your username under the name `KAGGLE_USERNAME` and your API key under the name `KAGGLE_KEY`.\n"
122122
]
123123
},
124124
{
@@ -482,7 +482,7 @@
482482
"\n",
483483
" image = tf.constant(image)\n",
484484
" image = tf.image.resize(image, (size, size), method='bilinear', antialias=True)\n",
485-
" return image.numpy() / 127.5 - 1.0 # [0, 255]-\u003e[-1,1]\n",
485+
" return image.numpy() / 127.5 - 1.0 # [0, 255]->[-1,1]\n",
486486
"\n",
487487
"def preprocess_tokens(prefix, suffix=None, seqlen=None):\n",
488488
" # Model has been trained to handle tokenized text composed of a prefix with\n",
@@ -622,12 +622,12 @@
622622
" return f\"data:image/jpeg;base64,{image_b64}\"\n",
623623
"\n",
624624
"def render_example(image, caption):\n",
625-
" image = ((image + 1)/2 * 255).astype(np.uint8) # [-1,1] -\u003e [0, 255]\n",
625+
" image = ((image + 1)/2 * 255).astype(np.uint8) # [-1,1] -> [0, 255]\n",
626626
" return f\"\"\"\n",
627-
" \u003cdiv style=\"display: inline-flex; align-items: center; justify-content: center;\"\u003e\n",
628-
" \u003cimg style=\"width:128px; height:128px;\" src=\"{render_inline(image, resize=(64,64))}\" /\u003e\n",
629-
" \u003cp style=\"width:256px; margin:10px; font-size:small;\"\u003e{html.escape(caption)}\u003c/p\u003e\n",
630-
" \u003c/div\u003e\n",
627+
" <div style=\"display: inline-flex; align-items: center; justify-content: center;\">\n",
628+
" <img style=\"width:128px; height:128px;\" src=\"{render_inline(image, resize=(64,64))}\" />\n",
629+
" <p style=\"width:256px; margin:10px; font-size:small;\">{html.escape(caption)}</p>\n",
630+
" </div>\n",
631631
" \"\"\"\n",
632632
"\n",
633633
"html_out = \"\"\n",
@@ -744,7 +744,7 @@
744744
" # Append to html output.\n",
745745
" for example, response in zip(examples, responses):\n",
746746
" outputs.append((example[\"image\"], response))\n",
747-
" if num_examples and len(outputs) \u003e= num_examples:\n",
747+
" if num_examples and len(outputs) >= num_examples:\n",
748748
" return outputs"
749749
]
750750
},
@@ -852,34 +852,12 @@
852852
],
853853
"metadata": {
854854
"colab": {
855-
"gpuType": "T4",
856-
"last_runtime": {
857-
"build_target": "//learning/grp/tools/ml_python:ml_notebook",
858-
"kind": "private"
859-
},
860-
"private_outputs": true,
861-
"provenance": [
862-
{
863-
"file_id": "17AiK8gRY7oiquQGkBH0d08PFQo3Kyx1I",
864-
"timestamp": 1715287187925
865-
},
866-
{
867-
"file_id": "1qZlJfPyfKRrNcz2shxQ93HnnE5Ge1LLn",
868-
"timestamp": 1715019972450
869-
},
870-
{
871-
"file_id": "1JFnlD2kSiTNexdPw_NYRtuW6uuSTI0kD",
872-
"timestamp": 1714585741026
873-
}
874-
],
855+
"name": "fine-tuning-paligemma.ipynb",
875856
"toc_visible": true
876857
},
877858
"kernelspec": {
878859
"display_name": "Python 3",
879860
"name": "python3"
880-
},
881-
"language_info": {
882-
"name": "python"
883861
}
884862
},
885863
"nbformat": 4,

0 commit comments

Comments
 (0)