Skip to content

Commit d2e4f35

Browse files
committed
Format LiteRT export guide with black and sync notebook
1 parent 47342f2 commit d2e4f35

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

guides/ipynb/litert_export.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@
9595
"preprocessor = keras_hub.models.Gemma3CausalLMPreprocessor.from_preset(\n",
9696
" preset, sequence_length=32\n",
9797
")\n",
98-
"model = keras_hub.models.Gemma3CausalLM.from_preset(\n",
99-
" preset, preprocessor=preprocessor\n",
100-
")\n",
98+
"model = keras_hub.models.Gemma3CausalLM.from_preset(preset, preprocessor=preprocessor)\n",
10199
"\n",
102100
"print(f\"Loaded {preset}\")"
103101
]
@@ -268,12 +266,14 @@
268266
" symmetric=True,\n",
269267
")\n",
270268
"\n",
269+
"\n",
271270
"# Calibrate with a few representative samples\n",
272271
"# (In production, use real prompts from your validation set)\n",
273272
"def calibration_data():\n",
274273
" for _ in range(10):\n",
275274
" yield [np.random.randint(0, 256000, size=(1, 32)).astype(np.int32)]\n",
276275
"\n",
276+
"\n",
277277
"qt.quantize(calibration_data(), \"gemma3_270m_aieq.tflite\")\n",
278278
"\n",
279279
"print(\"Exported ai-edge-quantizer model\")"

guides/litert_export.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@
6161
preprocessor = keras_hub.models.Gemma3CausalLMPreprocessor.from_preset(
6262
preset, sequence_length=32
6363
)
64-
model = keras_hub.models.Gemma3CausalLM.from_preset(
65-
preset, preprocessor=preprocessor
66-
)
64+
model = keras_hub.models.Gemma3CausalLM.from_preset(preset, preprocessor=preprocessor)
6765

6866
print(f"Loaded {preset}")
6967

@@ -164,12 +162,14 @@
164162
symmetric=True,
165163
)
166164

165+
167166
# Calibrate with a few representative samples
168167
# (In production, use real prompts from your validation set)
169168
def calibration_data():
170169
for _ in range(10):
171170
yield [np.random.randint(0, 256000, size=(1, 32)).astype(np.int32)]
172171

172+
173173
qt.quantize(calibration_data(), "gemma3_270m_aieq.tflite")
174174

175175
print("Exported ai-edge-quantizer model")

0 commit comments

Comments
 (0)