<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kuan Hoong, Ph.D on Medium]]></title>
        <description><![CDATA[Stories by Kuan Hoong, Ph.D on Medium]]></description>
        <link>https://medium.com/@kuanhoong?source=rss-fe772cae62e3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DHZj3JphYAtuZtIo8i3dNA.jpeg</url>
            <title>Stories by Kuan Hoong, Ph.D on Medium</title>
            <link>https://medium.com/@kuanhoong?source=rss-fe772cae62e3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 00:28:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kuanhoong/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Getting Started with TorchTPU: Run Native PyTorch on Google TPUs]]></title>
            <link>https://kuanhoong.medium.com/getting-started-with-torchtpu-run-native-pytorch-on-google-tpus-63bd823bdb8f?source=rss-fe772cae62e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/63bd823bdb8f</guid>
            <dc:creator><![CDATA[Kuan Hoong, Ph.D]]></dc:creator>
            <pubDate>Thu, 12 Nov 2026 14:02:33 GMT</pubDate>
            <atom:updated>2026-11-12T14:02:33.932Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Change one string, keep your PyTorch code, and run it on a Google TPU.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UmWx0-5C2zZlDAn17HyHbg.png" /></figure><p>If you write PyTorch, you have typed this line hundreds of times:</p><pre>model.to(&quot;cuda&quot;)</pre><p>With TorchTPU, running the same model on a Google TPU looks like this:</p><pre>model.to(&quot;tpu&quot;)</pre><p>For a surprising number of models, that is the whole port. Until recently, PyTorch on a TPU meant learning the lazy tensors of PyTorch/XLA, or rewriting your model in JAX. In October 2026, Google and the PyTorch team at Meta open sourced TorchTPU, a native PyTorch backend that makes the TPU just another device.</p><p>The timing matters. TorchTPU replaces PyTorch/XLA, and the PyTorch/XLA repository is archived on 15 November 2026. If you are starting something new on TPUs, this is the path.</p><p>This guide takes you from an empty Google Cloud project to tensors, a compiled transformer, Hugging Face models and a small training loop on a TPU v6e. All the code is in the companion repository, and there is an 11-minute video version of this tutorial on YouTube.</p><h3>What is a TPU?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AhhZ8LeWyw5JtRy6nqfe5Q.png" /></figure><p>A TPU (Tensor Processing Unit) is a chip Google designed for one job: the matrix math at the heart of neural networks. Three parts matter for this tutorial.</p><ul><li><strong>MXU (matrix multiply unit).</strong> A large systolic array of multipliers. Data flows through it in waves, so thousands of multiply-and-add operations finish on every clock cycle. It is fastest in bfloat16, which comes up again later.</li><li><strong>HBM (high bandwidth memory).</strong> Fast memory beside the compute units that keeps the MXUs fed.</li><li><strong>ICI (inter-chip interconnect).</strong> Direct links between chips, so a slice of many TPUs can act like one large accelerator.</li></ul><p>We will use <strong>TPU v6e</strong>, also called Trillium. A single-chip v6e machine is the easiest way to start, and it is plenty for everything in this post.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t-jk36A1YjKnMNMXgHbFOg.png" /></figure><p><em>Figure 1. Inside a TPU: the MXU does the math, HBM feeds it, and ICI links chips together.</em></p><h3>What is TorchTPU?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*rUcGgxYLEHBXzX4K3vLAmg.png" /></figure><p><a href="https://torchtpu.readthedocs.io/en/0.2.0/">TorchTPU</a> is an open source PyTorch backend for Google Cloud TPUs, built by Google with the PyTorch team at Meta and released under the Apache 2.0 license. The key word is <strong>native</strong>.</p><p>PyTorch/XLA used lazy tensors. Your Python ran, but operations were recorded into a graph and executed later, which made debugging and performance feel unfamiliar. TorchTPU instead registers the TPU through PyTorch’s official extension point for out-of-tree devices, called PrivateUse1. The result is an ordinary torch.Tensor on a device named tpu:</p><pre>x = torch.randn(4, 4, device=&quot;tpu&quot;)<br>type(x)    # torch.Tensor<br>x.device   # device(type=&#39;tpu&#39;, index=0)</pre><p>Under the hood, TorchTPU implements PyTorch’s ATen operators for the TPU, lowers work to StableHLO, compiles it with XLA and runs it through the PjRT runtime. There is no JAX runtime in the loop. It also keeps PyTorch’s usual one-process-per-device model, so existing training scripts and torchrun launches keep their shape.</p><p>Much of the ecosystem already works on top of it: Hugging Face Transformers v5 and Diffusers, DDP, FSDP2 and DTensor through a tpu_dist process group, TorchTitan for large-scale training, and vLLM and SGLang for serving.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MGjXtfQfVfoGwchjVH3TYA.png" /></figure><p><em>Figure 2. Where TorchTPU sits: your PyTorch code stays the same, and TorchTPU takes it down to the TPU.</em></p><h3>How TorchTPU runs your code</h3><p>TorchTPU gives you three ways to run. Knowing them explains almost every performance tip later in this post.</p><ol><li><strong>Eager (default).</strong> Each PyTorch operation is sent to the TPU one at a time, asynchronously, just like on a GPU. You can print tensors, set breakpoints and step through your model.</li><li><strong>DeferAndFuse.</strong> Set TORCH_TPU_DEFER_AND_FUSE=1 and TorchTPU collects operations until you actually need a result, for example on .cpu() or .item(). It then fuses them into one compiled program. You keep eager-style code and get much of the speed of compilation.</li><li><strong>torch.compile.</strong> torch.compile(model, backend=&quot;tpu&quot;) hands the graph that TorchDynamo captures to TorchTPU, which lowers it to StableHLO for XLA. Inductor and Triton are not involved. Compiled programs are cached per input shape, so you pay the compile cost once for each shape.</li></ol><p>There is also a debug mode, TORCH_TPU_LAUNCH_BLOCKING=1, which runs each operation synchronously with extra checks. It is slow, but useful when you are chasing an error.</p><p>The recommended workflow is simple: get it right in eager mode, then compile for speed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nwRSNm76iSqeLA6k3bHMZA.png" /></figure><p><em>Figure 3. Three ways to run: eager for development, DeferAndFuse for a quick speed-up, torch.compile for production.</em></p><h3>What you need</h3><ul><li>A Google Cloud project with billing enabled.</li><li>TPU v6e quota in at least one zone. Check it under IAM &amp; Admin, Quotas &amp; System limits.</li><li>The gcloud CLI on your laptop, or Cloud Shell in the browser.</li><li>Python 3.11 or newer on the TPU VM. We use 3.12.</li></ul><p><strong>A word on cost.</strong> A TPU VM bills for every hour it exists, idle or busy. A single v6e chip for an afternoon of experiments is a small expense, but delete the VM as soon as you are done. The last section shows the command.</p><h3>Step 1: Create a TPU v6e VM and install TorchTPU</h3><p>From your laptop or Cloud Shell, create a single-chip v6e VM. You can also click through Compute Engine, TPUs, VM instance in the Cloud console.</p><pre>gcloud compute instances create torchtpu-demo \<br>  --zone=europe-west4-a \<br>  --machine-type=ct6e-standard-1t \<br>  --image-project=ubuntu-os-accelerator-images \<br>  --image-family=ubuntu-accel-2204-amd64-tpu-v5e-v5p-v6e \<br>  --boot-disk-size=200GB \<br>  --maintenance-policy=TERMINATE</pre><p>ct6e-standard-1t is one v6e chip, and ct6e-standard-4t gives you four. If the zone has no capacity, pick another zone that offers v6e.</p><p>Copy the companion code across and connect:</p><pre>gcloud compute scp --recurse torchtpu-getting-started torchtpu-demo:~ --zone=europe-west4-a<br>gcloud compute ssh torchtpu-demo --zone=europe-west4-a</pre><p>On the VM, create a virtual environment and install TorchTPU:</p><pre>python3.12 -m venv .venv &amp;&amp; source .venv/bin/activate<br>pip install torch_tpu --extra-index-url https://download.pytorch.org/whl/cpu<br>pip install &quot;transformers&gt;=5&quot; accelerate</pre><p>The --extra-index-url flag matters. It points pip at PyTorch&#39;s CPU wheels. Without it, pip pulls the CUDA build of PyTorch, gigabytes of GPU libraries that a TPU VM never uses. If Python 3.12 is not on your image, the repository&#39;s 10_setup_vm.sh uses uv to fetch it and runs these installs for you.</p><p>Now check that PyTorch can see the TPU:</p><pre>python -c &#39;import torch; x = torch.ones(2, 2, device=&quot;tpu&quot;); print(x.device, (x + x).cpu())&#39;</pre><p>You should see a tensor on tpu:0. Installing the wheel registers the backend automatically, so a plain import torch is enough. If you have set TORCH_DEVICE_BACKEND_AUTOLOAD=0, add import torch_tpu as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p4kDZThcKDh5HmEuWdIaYw.png" /></figure><p><em>Figure 4. From an empty project to a working TPU in four commands.</em></p><h3>Step 2: First tensors on the TPU</h3><p>The first script is a smoke test. The only TPU-specific line is the device. Everything else is plain PyTorch.</p><pre>import torch</pre><pre>device = torch.device(&quot;tpu&quot;)          # the only change from &quot;cuda&quot;</pre><pre>cpu_tensor = torch.ones((5, 5))<br>moved = cpu_tensor.to(device)           # move an existing tensor<br>direct = torch.randn((5, 5), device=device)  # or create it on the TPU</pre><pre>a = torch.randn((2048, 2048), device=device)<br>b = torch.randn((2048, 2048), device=device)<br>product = a @ b<br>print(product.cpu().abs().mean())       # .cpu() waits for the TPU</pre><pre>w = torch.randn((64, 64), device=device, requires_grad=True)<br>(w @ w.T).pow(2).mean().backward()     # autograd works as usual<br>print(w.grad.norm().cpu())</pre><p>Run it with python 01_smoke_test.py. You should see moved and direct on tpu:0, a finished matmul and a gradient norm.</p><p>Notice the .cpu() call. TPU operations run asynchronously, so the Python line returns before the chip has finished. Copying a result back to the host is the moment the work actually completes. Keep that in mind as soon as you start timing anything.</p><h3>Step 3: Eager vs torch.compile, and the recompile trap</h3><p>Next, a small transformer: six blocks of attention and a feed-forward layer, run three ways on a fixed input of shape 32 x 256 x 512.</p><pre>model = TinyTransformer(dim=512, layers=6).to(&quot;tpu&quot;).eval()<br>x = torch.randn(32, 256, 512, device=&quot;tpu&quot;)</pre><pre>out = model(x)                                   # 1. eager<br># TORCH_TPU_DEFER_AND_FUSE=1 python ...          # 2. DeferAndFuse<br>compiled = torch.compile(model, backend=&quot;tpu&quot;)   # 3. compiled<br>out = compiled(x)</pre><p>For each mode, the script times the first call, then takes the median of 20 more. Every timing stops only after the result has been copied to the CPU.</p><pre>python 02_eager_vs_compile.py --label strict<br>TORCH_TPU_DEFER_AND_FUSE=1 python 02_eager_vs_compile.py --label defer_and_fuse --skip-compile</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8X2BQtaO9fT1qKvISXuUdQ.png" /></figure><p><em>Figure 5. Results on one TPU v6e chip. First calls include compilation; steady state is what you live with in production.</em></p><p>Three things stand out.</p><p><strong>The first compiled call is slow.</strong> That is XLA compiling the whole graph. Every call after that reuses the compiled program.</p><p><strong>The numbers are close to CPU, but not identical.</strong> The script compares TPU output with the same model on the CPU. By default, TorchTPU runs float32 matrix multiplies in bfloat16 with float32 accumulation, which is what the MXU is built for. CUDA’s default is full float32. If you need tighter numerics, raise the precision, at a real cost in speed:</p><pre>torch.set_float32_matmul_precision(&quot;high&quot;)     # about 3x the MXU work; &quot;highest&quot; is about 6x</pre><p>To raise precision for one part of a model only, TorchTPU also provides a scoped torch.tpu.precision context manager.</p><p><strong>A new shape means a new compile.</strong> The script then calls the compiled model with a sequence length of 128 instead of 256:</p><pre>x_new = torch.randn(32, 128, 512, device=&quot;tpu&quot;)<br>compiled(x_new)   # slow: compiles for the new shape<br>compiled(x_new)   # fast: cached</pre><p>The first call with the new shape takes … s, and the second takes … ms. This is the single most important habit on TPUs: <strong>keep your shapes fixed.</strong> Pad to fixed lengths and use consistent batch sizes, and the cache does the rest.</p><h3>Step 4: Hugging Face models on the TPU</h3><p>With Transformers v5, putting a Hub model on a TPU takes one argument: device_map=&quot;tpu&quot;.</p><pre>from transformers import AutoModelForSequenceClassification, AutoTokenizer</pre><pre>name = &quot;distilbert/distilbert-base-uncased-finetuned-sst-2-english&quot;<br>tok = AutoTokenizer.from_pretrained(name)<br>model = AutoModelForSequenceClassification.from_pretrained(name, device_map=&quot;tpu&quot;).eval()</pre><pre>texts = [<br>    &quot;Moving my model to a TPU took one line of code.&quot;,<br>    &quot;The first compile was slow and I nearly gave up.&quot;,<br>    &quot;After warmup, every step was fast.&quot;,<br>    &quot;Dynamic shapes kept triggering recompiles, which was painful.&quot;,<br>]<br>batch = tok(texts, padding=&quot;max_length&quot;, max_length=64,<br>            truncation=True, return_tensors=&quot;pt&quot;).to(&quot;tpu&quot;)</pre><pre>with torch.no_grad():<br>    labels = model(**batch).logits.argmax(-1).cpu()</pre><p>Look at the tokenizer call. padding=&quot;max_length&quot; gives every batch the same shape. With the default dynamic padding, each batch could have a different length, and you would trigger a fresh compile every time. That is Step 3&#39;s lesson applied to real data.</p><p>The repository’s 03_hf_inference.py --generate goes one step further. It loads SmolLM2-135M-Instruct the same way, asks it to explain a TPU in one sentence, and generates twice so you can compare a cold run with a warm one. The same pattern works for a wide range of models on the Hub: pick a model and send it to &quot;tpu&quot;.</p><h3>Step 5: A tiny training loop</h3><p>Finally, training. The dataset is three interleaved spirals, a classic toy problem that no straight line can separate. The model is a small multilayer perceptron, trained with AdamW and cross-entropy loss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QUGnv1XUUzE34LLza9tw3A.png" /></figure><p><em>Figure 6. The three-spiral dataset. A linear model fails here; a small MLP learns it in a few epochs.</em></p><p>Here is the training loop. There is nothing TPU-specific in it.</p><pre>for epoch in range(epochs):<br>    running = torch.zeros((), device=&quot;tpu&quot;)<br>    for step in range(steps):<br>        idx = perm[step * batch_size:(step + 1) * batch_size]<br>        optimizer.zero_grad(set_to_none=True)<br>        loss = loss_fn(model(x_train[idx]), y_train[idx])<br>        loss.backward()<br>        optimizer.step()<br>        running += loss.detach()          # stays on the TPU<br>    print(running.item() / steps)         # one host sync per epoch</pre><p>Two details make it TPU-friendly.</p><ul><li><strong>Every batch has the same shape.</strong> The dataset size is a multiple of the batch size, so nothing recompiles in the middle of an epoch.</li><li><strong>One host sync per epoch.</strong> The loss is summed on the device, and .item() is called once per epoch instead of once per step. Each .item() makes the CPU wait for the TPU, so fewer waits mean a busier chip.</li></ul><p>Run it in eager mode, then again with --compile to wrap the model in torch.compile(backend=&quot;tpu&quot;):</p><pre>python 04_tiny_training.py<br>python 04_tiny_training.py --compile</pre><p>The loss falls steadily, and test accuracy climbs toward 100 percent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9pQHdSU5yiBa3_9L5QCU9A.png" /></figure><p><em>Figure 7. Training loss and test accuracy per epoch on one TPU v6e chip.</em></p><h3>Five gotchas that will save you hours</h3><ol><li><strong>Sync before you time.</strong> TPU work is asynchronous. Copy a result to the CPU with .cpu() before you stop the clock, or your timings measure nothing.</li><li><strong>Keep shapes static.</strong> Pad to fixed lengths and keep batch sizes consistent. Every new shape is a new compile.</li><li><strong>Minimize host syncs.</strong> .item(), printing a tensor, or a Python if on a tensor value inside a hot loop all stall the chip.</li><li><strong>Know your precision.</strong> The default is bfloat16 multiplies with float32 accumulation. Raise it only where you need it.</li><li><strong>Check op support.</strong> FlexAttention is not supported yet, so use F.scaled_dot_product_attention, and FP8 is still on the roadmap. Check the TorchTPU docs before porting something exotic.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RcG0WeRxHnlzNgr-gA3MEw.png" /></figure><p><em>Figure 8. Five habits for PyTorch on TPU.</em></p><h3>Where to go next</h3><ul><li><strong>Scale out.</strong> TorchTPU supports DDP, FSDP2 and DTensor through the tpu_dist backend, launched with torchrun. On Google Cloud, the launch looks like this:</li></ul><pre>eval $(python -m torch.tpu.distributed | sed &#39;s/^/export /&#39;) torchrun --nproc_per_node=4 train.py</pre><ul><li><strong>Serve.</strong> vLLM-TorchTPU and SGLang-TorchTPU bring both serving engines to TPUs with the same PyTorch backend.</li><li><strong>Pretrain.</strong> TorchTitan has TPU recipes for large-scale training.</li><li><strong>Get help from your coding assistant.</strong> The TPU agent suite, in preview, adds skills for onboarding, profiling and kernel work to assistants such as Claude Code.</li></ul><h3>Clean up</h3><p>When you are finished, delete the VM so the meter stops:</p><pre>gcloud compute instances delete torchtpu-demo --zone=europe-west4-a</pre><h3>Wrapping up</h3><p>TorchTPU makes the TPU feel like any other PyTorch device. You change one string, debug in eager mode, compile for speed, and keep your shapes fixed. The companion repository has every script from this post, and the video version walks through the same steps in about 11 minutes.</p><p>Github repo: <a href="https://www.github.com/kuanhoong/torchtpu">https://www.github.com/kuanhoong/torchtpu</a></p><p>If you try it on your own model, I would love to hear what worked and what did not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63bd823bdb8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your Second Brain Should Maintain Itself: OKF, Gemini, and a Multi-Agent Vault]]></title>
            <link>https://kuanhoong.medium.com/your-second-brain-should-maintain-itself-okf-gemini-and-a-multi-agent-vault-bec5563afaf1?source=rss-fe772cae62e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/bec5563afaf1</guid>
            <dc:creator><![CDATA[Kuan Hoong, Ph.D]]></dc:creator>
            <pubDate>Sat, 05 Sep 2026 01:55:38 GMT</pubDate>
            <atom:updated>2026-09-05T02:01:12.066Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3VcCm_KNMdGVEmIeNmiKrg.png" /></figure><p><em>How Google’s Open Knowledge Format turns a folder of Markdown into a knowledge base that AI agents can read, write, and keep honest.</em></p><p>We have all been there. You read a brilliant article, take careful notes, save a PDF, jot down a decision in a meeting, and three months later you cannot find any of it. The information exists. It is just scattered, unlinked, and effectively dead. As productivity writer Tiago Forte puts it, your notes should be a second brain, not a graveyard.</p><p>The “second brain” idea has been around for years. What is new, and genuinely exciting, is that large language models can finally make that second brain <em>active</em>. Not just a place to store what you know, but a system that can answer from it, write into it, and keep it healthy over time.</p><p>In this post I want to do three things. First, revisit what a second brain actually is. Second, introduce a piece of the puzzle that most people have not heard of yet: <a href="https://cloud.google.com/blog/products/data-analytics/how-the-open-knowledge-format-can-improve-data-sharing">Google’s <strong>Open Knowledge Format (OKF)</strong></a>. Third, show a working demo I built that ties OKF, Gemini, and <a href="https://adk.dev/">Google’s Agent Development Kit</a> together into a second brain that maintains itself. All the code is on GitHub.</p><h3>What a second brain really is</h3><p>Strip away the productivity influencers and a second brain is simple: an external, trusted system that stores what you know so your biological brain is freed to think, not to remember.</p><p>Two clean methods, both popularised by Tiago Forte, are all you need to make it work. <strong>CODE</strong> describes the workflow: Capture what resonates, Organise it by where it is useful, Distill it to its essence, and Express it as output. <strong>PARA</strong>describes where things live: Projects, Areas, Resources, Archives, sorted by how actionable they are rather than by topic.</p><p>None of this requires fancy software. A folder of plain text files does the job. And that plainness turns out to be the whole point, because plain, open files are exactly what an AI can read.</p><h3>The catch with plain RAG</h3><p>The obvious way to make notes intelligent is Retrieval-Augmented Generation (RAG): embed your documents, retrieve the relevant chunks for a question, and let the model answer from them. RAG is great, and I am not knocking it. But classic RAG behaves like an <em>interpreter</em>. Every question rebuilds context from scratch out of raw, messy source text.</p><p>There is another posture available now: treat the AI like a <em>compiler</em>. Instead of re-reading raw notes on every query, the AI pre-synthesises messy input once into a clean, structured, interlinked note that compounds in value over time. Your knowledge base stops being a pile of documents you search and becomes a curated library that grows more useful the more you use it.</p><p>To do that well, you need a format both humans and machines can trust. That is where OKF comes in.</p><h3>Introducing the Open Knowledge Format (OKF)</h3><p>Google Cloud released the <a href="https://cloud.google.com/blog/products/data-analytics/how-the-open-knowledge-format-can-improve-data-sharing">Open Knowledge Format</a> in 2026 as an open, vendor-neutral specification for representing knowledge that AI systems and agents can consume. The striking thing, when you look at it, is how deliberately unfancy it is.</p><p>An OKF bundle is just a directory of Markdown files with YAML frontmatter, linked together with ordinary Markdown links. That is the entire format.</p><ul><li>The <strong>file path is the concept’s identity</strong>. playbooks/project-success.md <em>is</em> the &quot;project success&quot; concept.</li><li><strong>Links are normal Markdown links</strong>, and those links form a knowledge graph.</li><li>Only one frontmatter field is required: type. Everything else is up to you.</li></ul><p>If that sounds familiar to anyone who uses Obsidian, it should. An Obsidian vault is roughly ninety percent of an OKF bundle already. What OKF adds is that this shape is now a written-down, portable standard that agents are being built to read and write.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eAG8m36XY3Mf2XLikAvm7A.png" /><figcaption>The three-layer OKF second brain (raw sources → wiki → schema)</figcaption></figure><h3>The purpose: knowledge that is not locked in</h3><p>Most organisations keep knowledge trapped in incompatible silos: a wiki here, a metadata catalogue there, docstrings in code, and a lot of it only in people’s heads. Agents keep rediscovering the same context. OKF exists to end that. Because it is a format and not a platform, with no SDK, no account, and no runtime to adopt, your knowledge lives in plain files you fully own. You can version it in Git, ship it as a tarball, mount it on a filesystem, and point any model you like at it. Gemini today, something else tomorrow, same files.</p><h3>The usage: an LLM-friendly wiki with trust signals</h3><p>The way you use OKF is to treat it as a shared, curated library that both people and agents maintain. Each note is atomic (one concept), each folder has an index map so an agent can do a cheap first pass instead of scanning everything, and the frontmatter carries small structured fields the agent can reason about.</p><p>The most important of those fields, for my money, is status. A note can be draft (machine-generated, not yet checked), stable(verified, safe to answer from), or deprecated (superseded, never to be used). This one field is what lets an agent give deterministic, contradiction-free answers, as you will see in the demo. A note looks like this:</p><pre>---<br>type: Playbook<br>title: &quot;Project Success Criteria (v2)&quot;<br>status: stable<br>stale_after: 2027-08-28T00:00:00Z<br>tags: [delivery, criteria]<br>---</pre><pre># Project Success Criteria (v2)<br>A project is successful when...</pre><h3>The demo: a second brain that maintains itself</h3><p>To make this concrete I built a small, working system and put it on GitHub. It has three parts:</p><ul><li>an <strong>OKF vault</strong> of developer notes (Kubernetes, Go, RAG, embeddings, and a few playbooks),</li><li><strong>Gemini</strong> as the reasoning engine, and</li><li>Google’s <a href="https://adk.dev/">Agent Development Kit</a> (ADK) running a <strong>multi-agent</strong> system on top of the vault.</li></ul><p>A root agent I call the <strong>Archivist</strong> answers questions from the vault and delegates the work of maintaining it to four specialists: a <strong>researcher</strong> (which uses Gemini’s built-in Google Search), a <strong>writer</strong> (which compiles content into a clean OKF note), a <strong>linker</strong> (which wires new notes into the index maps), and a <strong>reviewer</strong> (which audits the vault’s health). Two rules are baked into the Archivist: read an index before opening notes, and answer only from stable notes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yNIk3MgFbqHUDx4NdezIvw.png" /><figcaption>The demo architecture (Archivist, the four agents, vault, graph)</figcaption></figure><p>You drive the whole thing from ADK’s web dev UI, which shows the agent’s live tool-call trace. That trace is the point. You can literally watch the agent decide what to read, what to write, and what to reject.</p><h3>The moment that sells it: contradiction resolution</h3><p>Here is my favourite part. The vault deliberately contains two conflicting playbooks about what makes a project successful. One is marked stable, the other deprecated. Ask the Archivist a simple question:</p><blockquote><em>What are our criteria for a successful project?</em></blockquote><p>A naive system would blend the two and give you mush. The Archivist instead reads both, sees that one is deprecated, ignores it, and answers only from the stable one, with a citation. It did not average two contradictory notes. It reasoned about which one to trust. That is the trust signal doing its job.</p><p>That same status field drives a small lifecycle. New notes the agent writes are always draft. They only become stable when a human runs a verify step. Deprecated notes are never used. You stay the human in the loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*FqKu-Uhm4Ri8T4kt4GfV7A.png" /><figcaption>The draft → stable → deprecated lifecycle</figcaption></figure><h3>Watching the brain change</h3><p>Because the vault is plain files, I also ship a tiny offline visualiser that renders it as a force-directed knowledge graph, colour-coded by trust signal: green for stable, amber for draft, grey for deprecated, and a pink ring for notes that are past their freshness date. Every agent action changes the picture. When the reviewer flags a stale note, you see it. When you verify a draft, you watch the node turn from amber to green.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*_xONfOXpWzVuSy4XWkp4FQ.png" /><figcaption>The real colour-coded knowledge graph from the demo</figcaption></figure><h3>The full loop</h3><p>Put together, a single session can run the whole lifecycle: drop a messy note in the inbox and the writer compiles it into a clean, linked note; ask a question and get a grounded, contradiction-free answer; ask the agent to research something new and the researcher, writer, linker, and reviewer chain runs end to end; ask what is rotting and the reviewer flags stale and deprecated notes for you to act on. RAG reads your notes. This agent keeps them.</p><h3>Try it yourself</h3><p>The full demo, including the OKF vault, the ADK agents, the graph visualiser, and a step-by-step runsheet, is open source under the MIT licence:</p><p><a href="https://github.com/kuanhoong/second-brain-agent"><strong>github.com/kuanhoong/second-brain-agent</strong></a></p><p>You will need Python and a free <a href="https://aistudio.google.com/apikey">Google AI Studio</a> key. Clone it, drop your key in a .env, run the graph generator, launch adk web, and select the archivist agent. The README walks through the four demo prompts.</p><h3>A few honest caveats</h3><p>OKF is an early specification (v0.1), and the status and freshness fields I lean on are a spec-compatible convention on top of it rather than official schema, so check the current spec before you build production systems on it. ADK and Gemini model names move quickly, so pin versions and re-test. And agents are non-deterministic, which is exactly why trust signals, a human verification step, and a pristine, resettable vault matter so much.</p><h3>Where this is going</h3><p>The pattern here is bigger than one demo. Once your knowledge lives in an open, local format with trust signals, the AI stops being a search box bolted onto your notes and becomes a collaborator that curates them. It compiles the messy into the structured, refuses to answer from what it should not trust, and does its own upkeep while you sleep.</p><p>Your second brain has spent years being a place you put things and lost them. It is time it started keeping itself.</p><p><em>Built with Obsidian, Google’s Open Knowledge Format, Gemini, and the Agent Development Kit. Code and diagrams: </em><a href="https://github.com/kuanhoong/second-brain-agent"><em>github.com/kuanhoong/second-brain-agent</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bec5563afaf1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutorial: Build a Manufacturing Procurement Multi-Agent System with Google ADK 2 Graphs]]></title>
            <link>https://kuanhoong.medium.com/tutorial-build-a-manufacturing-procurement-multi-agent-system-with-google-adk-2-graphs-260c57d0cee3?source=rss-fe772cae62e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/260c57d0cee3</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[google-adk]]></category>
            <category><![CDATA[multi-agent-systems]]></category>
            <category><![CDATA[ai-applications]]></category>
            <category><![CDATA[manufacturing]]></category>
            <dc:creator><![CDATA[Kuan Hoong, Ph.D]]></dc:creator>
            <pubDate>Fri, 03 Jul 2026 02:13:58 GMT</pubDate>
            <atom:updated>2026-07-03T02:13:58.195Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A step-by-step guide to ADK 2’s new graph workflow engine — we’ll wire LLM subagents, routing, a refinement loop, and a parallel fan-out into ONE graph that handles real supply-chain requests.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pXhumo-_SYUZcoBiHk9MJg.png" /></figure><p>Google’s <a href="https://adk.dev/"><strong>Agent Development Kit (ADK) 2</strong></a> ships with a headline feature: a <strong>graph-based workflow engine</strong>. Instead of wiring agents together with SequentialAgent, LoopAgent, and ParallelAgent wrappers — or hand-rolled Python dispatch loops — you express an entire multi-agent application as <strong>nodes connected by edges</strong>, and the framework&#39;s scheduler handles execution, concurrency, and state.</p><p>In this tutorial we’ll build a complete <strong>manufacturing procurement multi-agent system</strong> on the graph API, end to end. By the end you will know how to:</p><ol><li>Define <strong>LLM subagents</strong> as graph nodes (grounded with Google Search)</li><li>Route requests with an LLM classifier + a <strong>deterministic dispatch node</strong></li><li>Build a <strong>sequential</strong> chain, a <strong>refinement loop</strong>, and a <strong>parallel fan-out/fan-in</strong> — all as edges</li><li>Run the whole thing with a <strong>single </strong><strong>Runner</strong> and stream every node firing live</li></ol><p>All code is in the companion repo — clone it and follow along:</p><p>👉 <a href="https://github.com/kuanhoong/adk-graph-demo"><strong>https://github.com/kuanhoong/adk-graph-demo</strong></a></p><h3>Why procurement? The use case</h3><p>Manufacturing supply-chain work is a perfect stress test for multi-agent design, because real requests decompose into very different workflow <em>shapes</em>:</p><p>A buyer asks…What it actually needs”Who can supply IP67 cable glands?”One focused <strong>sourcing specialist</strong>”What standards do Li-ion packs need for the EU?”One <strong>compliance specialist</strong> (RoHS, REACH, UL, CE…)”Find a supplier for M3x10 screws, <em>then</em> quote lead time to Penang”A <strong>sequential</strong> pipeline: find → quote”Build a PO for 10,000 screws under $350, arriving in 20 days”An <strong>iterative loop</strong>: propose → critique vs budget → refine”Evaluate this die-cast enclosure: price, compliance, logistics risk”<strong>Parallel</strong> research fanned out, then synthesized</p><p>Each specialist agent is small, focused, and grounded with <strong>Google Search</strong> — real suppliers, real prices, real lead times. The hard part has always been the orchestration: one incoming request must reach the right shape of workflow. That’s exactly what the graph solves.</p><h3>The architecture we’re building</h3><p>Here is the entire system — one ADK 2 Workflow. Rounded nodes are LLM agents (&quot;subagents&quot;); rectangles are plain Python <strong>function nodes</strong>; the dashed box is a <strong>JoinNode</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W4HqKl--Om_VuihgBsasww.png" /></figure><p>A request enters at START, a function node stashes it in state, an LLM router classifies it, a dispatch node turns that classification into a <strong>graph route</strong>, and one of five branches runs. Every branch ends at a terminal node whose output becomes the final brief.</p><p>Keep this picture in mind — every step below builds one piece of it.</p><h3>Prerequisites</h3><ul><li>Python 3.10+</li><li>A free Gemini API key from <a href="https://aistudio.google.com/apikey">Google AI Studio</a></li><li>pip install &quot;google-adk&gt;=2.3.0&quot; — the graph API (google.adk.workflow) landed in the 2.x line</li></ul><pre>git clone https://github.com/kuanhoong/adk-graph-demo<br>cd adk-graph-demo<br>pip install -r requirements.txt<br>cp .env.example .env        # then set GOOGLE_API_KEY=...</pre><h3>Step 1 — Define the specialist subagents (LLM nodes)</h3><p>In ADK 2, a subagent used in a graph is just a plain Agent. No wrapper classes, no parent/child registration — the graph decides who runs and when:</p><pre># manufacturing_agent/sub_agents/sourcing.py<br>from google.adk.agents import Agent<br>from google.adk.tools import google_search</pre><pre>sourcing_agent = Agent(<br>    name=&quot;sourcing_agent&quot;,<br>    model=MODEL,  # e.g. gemini-3.5-flash<br>    tools=[google_search],<br>    description=&quot;Finds qualified suppliers for a part, component, or raw material.&quot;,<br>    instruction=&quot;&quot;&quot;You are an expert procurement sourcing specialist...<br>    For each recommendation, state the supplier&#39;s name and why they fit<br>    (certifications, MOQ, region, specialization). Use Google Search to<br>    find current, real vendors.&quot;&quot;&quot;,<br>)</pre><p>When an Agent runs as a graph node it operates in <strong>single-turn mode</strong>: it receives the previous node&#39;s output as its input message, produces one answer, and hands that answer to the next edge. This is a key mental-model shift from ADK 1.x — <strong>data flows along the edges</strong>, not through a shared conversation.</p><p>One consequence worth knowing: a single-turn node doesn’t see the chat history. If a downstream agent needs the buyer’s original request, you pass it explicitly — which brings us to state.</p><h3>Step 2 — Capture state, classify, and dispatch</h3><p>The graph’s entry sequence is three nodes: a function node, an LLM node, and another function node.</p><p><strong>First</strong>, capture the raw request into session state so any later prompt can reference it:</p><pre># manufacturing_agent/nodes.py<br>def capture_request(ctx: Context, node_input: str) -&gt; str:<br>    &quot;&quot;&quot;Store the original user request in state and pass it along.&quot;&quot;&quot;<br>    ctx.state[&quot;original_request&quot;] = node_input<br>    return node_input</pre><p>That’s a complete graph node. Any Python function becomes a FunctionNode automatically when it appears in an edge — ctx gives you state access, node_input is whatever the previous node produced, and the return value flows to the next node.</p><p><strong>Second</strong>, the router. Classification is what LLMs are good at, so the router is an ordinary agent whose instruction lists the route names and ends with <em>“Return the single, most appropriate option’s name and nothing else.”</em></p><p><strong>Third</strong> — and this is the part I’d encourage you to steal — the <em>dispatch</em> is deterministic code, not an LLM. A function node inspects the router’s reply and emits a <strong>route</strong> on its event:</p><pre># manufacturing_agent/nodes.py<br>from google.adk.events.event import Event</pre><pre>def route_dispatch(ctx: Context, node_input: str) -&gt; Event:<br>    &quot;&quot;&quot;Convert the router LLM&#39;s reply into a graph route.&quot;&quot;&quot;<br>    reply = node_input.strip().strip(&quot;&#39;\&quot;`&quot;)<br>    route = next((name for name in KNOWN_ROUTES if name in reply), reply)<br>    # The chosen branch receives the ORIGINAL request, not the router&#39;s reply.<br>    return Event(route=route, output=ctx.state[&quot;original_request&quot;])</pre><p>Event(route=...) is the graph&#39;s traffic signal: edges can carry route conditions, and only the edges matching the emitted route fire. Note the separation of concerns — the LLM <em>decides</em>, the code <em>dispatches</em>. If the router hallucinates a name that matches nothing, a DEFAULT_ROUTE edge (Step 6) catches it. No unknown-route crashes.</p><h3>Step 3 — The sequential branch: chain edges + state</h3><p>The find-and-quote workflow is two agents in a row. In ADK 1.x this needed a SequentialAgent wrapper; in ADK 2 it&#39;s literally one tuple in the edge list: (supplier_finder_agent, quote_agent).</p><p>The interesting detail is how data moves. The finder outputs <em>only</em> a supplier name, and saves it to state with output_key:</p><pre>supplier_finder_agent = Agent(<br>    name=&quot;supplier_finder_agent&quot;,<br>    model=MODEL,<br>    tools=[google_search],<br>    instruction=&quot;&quot;&quot;Find the single best supplier for the part in the user&#39;s<br>    request. Output *only* the name of the supplier and nothing else.&quot;&quot;&quot;,<br>    output_key=&quot;supplier&quot;,   # ADK saves the final response to state[&quot;supplier&quot;]<br>)</pre><pre>quote_agent = Agent(<br>    name=&quot;quote_agent&quot;,<br>    model=MODEL,<br>    tools=[google_search],<br>    instruction=&quot;&quot;&quot;You are a procurement quoting assistant. The buyer wants<br>    to purchase from this supplier: {supplier}.</pre><pre>    The buyer&#39;s full original request was:<br>    &quot;{original_request}&quot;</pre><pre>    Provide: unit price range, manufacturing + shipping lead time, and the<br>    likely shipping route / incoterms. Return the quote in MARKDOWN.&quot;&quot;&quot;,<br>)</pre><p>The {supplier} and {original_request} placeholders are resolved from session state at prompt time. So the quote agent gets the supplier name twice — as its input message (flowing along the edge) <em>and</em> in its instruction (via state). Belt and suspenders.</p><h3>Step 4 — The loop branch: a routed cycle</h3><p>This is my favorite upgrade in ADK 2. In v1, the PO optimizer needed a LoopAgent(max_iterations=3) plus a special exit_loop <strong>tool</strong> that the refiner LLM had to <em>remember to call</em>. If the model forgot, the loop ran to exhaustion.</p><p>In ADK 2, a loop is simply a <strong>cycle in the graph</strong>. The only rule: the cycle must contain at least one conditional (routed) edge, so it can’t spin forever. That lets us move the exit condition out of the LLM’s hands entirely and into a small control node:</p><pre># manufacturing_agent/nodes.py<br>MAX_REFINEMENT_ROUNDS = 3</pre><pre>def check_po_approval(ctx: Context, node_input: str) -&gt; Event:<br>    &quot;&quot;&quot;Loop control: keep refining, or exit the cycle.&quot;&quot;&quot;<br>    rounds = ctx.state.get(&quot;po_rounds&quot;, 0)<br>    if COMPLETION_PHRASE in node_input:               # critic approved<br>        return Event(route=&quot;approved&quot;, output=node_input)<br>    if rounds &gt;= MAX_REFINEMENT_ROUNDS:               # round budget spent<br>        return Event(route=&quot;approved&quot;, output=node_input)<br>    ctx.state[&quot;po_rounds&quot;] = rounds + 1<br>    return Event(route=&quot;refine&quot;, output=node_input)   # back around the cycle</pre><p>The flow: po_planner_agent proposes a purchase order → cost_critic_agent critiques it against the buyer&#39;s budget and deadline (emitting an exact completion phrase when satisfied) → check_po_approval routes refine back to po_refiner_agent (which loops to the critic) or approved out to a formatting node.</p><p>I stress-tested this with a deliberately impossible request — <em>10,000 titanium screws under a $5 total budget, arriving in 2 days</em>. The graph ran exactly three refinement rounds (each proposing a cheaper alternative), then exited honestly: <em>“Best candidate after 3 refinement rounds — review open critique below.”</em> Deterministic exit, no LLM cooperation required.</p><h3>Step 5 — The parallel branch: fan-out + JoinNode</h3><p>The part evaluator fans one request out to three researchers <strong>concurrently</strong> — price, compliance, and logistics. Fan-out in an edge list is just a tuple of nodes; fan-in is a dedicated JoinNode:</p><pre># manufacturing_agent/nodes.py<br>from google.adk.workflow import JoinNode</pre><pre>part_research_join = JoinNode(<br>    name=&quot;part_research_join&quot;,<br>    description=&quot;Waits for price, compliance, and logistics research to finish.&quot;,<br>)</pre><p>A JoinNode is a barrier: it waits until <strong>all</strong> of its predecessors complete, then passes a dict of {node_name: output} downstream. The synthesis agent receives all three research summaries as one JSON input message:</p><pre>synthesis_agent = Agent(<br>    name=&quot;synthesis_agent&quot;,<br>    model=MODEL,<br>    instruction=&quot;&quot;&quot;Your input message is a JSON object with research from<br>    three analysts: &quot;price_agent&quot;, &quot;compliance_check_agent&quot;, &quot;logistics_agent&quot;.</pre><pre>    The buyer&#39;s original request was: &quot;{original_request}&quot;</pre><pre>    Combine the research into a single supplier-evaluation brief, as a<br>    bulleted MARKDOWN summary with a one-line recommendation at the end.&quot;&quot;&quot;,<br>)</pre><p>No shared-state gymnastics, no race conditions, no polling — the scheduler runs the three branches concurrently and the join guarantees the synthesis only fires once everything is in.</p><h3>Step 6 — Wire the whole graph</h3><p>Now the payoff. Here is the <em>entire</em> orchestration of the system — every pattern from Steps 2–5 as one edges=[...] literal:</p><pre># manufacturing_agent/agent.py<br>from google.adk.workflow import DEFAULT_ROUTE, Workflow</pre><pre>root_agent = Workflow(<br>    name=&quot;procurement_workflow&quot;,<br>    edges=[<br>        # Ingest -&gt; classify -&gt; dispatch.<br>        (&quot;START&quot;, capture_request, router_agent, route_dispatch),</pre><pre>        # The router&#39;s answer becomes the graph route.<br>        (route_dispatch, {<br>            &quot;sourcing_agent&quot;: sourcing_agent,                # specialist<br>            &quot;compliance_agent&quot;: compliance_agent,            # specialist<br>            &quot;find_and_quote_agent&quot;: supplier_finder_agent,   # sequential<br>            &quot;po_optimizer_agent&quot;: po_planner_agent,          # loop<br>            &quot;part_evaluator_agent&quot;: (                        # parallel fan-out<br>                price_agent, compliance_check_agent, logistics_agent,<br>            ),<br>            DEFAULT_ROUTE: general_procurement_agent,        # safety net<br>        }),</pre><pre>        # SEQUENTIAL branch: find a supplier, then quote it.<br>        (supplier_finder_agent, quote_agent),</pre><pre>        # LOOP branch: a routed cycle with a deterministic exit.<br>        (po_planner_agent, cost_critic_agent, check_po_approval),<br>        (check_po_approval, {&quot;refine&quot;: po_refiner_agent, &quot;approved&quot;: finalize_po}),<br>        (po_refiner_agent, cost_critic_agent),</pre><pre>        # PARALLEL branch: three researchers -&gt; join -&gt; synthesis.<br>        ((price_agent, compliance_check_agent, logistics_agent),<br>         part_research_join, synthesis_agent),<br>    ],<br>)</pre><p>Reading guide:</p><ul><li>A <strong>tuple</strong> chains nodes sequentially: (a, b, c) means a → b → c.</li><li>A <strong>dict</strong> is a routing map: keys are route values, values are destination nodes.</li><li>A <strong>nested tuple</strong> fans out to several nodes at once.</li><li>A <strong>cycle</strong> (check_po_approval → po_refiner_agent → cost_critic_agent → check_po_approval) is a loop; it&#39;s legal because one of its edges is routed.</li><li>Nodes with no outgoing edges are <strong>terminal</strong> — whichever one runs produces the workflow’s final output.</li></ul><p>The graph validates itself at construction time: unreachable nodes, duplicate names, and <em>unconditional</em> cycles (which would loop forever) all raise errors before anything runs.</p><h3>Step 7 — Run it: one Runner, streamed events</h3><p>Because a Workflow behaves like any other agent, the whole system runs under a <strong>single </strong><strong>Runner</strong>:</p><pre># manufacturing_agent/runner.py<br>from google.adk.runners import Runner<br>from google.adk.sessions import InMemorySessionService</pre><pre>session_service = InMemorySessionService()<br>runner = Runner(node=root_agent, session_service=session_service,<br>                app_name=&quot;manufacturing_procurement&quot;)</pre><pre>async for event in runner.run_async(user_id=user_id, session_id=session.id,<br>                                    new_message=new_message):<br>    ...</pre><p>Compare with the ADK 1.x version of this project: one Runner for the router, a Python registry lookup, then a <em>second</em> Runner for the chosen worker.</p><p>The event stream is where the graph really shines for UX. Two details you’ll want for any UI:</p><ul><li><strong>Routing decisions</strong> ride on event.actions.route — so you can render &quot;route → refine&quot; moments live.</li><li><strong>Node outputs</strong> surface two ways: LLM nodes flag their final message with event.node_info.message_as_output, while function nodes set event.output directly. The last output-carrying event of a run is the terminal node&#39;s answer:</li></ul><pre>def event_output_text(event) -&gt; str | None:<br>    if getattr(event.node_info, &quot;message_as_output&quot;, None) and event.content:<br>        return &quot;&quot;.join(p.text or &quot;&quot; for p in event.content.parts if p.text)<br>    if event.output is not None:<br>        return str(event.output)<br>    return None</pre><p>The repo includes a Streamlit “control room” that streams every node as a colour-coded card — cyan specialists, green sequential, amber loop, violet parallel — plus a one-click PDF export of the final brief:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XKN_bfg3g0BUYJf_wTlHIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3lf-yrVWoT4QCAU1EFtplw.png" /></figure><h3>Step 8 — Test every branch</h3><pre>streamlit run app.py     # web control room<br>python main.py           # or run all five demo queries headless</pre><p>Try this requestBranch that fires”Who are good suppliers for IP67-rated industrial cable glands?”Specialist (sourcing)”What compliance standards do lithium-ion battery packs need in the EU?”Specialist (compliance)”Find a supplier for M3x10 stainless screws, then quote lead time to Penang.”Sequential”Build a PO for 10,000 M3x10 screws under a $350 budget, within 20 days.”Loop”Evaluate an aluminum 6061 die-cast enclosure: price, compliance, logistics.”Parallel</p><p>From my runs: the sequential branch found MISUMI and produced a full Penang shipping quote; the loop approved a $255 PO on the first critique; and the parallel branch’s synthesis flagged a real technical risk (6061 is prone to hot cracking in die-casting) and recommended an alloy change — genuinely decision-ready output.</p><h3>What the graph bought us (ADK 1.x → ADK 2)</h3><p>ADK 1.xADK 2 graphManual Python dispatch loop + worker registryOne routing-map edge + Event(route=...)SequentialAgent([finder, quote])A chain edge: (finder, quote)LoopAgent + an exit_loop tool the LLM must callA routed cycle + a 10-line control nodeParallelAgent nested inside a SequentialAgentFan-out tuple + JoinNodeTwo Runners per requestOne Runner for everything</p><p>The deeper win is <strong>separation of concerns</strong>: LLMs do what they’re good at (classify, research, write) and plain Python does what <em>it’s</em> good at (routing, counting iterations, joining results). The system’s entire topology is readable in one edges=[...] literal — the code <em>is</em> the architecture diagram.</p><h3>Resources</h3><ul><li><strong>Companion repo (all code in this tutorial):</strong> <a href="https://github.com/kuanhoong/adk-graph-demo">https://github.com/kuanhoong/adk-graph-demo</a></li><li><strong>ADK 2.0 announcement — graph engine overview:</strong> <a href="https://developers.googleblog.com/announcing-adk-go-20/">https://developers.googleblog.com/announcing-adk-go-20/</a></li><li><strong>ADK graph documentation — nodes, edges, routing:</strong> <a href="https://adk.dev/graphs/">https://adk.dev/graphs/</a></li><li><strong>google-adk on PyPI:</strong> <a href="https://pypi.org/project/google-adk/">https://pypi.org/project/google-adk/</a></li><li><strong>Get a free Gemini API key:</strong> <a href="https://aistudio.google.com/apikey">https://aistudio.google.com/apikey</a></li></ul><p><em>If you found this useful, follow me for more hands-on agent engineering tutorials — and let me know in the comments what you’d orchestrate as a graph.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=260c57d0cee3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spec-Driven Development vs Vibe Coding: Why Kiro Bets on Writing It Down]]></title>
            <link>https://kuanhoong.medium.com/spec-driven-development-vs-vibe-coding-why-kiro-bets-on-writing-it-down-df63b9299820?source=rss-fe772cae62e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/df63b9299820</guid>
            <category><![CDATA[spec-driven-development]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[amazon]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kiro]]></category>
            <dc:creator><![CDATA[Kuan Hoong, Ph.D]]></dc:creator>
            <pubDate>Fri, 05 Jun 2026 00:06:06 GMT</pubDate>
            <atom:updated>2026-06-05T00:48:58.359Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xSqmwTdWwhins-HEmcQUgQ.png" /></figure><p><strong>TL;DR:</strong> Vibe coding is fast and fun, but it loses every decision into a disposable chat thread and tends to bloat your codebase. Spec-driven development, the approach <a href="https://kiro.dev/">Kiro</a> is built around, makes intent explicit and version-controlled before any code is written. The result holds up on large codebases and across teams. This post breaks down the real difference, the data on why unstructured AI coding gets expensive, and when each approach actually wins.</p><h3>Key Takeaways</h3><ul><li><strong>Vibe coding optimizes the first iteration; spec-driven development optimizes the whole lifecycle.</strong> One is for discovery, the other for systems that have to last.</li><li><strong>The hidden cost of vibe coding is measurable.</strong> <a href="https://www.gitclear.com/ai_assistant_code_quality_2025_research">GitClear’s analysis</a> of 211 million lines of code found copy-pasted code exceeded refactored code for the first time in 2024, with code duplication up roughly eightfold.</li><li><strong>Kiro splits the workflow into two explicit modes:</strong> Vibe (chat first, then build) and Spec (plan first, then build), and lets you switch between them.</li><li><strong>Specs in Kiro are version-controlled artifacts,</strong> not chat history. Requirements, design, and tasks live as files you can review, edit, and track.</li><li><strong>It’s not either/or.</strong> The strongest pattern is vibe-code to explore, then formalize into specs before anything ships to production.</li></ul><h3>You’re Not Bad at Prompting. The Workflow Is the Problem.</h3><p>Open any AI coding tool, describe a feature, and watch working code appear in seconds. For a weekend prototype, this feels like a superpower. Then you try it on a production codebase with real stakes, and the cracks show: the code compiles but solves the wrong problem, the agent forgets a decision it made three prompts ago, and nobody on the team can explain why a given approach was chosen because the reasoning evaporated into a chat thread.</p><p>This is the core tension in AI-assisted development right now, and it’s exactly what <strong>spec-driven development</strong> is designed to fix. Amazon’s Kiro, which reached general availability in November 2025 after more than 250,000 developers used it in preview, is the clearest bet on this shift. This post explains what changes when you stop vibing and start speccing, and just as importantly, when you shouldn’t.</p><h3>What Is Vibe Coding, Really?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2jlyeI6Bf2p9OxTDT53ccw.png" /></figure><p>Vibe coding is reactive, exploratory development. You prompt, the AI generates, you eyeball the result, you prompt a correction, and you repeat until it looks right. It’s speculative software development: fast, fluid, improvisational. You reason abstractly about what might work and let the tool play it out in code.</p><p>This is genuinely the right tool for some jobs. Exploration, learning a new stack, throwaway prototypes, and proof-of-concept work all benefit from the speed and the flow state. The problem isn’t that vibe coding is bad. It’s that it’s optimized for the first iteration, not for the entire life of the software.</p><p>Two failure modes show up under pressure. First, <strong>context loss</strong>: on complex tasks or large codebases, the agent lacks the context to get it right and misinterprets intent. Second, <strong>decision amnesia</strong>: every “actually, do it this way” lives only in the conversation. Six months later, when someone asks why the payment flow retries three times, the answer is gone.</p><h3>What Is Spec-Driven Development?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kw7YX1h7M1d4AS-gU0dCgg.png" /></figure><p>Spec-driven development is proactive. Instead of jumping to code, you make intent explicit first, then let the agent build against it. In Kiro, a single natural-language prompt like “add a product review system” expands into three reviewable artifacts:</p><ul><li><strong>Requirements</strong> — Your prompt becomes user stories with acceptance criteria in EARS notation (Easy Approach to Requirements Syntax). This forces precision: not “add reviews,” but explicit, testable conditions.</li><li><strong>Design</strong> — Kiro analyzes your existing codebase and proposes architecture, system design, and tech stack that fit the code you already have, not a generic template.</li><li><strong>Tasks</strong> — The design breaks into discrete, dependency-sequenced steps, each mapped back to the requirement it satisfies, with optional tests. You execute them and watch each move from “in progress” to “done.”</li></ul><p>The decisive detail: you review and approve at each stage. Requirements off? Edit them before any design happens. Design wrong? Fix it before a single line of code exists. As AWS senior principal engineer David Yanacek, an advisor to the Kiro team, put it, you spend time talking about what good looks like, and the tool responds with requirements, a technical design, and a task breakdown.</p><h3>Why Does Vibe Coding Get Expensive at Scale?</h3><p>Here is the part most Kiro write-ups skip: there’s hard data on what unstructured AI coding does to a codebase over time.</p><p>GitClear analyzed 211 million changed lines of code from 2020 to 2024 across private repositories and major open-source projects. The findings are a direct argument for structure. In 2024, copy-pasted code exceeded “moved” (refactored) code for the first time in the dataset’s history. Refactoring activity, the signature of code reuse, fell from around 24% of changes in 2020 to under 10% in 2024. Duplicated code blocks rose roughly eightfold. And code churn, new code revised within two weeks of being committed, nearly doubled from 3.1% to 5.7%.</p><p>That churn number is the tell. Churn is a reliable proxy for premature, wrong-shaped code: something gets committed, then immediately revisited because it didn’t actually fit. When you vibe-code at speed without a spec, you generate more, reuse less, and revise sooner. You pay for the work twice.</p><p>Spec-driven development attacks this at the root. By defining requirements and a codebase-aware design first, the agent produces code that fits the first time more often, which means fewer correction cycles and less churn.</p><h3>What Makes Kiro’s Specs Different From a Chat Log?</h3><p>The single biggest structural advantage is that <strong>Kiro’s specs are version-controlled artifacts</strong>, not ephemeral conversation. When requirements change, you update the spec file rather than letting a decision disappear into chat history. Writing things down makes them long-lived, durable, and official.</p><p>This is what turns AI development from a solo improvisation into a real collaboration between you and the agent, and between you and your team. A spec is reviewable. A product manager, an engineer, and the agent can all read the same requirements.md and agree on what&#39;s being built before effort is spent. Some teams even generate Jira-style tickets and acceptance criteria straight from the requirements file.</p><p>Kiro reinforces this with surrounding context systems. <strong>Steering files</strong> (stored in .kiro/steering/) give the agent persistent knowledge of your product, stack, and conventions, so it behaves consistently instead of relearning your project every session. <strong>Agent hooks</strong> trigger on events like a file save to run background tasks such as generating docs or tests, effectively an enforcer that validates changes made by you or the agent. <strong>Native MCP support</strong> connects Kiro to your docs, databases, and APIs.</p><h3>So Which One Should You Use?</h3><p>Neither approach is universally “better.” They’re different philosophies for different stages, and Kiro deliberately ships both modes so you can switch in the session picker.</p><p>Reach for <strong>vibe coding</strong> when you’re exploring an idea, learning, prototyping, or working solo on something disposable. The speed and flow are the point, and the lack of ceremony is a feature.</p><p>Reach for <strong>spec-driven development</strong> when more than one person needs to understand the codebase, when users or business processes will depend on the system, or when the work lands on a large existing codebase. These are the signals that the cost of miscoordination has surpassed the cost of writing and maintaining a spec.</p><p>The practical synthesis that experienced practitioners keep landing on: vibe-code to discover the requirements, then formalize them into version-controlled specs before production. You keep the fun of vibe coding and fix its limitations, which is exactly how Kiro itself frames the tradeoff.</p><h3>The Shift This Actually Represents</h3><p>Kiro marks the point where coding starts giving way to architecture. The scarce skill is no longer typing logic into syntax, the agent does that now. The scarce skill is articulating intent with enough clarity and precision that a system like Kiro can bring it to life correctly. Your role moves from code-typist to system architect, hyper-aware of every change and whether it’s the right decision for the system.</p><p>If you’ve been vibe coding through serious work and feeling the friction, that friction is the signal. The next time you start something that has to last, write the spec first.</p><p><a href="https://kiro.dev/"><em>Kiro </em></a><em>is free to start, with an IDE, a CLI, and a web interface. New users get 500 bonus credits for 30 days, eligible students get 1,000 credits per month free for a year, and you can install the CLI with a single command from </em><a href="https://kiro.dev/"><em>kiro.dev</em></a><em>. Try building the same feature twice, once in Vibe mode and once in Spec mode, and compare what you end up with.</em></p><h3>References</h3><ol><li>GitClear, <a href="https://www.gitclear.com/ai_assistant_code_quality_2025_research"><em>AI Copilot Code Quality 2025 Research</em></a> (211M lines, 2020–2024) — copy/paste vs refactoring, duplication, churn data.</li><li>Kiro, <a href="https://kiro.dev/blog/kiro-and-the-future-of-software-development/">“Kiro and the future of AI spec-driven software development”</a> — version-controlled specs as durable artifacts.</li><li>Augment Code, <a href="https://www.augmentcode.com/guides/vibe-coding-vs-spec-driven-development">“Vibe Coding vs Spec-Driven Development (2026)” </a>— GA milestone, 250,000+ preview users, dual-mode design, team/production signals.</li><li>InfoWorld, <a href="https://www.infoworld.com/article/4166817/vibe-coding-or-spec-driven-development-how-to-choose.html">“Vibe coding or spec-driven development? How to choose”</a> — David Yanacek (AWS) on what spec-driven development produces.</li><li>RedMonk, <a href="https://redmonk.com/rstephens/2025/07/31/spec-vs-vibes/">“Spec vs vibes” — vibe coding as speculative development; “yes and”</a> framing.</li><li>Kiro Docs, <a href="https://kiro.dev/docs/chat/vibe/">“Vibe vs Spec sessions” </a>— mode switching and session behavior.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df63b9299820" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fine-Tuning Gemma 2B on PubMedQA: Building a Medical Q&A Assistant with LoRA, Keras Kinetic, and…]]></title>
            <link>https://kuanhoong.medium.com/fine-tuning-gemma-2b-on-pubmedqa-building-a-medical-q-a-assistant-with-lora-keras-kinetic-and-0e6eaf566834?source=rss-fe772cae62e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e6eaf566834</guid>
            <category><![CDATA[gemma2]]></category>
            <category><![CDATA[keras-kinetic]]></category>
            <category><![CDATA[fine-tuning]]></category>
            <category><![CDATA[lora]]></category>
            <category><![CDATA[keras]]></category>
            <dc:creator><![CDATA[Kuan Hoong, Ph.D]]></dc:creator>
            <pubDate>Thu, 02 Apr 2026 21:53:52 GMT</pubDate>
            <atom:updated>2026-04-03T01:17:11.736Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fhcs26wTIz52B9QA6acMxg.png" /></figure><h3>Fine-Tuning Gemma 2B on PubMedQA: Building a Medical Q&amp;A Assistant with LoRA, Keras Kinetic, and Cloud TPU</h3><p><em>How I used a single Python decorator to fine-tune a medical question-answering model on a remote TPU — no Docker, no Kubernetes YAML, just </em><em>@kinetic.run()</em></p><h3>Introduction</h3><p>Fine-tuning large language models typically involves wrestling with cloud infrastructure — setting up VMs, writing Dockerfiles, managing Kubernetes configs, and SSHing into remote machines. What if you could skip all that and launch TPU training with a single Python decorator?</p><p>That’s exactly what I did during the <strong>TPU Sprint</strong>, where I fine-tuned <strong>Google’s Gemma 2B</strong> model on the <strong>PubMedQA</strong> biomedical question-answering dataset using <strong>LoRA</strong> (Low-Rank Adaptation) and <strong>Keras Kinetic</strong> — a new framework from the Keras team that lets you run ML workloads on cloud TPUs and GPUs by simply decorating a Python function. The entire training job ran on a <strong>Cloud TPU v5e-1</strong>, launched from my local machine.</p><p>In this article, I’ll walk through the full workflow: from dataset preparation to remote TPU training to building a local Flask demo app for medical Q&amp;A. The complete code is available on my GitHub repository: <a href="https://github.com/kuanhoong/keras-kinetic">kuanhoong/keras-kinetic</a>.</p><h3>What is Keras Kinetic?</h3><p><a href="https://github.com/keras-team/kinetic">Keras Kinetic</a> is a new open-source tool from the Keras team that removes infrastructure friction from ML training. Instead of provisioning VMs, building containers, and writing deployment manifests, you simply:</p><ol><li>Write a normal Python training function</li><li>Decorate it with @kinetic.run(accelerator=&quot;v5e-1&quot;)</li><li>Call the function — Kinetic handles the rest</li></ol><p>Under the hood, Kinetic packages your function and dependencies, builds a container image (cached after the first run), spins up a GKE cluster with the requested accelerator, executes the job on the remote TPU, and streams logs and results back to your local machine.</p><p>The magic is that your function’s return value is delivered back as if it ran locally. If the remote function raises an exception, it’s re-raised locally with the original traceback. The developer experience feels like running code on your own machine.</p><h3>Why PubMedQA?</h3><p>PubMedQA is a biomedical question-answering dataset built from PubMed abstracts. It was introduced at EMNLP-IJCNLP 2019 and contains three subsets:</p><ul><li><strong>PQA-L (Labeled):</strong> 1,000 expert-annotated QA instances</li><li><strong>PQA-U (Unlabeled):</strong> 61,200 instances without expert labels</li><li><strong>PQA-A (Artificial):</strong> 211,300 artificially generated instances</li></ul><p>Each instance consists of a research question (derived from an article title), the abstract context (excluding the conclusion), the long answer (the conclusion itself), and a yes/no/maybe label. The dataset is designed to test a model’s ability to reason over biomedical research text, including quantitative content like statistical results.</p><p>For this project, I used the pqa_labeled subset and fine-tuned Gemma 2B to generate long-form answers given a question and context — essentially teaching the model to synthesize conclusions from biomedical abstracts.</p><h3>Why LoRA?</h3><p>Fine-tuning all 2 billion parameters of Gemma 2B would be computationally expensive and memory-intensive. LoRA (Low-Rank Adaptation) solves this by freezing the original model weights and injecting small, trainable low-rank matrices into the model’s layers. Instead of updating billions of parameters, LoRA trains only a fraction of them.</p><p>In my configuration, I used a LoRA rank of 4, which means the trainable parameter count drops dramatically while the model still learns domain-specific behavior. The output is a lightweight adapter file (not a full model checkpoint), which makes the workflow practical for both training and deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vvqI2yInDdZXjpGTRuCV7w.png" /></figure><h3>Project Architecture</h3><p>The project is split into two phases:</p><h3>Phase 1: Remote Fine-Tuning on TPU</h3><p>My local machine submits train.py through Keras Kinetic. Kinetic packages the code and dependencies, runs the training job on a remote TPU v5e-1, and the job loads Gemma 2B, applies LoRA, trains on PubMedQA, and saves adapter-only weights to Google Cloud Storage.</p><h3>Phase 2: Local Demo Inference</h3><p>The base Gemma 2B preset is stored locally, the trained LoRA adapter is downloaded as a .lora.h5 file, and a Flask app loads both to serve a simple web UI at <a href="http://127.0.0.1:5000.">http://127.0.0.1:5000.</a></p><pre>Local Machine                          Remote TPU (v5e-1)<br>┌──────────────────┐                  ┌──────────────────────────┐<br>│  python train.py │──── Kinetic ────▶│  Load Gemma 2B preset    │<br>│                  │    packages &amp;    │  Load PubMedQA dataset   │<br>│                  │    submits job   │  Enable LoRA (rank=4)    │<br>│                  │                  │  Train with JAX + DataP. │<br>│                  │◀── results ──────│  Save LoRA adapter → GCS │<br>└──────────────────┘                  └──────────────────────────┘<br>        │<br>        ▼<br>┌──────────────────┐<br>│  download_model  │<br>│  Flask app.py    │<br>│  Serve demo UI   │<br>└──────────────────┘</pre><h3>Step-by-Step Walkthrough</h3><h3>Step 1: Data Preprocessing</h3><p>The data_preprocessing.py script loads the PubMedQA dataset and converts each sample into an instruction-style prompt suitable for causal language model fine-tuning:</p><pre>from datasets import load_dataset</pre><pre>def get_pubmedqa_dataset():<br>    dataset = load_dataset(&quot;pubmed_qa&quot;, &quot;pqa_labeled&quot;, split=&quot;train&quot;)</pre><pre>    def format_example(example):<br>        context_str = &quot; &quot;.join(example[&quot;context&quot;][&quot;contexts&quot;])<br>        question = example[&quot;question&quot;]<br>        answer = example[&quot;long_answer&quot;]</pre><pre>        text = (<br>            f&quot;Instruction: Answer the medical question &quot;<br>            f&quot;based on the context.\n\n&quot;<br>            f&quot;Context: {context_str}\n\n&quot;<br>            f&quot;Question: {question}\n\n&quot;<br>            f&quot;Response: {answer}&quot;<br>        )<br>        return {&quot;text&quot;: text}</pre><pre>    dataset = dataset.map(format_example)<br>    dataset = dataset.train_test_split(test_size=0.1, seed=42)</pre><pre>    train_data = [ex[&quot;text&quot;] for ex in dataset[&quot;train&quot;]]<br>    val_data = [ex[&quot;text&quot;] for ex in dataset[&quot;test&quot;]]</pre><pre>    return train_data, val_data</pre><p>Each sample becomes a structured prompt with instruction, context, question, and response — matching the format that the Flask demo app will use at inference time.</p><h3>Step 2: The Training Script</h3><p>This is where Keras Kinetic shines. The entire training function is a single decorated Python function:</p><pre>import kinetic<br>from data_preprocessing import get_pubmedqa_dataset</pre><pre>@kinetic.run(accelerator=&quot;v5e-1&quot;, capture_env_vars=[&quot;KAGGLE_*&quot;])<br>def train_and_eval():<br>    import os<br>    os.environ[&quot;KERAS_BACKEND&quot;] = &quot;jax&quot;</pre><pre>    import jax<br>    import keras<br>    import keras_hub</pre><pre>    devices = jax.devices()<br>    print(f&quot;Connected to {len(devices)} JAX devices:&quot;, devices)</pre><pre>    # Load base model<br>    gemma_lm = keras_hub.models.GemmaCausalLM.from_preset(<br>        &quot;gemma2_2b_en&quot;<br>    )</pre><pre>    # Enable LoRA<br>    gemma_lm.backbone.enable_lora(rank=4)</pre><pre>    # Load and prepare data<br>    train_data, val_data = get_pubmedqa_dataset()</pre><pre>    # Configure training<br>    gemma_lm.preprocessor.sequence_length = 512<br>    optimizer = keras.optimizers.AdamW(<br>        learning_rate=5e-5, weight_decay=0.01<br>    )<br>    gemma_lm.compile(<br>        loss=keras.losses.SparseCategoricalCrossentropy(<br>            from_logits=True<br>        ),<br>        optimizer=optimizer,<br>        weighted_metrics=[<br>            keras.metrics.SparseCategoricalAccuracy()<br>        ],<br>    )</pre><pre>    # Train<br>    gemma_lm.fit(train_data, epochs=3, batch_size=1)</pre><pre>    # Save LoRA adapter only<br>    gemma_lm.backbone.save_lora_weights(&quot;gemma2_lora.lora.h5&quot;)</pre><pre>    return &quot;Training complete&quot;</pre><pre># Run it — executes remotely on TPU v5e-1<br>result = train_and_eval()</pre><p>A few things to note:</p><ul><li><strong>capture_env_vars=[&quot;KAGGLE_*&quot;]</strong> forwards Kaggle credentials to the remote pod so the model can be downloaded from Kaggle&#39;s model hub.</li><li><strong>All imports happen inside the function</strong> — this avoids local environment mismatches since JAX/TPU dependencies are resolved on the remote machine.</li><li><strong>Only the LoRA adapter is saved</strong>, not a full model checkpoint. This is intentional — the adapter file is small and lightweight, while the base model can be downloaded separately.</li></ul><h3>Step 3: Infrastructure Setup</h3><p>Before running the training, you need to provision the TPU cluster (a one-time setup):</p><pre># Install Keras Kinetic<br>pip install keras-kinetic</pre><pre># Authenticate with GCP<br>gcloud auth application-default login<br>gcloud config set project your-project-id</pre><pre># Provision the TPU cluster<br>kinetic up --accelerator v5e-1 --yes</pre><p>Kinetic handles all the GCP plumbing: enabling required APIs, creating Artifact Registry repos, provisioning GKE clusters, and configuring node pools.</p><h3>Step 4: Launch Training</h3><pre>python train.py</pre><p>The first run takes about 5 minutes because Kinetic builds a container image with your dependencies. Subsequent runs with unchanged dependencies skip the build and start in under a minute — container caching is a killer feature for rapid iteration.</p><h3>Step 5: Tear Down</h3><p>Once training is complete, shut down the TPU resources to avoid charges:</p><pre>kinetic down --yes</pre><p>This is critical — the GKE cluster control plane costs money even when no TPU nodes are active.</p><h3>Step 6: Download and Serve</h3><p>After training, download the model artifacts locally:</p><pre>python download_model.py</pre><p>Then launch the Flask demo app:</p><pre>python app.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pwljQSAu4ydfJFb7wiaamg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pYEwaKJFVPwofePwdg3Fpg.png" /></figure><p>The app loads the base Gemma 2B preset plus the LoRA adapter and serves a medical Q&amp;A interface at http://127.0.0.1:5000. Model loading is deferred until the first question is asked, so the server starts immediately.</p><h3>Training Configuration Summary</h3><p>Parameter Value Base model Gemma 2B Dataset PubMedQA (pqa_labeled) Method LoRA LoRA rank 4 Sequence length 512 Optimizer AdamW Learning rate 5e-5 Weight decay 0.01 Epochs 3 Batch size 1 Accelerator TPU v5e-1</p><h3>Key Takeaways</h3><h3>Keras Kinetic Makes TPUs Feel Local</h3><p>The @kinetic.run() decorator genuinely eliminates infrastructure friction. The mental model is simple: you have a function, you want it to run on a TPU, and Kinetic makes that literal. No Docker, no Kubernetes YAML, no SSH. Write your training code, decorate it, and call it.</p><h3>Container Caching Enables Rapid Iteration</h3><p>The first run pays a build tax, but every subsequent run skips straight to execution. During development, I ran multiple iterations fixing bugs, tweaking data formatting, and adjusting hyperparameters — only the first run waited for a container build. This is what makes Kinetic feel like local development.</p><h3>LoRA Keeps Things Practical</h3><p>With a rank of 4, the trainable parameter count drops from 2 billion to just a few million. The output is a small adapter file, not a multi-gigabyte checkpoint. This makes the entire workflow feasible: fast training on TPU, small artifact to download, and reasonable memory footprint for local inference.</p><h3>PubMedQA Is a Strong Domain Adaptation Benchmark</h3><p>The structured nature of PubMedQA — with its question, context, and long-answer format — maps naturally to an instruction-tuning setup. After fine-tuning, the model learns to synthesize biomedical conclusions from abstract context, demonstrating clear domain adaptation from the general-purpose base model.</p><h3>Adapting This to Your Own Domain</h3><p>The project is designed to be reusable. If you want to adapt it to another domain, the main pieces to swap are:</p><ul><li><strong>Dataset formatting</strong> in data_preprocessing.py — change how you load and format training examples</li><li><strong>Evaluation prompt</strong> in train.py — adjust the test prompt for your domain</li><li><strong>UI copy</strong> in templates/index.html — update the demo interface</li></ul><p>The training loop, Kinetic configuration, and LoRA setup can stay the same.</p><h3>Resources</h3><ul><li><strong>Project repository:</strong> <a href="https://github.com/kuanhoong/keras-kinetic">github.com/kuanhoong/keras-kinetic</a></li><li><strong>Keras Kinetic:</strong> <a href="https://github.com/keras-team/kinetic">github.com/keras-team/kinetic</a></li><li><strong>PubMedQA dataset:</strong> <a href="https://pubmedqa.github.io/">pubmedqa.github.io</a></li><li><strong>Gemma models:</strong> <a href="https://ai.google.dev/gemma">ai.google.dev/gemma</a></li><li><strong>LoRA paper:</strong> Hu et al., “<a href="https://arxiv.org/abs/2106.09685">LoRA: Low-Rank Adaptation of Large Language Models</a>” (2021)</li></ul><h3>Acknowledgement</h3><ul><li><strong>Google Cloud credits are provided for this project. </strong>#TPUSprint.</li><li>Special thanks to the Keras team for building Kinetic — it genuinely changes the developer experience for TPU training.</li><li>The author uses generative AI as a writing assistance for this article.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e6eaf566834" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Science Simulator Hub with Google AI Studio, Google Antigravity and Gemini 3]]></title>
            <link>https://kuanhoong.medium.com/building-a-science-simulator-hub-with-google-ai-studio-google-antigravity-and-gemini-3-4e5a3b43b7eb?source=rss-fe772cae62e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e5a3b43b7eb</guid>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[google-antigravity]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[google-ai-studio]]></category>
            <dc:creator><![CDATA[Kuan Hoong, Ph.D]]></dc:creator>
            <pubDate>Thu, 18 Dec 2025 01:09:14 GMT</pubDate>
            <atom:updated>2025-12-18T01:41:13.850Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7B8eBzYQnTfDARDkWyL6Ew.png" /></figure><p><em>Making physics, sound, and systems thinking interactive for students</em></p><p>What if students could <em>feel</em> gravity, <em>see</em> sound, and <em>play</em> with complex systems instead of just reading about them?</p><p>That curiosity led me to build the <strong>Science Simulator Suite</strong> — a collection of interactive, browser-based simulators designed to help students experience scientific concepts through direct interaction. The goal was simple: make learning <strong>playful, visual, and intuitive</strong>, while showcasing how fast and accessible modern app development can be using <strong>vibe coding with </strong><a href="https://aistudio.google.com/"><strong>Google AI Studio</strong></a><strong>, </strong><a href="https://antigravity.google/"><strong>Google Antigravity </strong></a><strong>and </strong><a href="https://aistudio.google.com/models/gemini-3"><strong>Gemini 3</strong></a>.</p><p>👉 GitHub: <a href="https://www.github.com/kuanhoong/science-simulator">https://www.github.com/kuanhoong/science-simulator</a></p><h3>🌌 What is the Science Simulator Hub?</h3><p>The Science Simulator Hub is a set of three interactive simulations that run directly in the browser. Each simulator focuses on a different scientific or systems concept and encourages exploration through <strong>natural inputs</strong> like hand gestures, sound, and real-time interaction.</p><p>This project is also a personal experiment:</p><blockquote>How far can we go by combining creative intent with AI-assisted development tools?</blockquote><p>The answer: surprisingly far — and surprisingly fast.</p><h3>🪐 1. Solar System Simulator</h3><p><strong>Control planetary motion with hand gestures</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qLQ0DPxDUE_Db05koh6xiA.png" /></figure><p>The <strong>Solar System Simulator</strong> lets users explore orbital motion in a playful way. Instead of using a mouse or keyboard, users control the movement of planets around the sun using <strong>webcam-based hand gestures</strong>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FDlRK0zFj904%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DDlRK0zFj904&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FDlRK0zFj904%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6abbeeb84859c1cab36fa7335bd25068/href">https://medium.com/media/6abbeeb84859c1cab36fa7335bd25068/href</a></iframe><h3>What students experience:</h3><ul><li>How planets orbit around a central body</li><li>The relationship between distance, speed, and motion</li><li>Cause-and-effect through direct physical movement</li></ul><p>By moving their hands closer, farther, or faster, users influence planetary behavior in real time. This turns abstract gravitational concepts into something <strong>felt</strong>, not just observed.</p><p>💡 <em>Why it matters:</em><br> Embodied interaction helps students intuitively understand motion and dynamics, especially those who learn best by doing.</p><h3>🔊 2. Sound Particle Playground</h3><p><strong>Visualizing sound as motion</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h22GSRF3ODExc1cn4Bcxyw.png" /></figure><p>The <strong>Sound Particle Playground</strong> transforms sound into movement. Using the device’s microphone, users can speak, clap, or play music and watch particles respond dynamically to <strong>volume, frequency, and rhythm</strong>.</p><h3>What students experience:</h3><ul><li>Sound as a physical phenomenon</li><li>How amplitude and pitch affect energy and motion</li><li>The connection between audio signals and visual patterns</li></ul><p>Loud sounds create bursts of motion. Softer tones produce gentle waves. The result is a living visualization of sound energy in action.</p><p>💡 <em>Why it matters:</em><br> Sound is invisible — until you make it visible. This simulator bridges physics, art, and creativity in a way that instantly clicks.</p><h3>🏙️ 3. React 3D City Simulator</h3><p><strong>A SimCity-style experience in the browser</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RqqdX97fZFt3KG3eJi2k3Q.png" /></figure><p>The <strong>React 3D City Simulator</strong> is inspired by classic city-building games. Users can explore a 3D city environment directly in the browser and interact with elements of a simplified simulation.</p><h3>What students experience:</h3><ul><li>Systems thinking and interdependencies</li><li>How small decisions can affect larger outcomes</li><li>Spatial reasoning in a 3D environment</li></ul><p>While playful on the surface, this simulator introduces foundational ideas behind urban planning, simulations, and emergent behavior.</p><p>💡 <em>Why it matters:</em><br> Simulation games are powerful learning tools — they encourage experimentation, curiosity, and critical thinking.</p><h3>🚀 Built with Vibe Coding, Google AI Studio, Google Antigravity &amp; Gemini 3</h3><p>What made this project especially exciting was <em>how</em> it was built.</p><p>Using <a href="https://aistudio.google.com/"><strong>Google AI Studio</strong></a> and <a href="https://antigravity.google/"><strong>Google Antigravity</strong></a>, I leaned into <strong>vibe coding</strong> — focusing on intent, interaction, and creativity rather than boilerplate code. AI handled much of the scaffolding, iteration, and refinement, allowing me to move quickly from idea → prototype → working simulator.</p><h3>🤖 Google AI Studio — Build Apps Entirely in the Browser</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BS1-ayeTn78G9OJYHWe3-g.png" /></figure><p>One of the key enablers behind this project is <a href="https://aistudio.google.com/"><strong>Google AI Studio</strong>,</a> which comes with powerful <a href="https://aistudio.google.com/apps"><strong>Build features</strong></a> that allow developers to design, prototype, and build entire applications <strong>directly in the browser</strong>.</p><p>With Google AI Studio, you can:</p><ul><li>Build and iterate on full applications online without local setup</li><li>Describe intent and functionality, then refine through natural language</li><li>Rapidly prototype interactive experiences with AI-assisted coding</li><li>Test ideas instantly and evolve them in real time</li></ul><p>For the Science Simulator Hubthis meant focusing more on <strong>interaction design, learning experience, and creativity</strong>, while letting AI handle much of the repetitive and structural work. It significantly lowers the barrier to building complex apps and makes experimentation fast, fluid, and fun.</p><p>💡 <em>In short:</em> Google AI Studio turns app building into a conversational, creative process — perfect for vibe coding and educational experimentation.</p><h3>🌐 Google Antigravity — A New Vibe Coding IDE</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wBWbpmrgDtbj-QCflRS4tg.png" /></figure><p><a href="https://antigravity.google/"><strong>Google Antigravity</strong> </a>is a new vibe coding IDE that complements Google AI Studio by turning ideas into cohesive, shippable experiences. While the simulators themselves were built in Google AI Studio, <strong>Antigravity was used to build a launcher application</strong> that brings all three simulators together in a single, unified entry point.</p><p>With Google Antigravity, I was able to:</p><ul><li>Rapidly scaffold a clean launcher interface</li><li>Connect and orchestrate multiple simulator apps built in Google AI Studio</li><li>Iterate quickly using AI-assisted coding and natural language prompts</li><li>Focus on flow, usability, and experience rather than setup and wiring</li></ul><p>The launcher acts as the “home screen” for the Science Simulator Suite, allowing users to seamlessly jump between the Solar System Simulator, Sound Particle Playground, and React 3D City Simulator.</p><p>💡 <em>Why it matters:</em></p><p>Antigravity makes it easy to move from isolated demos to a complete product. Combined with Google AI Studio, it enables an end-to-end vibe coding workflow — from individual experiments to a polished, integrated experience.</p><p>This project is a showcase of:</p><ul><li>How accessible interactive 3D and simulation apps have become</li><li>How AI can accelerate creative development</li><li>How educators and developers can prototype learning tools rapidly</li></ul><h3>🎓 Why This Matters for Education</h3><p>The Science Simulator Suite isn’t just a demo — it’s a statement.</p><ul><li>Learning doesn’t have to be passive</li><li>Science doesn’t have to be abstract</li><li>Building educational tools doesn’t have to be complex</li></ul><p>With modern web technologies and AI-assisted development, <strong>anyone can build interactive learning experiences</strong> that inspire curiosity and experimentation.</p><h3>🛠️ Tech Stack Behind the Simulators</h3><p>The entire <strong>Science Simulator Hub</strong>is built using a minimal but powerful tech stack, keeping performance high while allowing rapid experimentation through vibe coding.</p><h3>Core Technologies</h3><ul><li><a href="https://www.typescriptlang.org/"><strong>TypeScript</strong></a><br>Used across all simulators for type safety, better maintainability, and a smoother development experience when working with complex interactions and state.</li><li><a href="https://threejs.org/"><strong>Three.js</strong></a><br>Powers all 3D rendering, particle systems, planetary motion, and real-time visual effects. <a href="https://threejs.org/">Three.js </a>makes it possible to run rich, interactive 3D simulations directly in the browser without external plugins.</li></ul><h3>Why this stack?</h3><p>TypeScript + Three.js strikes a great balance between <strong>developer productivity and visual expressiveness</strong>. Combined with AI-assisted development via <strong>Google AI Studio</strong> and <strong>Google Antigravity</strong>, it enables fast prototyping of educational simulations that would traditionally take much longer to build.</p><h3>🔗 Explore the Project</h3><p>If you’re curious to explore, remix, or extend the simulators:</p><p>👉 <strong>GitHub:</strong> <a href="https://www.github.com/kuanhoong/science-simulator">https://www.github.com/kuanhoong/science-simulator</a></p><p>I hope this inspires educators, students, and developers to experiment with simulations, interaction, and vibe coding — and to rethink how we experience science in the browser.</p><p>Happy building 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e5a3b43b7eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connect to Google Colab Server in VS Code IDE with Colab Extension]]></title>
            <link>https://kuanhoong.medium.com/connect-to-google-colab-server-in-vs-code-ide-with-colab-extension-024e552442ef?source=rss-fe772cae62e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/024e552442ef</guid>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[google-colab]]></category>
            <category><![CDATA[vscode-extension]]></category>
            <dc:creator><![CDATA[Kuan Hoong, Ph.D]]></dc:creator>
            <pubDate>Fri, 14 Nov 2025 00:01:19 GMT</pubDate>
            <atom:updated>2025-11-14T00:01:19.201Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aQlEdwEDQbn1cEjqvO6qhQ.jpeg" /></figure><p>If you’re in the world of data science, machine learning or AI engineering then you’ve likely used one or more of the following workflows:</p><ul><li>A cloud notebook environment such as Colab for rapid experimentation.</li><li>A full-fledged IDE such as Visual Studio Code (VS Code) for development, debugging, version control and production-grade code.</li></ul><p>What if you could bring the best of both into one workflow? That’s precisely what the <a href="https://marketplace.visualstudio.com/items?itemName=Google.colab">Colab VS Code Extension</a> lets you do. In this post, I’ll walk through what it is, why it matters (especially for you as a data/AI engineer &amp; community-leader), how you can get started, pros/cons, and real-world use-cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4-x4k8X9TGepQe7AtVI7ow.gif" /></figure><h3>What Is It?</h3><p>The VS Extension is named simply “Colab” in the VS Code Marketplace. Here are the key details:</p><ul><li>Developer: Google</li><li>Description: “Connect notebooks to Colab servers.”</li><li>It builds on the existing Jupyter extension in VS Code and “exposes Colab servers directly in VS Code!”</li></ul><h3>How to get started</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*JrvqKCTgRKQkPo9w7GQY2Q.png" /></figure><p><strong>Quick start steps:</strong></p><ol><li>Install <a href="https://code.visualstudio.com/">VS Code</a></li><li>Install the <a href="https://marketplace.visualstudio.com/items?itemName=Google.colab">Colab extension</a> (and <a href="https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter">Jupyter extension</a> if you don’t already have it)</li><li>Open or create a notebook file</li><li>When prompted, sign in</li><li>Click <em>Select Kernel → Colab → New Colab Server</em></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*v7nTJrL2usLrGiq-YSiNJg.png" /></figure><p>With Colab extension, you remain in the VS Code UI (with all your favourite editor features: source control, extensions, rich code editing) but underneath you can connect to a Colab-hosted runtime (with its cloud compute, GPUs/TPUs etc).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LDfqYUtIq4j3hT52YmNoOQ.png" /></figure><h3>Why This Matters</h3><p>As someone deeply embedded in AI/ML, tooling, community evangelism and giving workshops, talks, etc. With this workflow unlocks some meaningful value:</p><p><strong>✅ Improved Productivity &amp; Comfort</strong></p><ul><li>You get the comfort of a full-featured editor (VS Code) rather than browser-only notebook UI. This means better keyboard shortcuts, integrated version control, search across files, multi-file views (not just isolated notebook cells).</li><li>For a data engineering/AI lead, you often juggle “exploratory notebook + production code + pipelines”. With this extension, it helps to unify that.</li></ul><p><strong>✅ Access to Cloud Compute</strong></p><ul><li><a href="https://colab.google.com/">Colab </a>already gives free access to GPUs/TPUs and a zero-install environment.</li><li>With the extension, you don’t have to switch contexts: You stay in VS Code and still leverage Colab’s server.</li></ul><p><strong>✅ Better Hybrid Workflows</strong></p><ul><li>Because you’re often organising meetups, training people, you might want to show how to go from “prototype in a notebook” → “production in codebase” seamlessly. This extension can be a teaching op.</li><li>You might have a local dev environment but want GPU/TPU for heavy tasks. With this tool, it lets you easily spin up a remote kernel without leaving VS Code.</li></ul><p><strong>✅ Leveraging Existing Skills &amp; Community Tools</strong></p><ul><li>Since you’re already familiar with VS Code and likely teaching others, this lowers the barrier for your audience: they don’t need to learn a new UI just for Colab; they can stay in the VS Code environment they already know.</li><li>Also helpful for community workshops: “Bring your VS Code, hit the notebook, run on Colab kernel” — easier to standardise.</li></ul><h3>Pros &amp; Cons</h3><p>As with any tool, there are trade-offs. Here’s a balanced view.</p><h3>👍 Pros</h3><ul><li>Blend of familiar editor (VS Code) + cloud runtime (Colab) = less context-switching.</li><li>Access to GPUs/TPUs via Colab, even though you are in VS Code.</li><li>Good for collaborative settings: you can share notebook files, version control, integrate into dev workflows.</li><li>Educational/Workshop-friendly: lowers entry barrier for users comfortable with VS Code.</li><li>No local heavy hardware requirement for GPU-based experimentation.</li></ul><h3>👎 Cons / Considerations</h3><ul><li>Colab sessions are still subject to Colab’s policies: session timeouts, resource limits, possible interruptions. (A general limitation of Colab).</li><li>You may not have full control of the runtime environment (as you would locally or in a dedicated cloud VM) such dependency management, environment consistency may be more complex.</li><li>If you have a heavy production workload, eventually you may outgrow this workflow (you’d want dedicated infra, containers, pipeline orchestration).</li><li>Network latency / remote kernel overhead: since the backend is remote, you might encounter delays vs purely local code.</li><li>It’s <em>another</em> tool to teach/manage in your community. You’ll want to ensure participants understand underlying concepts (what is a remote kernel vs local kernel).</li><li>Because the extension is relatively new (at time of writing) and still niche compared to core VS Code &amp; Jupyter workflows, you might hit edge-cases or smaller community support.</li></ul><h3>Final Thoughts &amp; Recommendation</h3><p>Just like any other tools out there, it matters as it is not just for your personal workflow, but for how you can run and scale to others. The “Colab VS Code Extension” is a smart addition to your toolbox:</p><ul><li>It gives you flexibility: Dev environment + remote compute.</li><li>It helps you teach more effectively: one environment (VS Code) that many already know, with the magic of Colab’s compute behind the scenes.</li><li>It supports mobility: no heavy local hardware required.</li><li>It scales: from prototyping to serving as stepping-stone to production pipelines.</li></ul><p>Happy coding!</p><p><em>Install the Colab extension from either the </em><a href="https://marketplace.visualstudio.com/items?itemName=google.colab"><em>Visual Studio Marketplace</em></a><em> or </em><a href="https://open-vsx.org/extension/Google/colab"><em>Open VSX</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=024e552442ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gemini for Productivity: How Google’s AI is Changing the Way We Work]]></title>
            <link>https://kuanhoong.medium.com/gemini-for-productivity-how-googles-ai-is-changing-the-way-we-work-cef2ec573b80?source=rss-fe772cae62e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/cef2ec573b80</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Kuan Hoong, Ph.D]]></dc:creator>
            <pubDate>Mon, 23 Jun 2025 06:17:41 GMT</pubDate>
            <atom:updated>2025-06-23T06:17:41.778Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SmW63yb4KiLlvAeip8v0EQ.png" /></figure><p>In today’s hyperconnected world, productivity isn’t just about working harder — it’s about working smarter. With an overwhelming flood of emails, documents, meetings, and tasks, staying focused and efficient often feels like chasing a moving target. This is where <a href="https://gemini.google.com/"><strong>Gemini</strong></a>, Google’s advanced generative AI assistant, is making waves.</p><p>Current latest model is the <strong>Gemini 2.5. It is a thinking model</strong>, designed to tackle increasingly complex problems. The first release in this line — <strong>Gemini 2.5 Pro Experimental</strong> — leads common <a href="https://lmarena.ai/leaderboard">AI benchmarks</a> by meaningful margins and showcases strong reasoning and coding capabilities. This evolution marks a shift from basic task automation to deep analytical thinking, enabling Gemini to support more sophisticated decision-making and problem-solving scenarios at work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0LXIoR6LIXiZ4wPr1LmFYA.png" /><figcaption>LMArena Leaderboard</figcaption></figure><p>Gemini 2.5 Pro is available now in <a href="http://aistudio.google.com/app/prompts/new_chat?model=gemini-2.5-pro-exp-03-25">Google AI Studio</a> and in the <a href="https://gemini.google.com/">Gemini app</a> for Gemini Advanced users, and <a href="https://console.cloud.google.com/freetrial?redirectPath=/vertex-ai/studio">Vertex AI</a> soon.</p><p>Built directly into <a href="https://workspace.google.com/intl/en_my/">Google Workspace</a> tools like Gmail, Docs, Sheets, and Slides, Gemini empowers users to cut through digital clutter and focus on what really matters. Whether you’re a knowledge worker, student, project manager, or executive, Gemini offers a fresh way to automate the mundane and accelerate the meaningful.</p><h3>🧠 What is Gemini?</h3><p>Gemini is Google’s latest family of generative AI models, designed to be multimodal (capable of understanding text, images, and more) and deeply integrated into productivity workflows. Available via the Google Workspace side panel, Gemini serves as a smart assistant that can:</p><ul><li>Draft and summarize content</li><li>Analyze data in spreadsheets</li><li>Brainstorm ideas</li><li>Create visuals and presentations</li><li>Answer questions in natural language</li></ul><p>Unlike standalone tools, Gemini lives where your work happens — within your documents, emails, and files — making it both accessible and context-aware.</p><h3>🔧 Introducing the Gemini Side Panel</h3><p>One of the most powerful ways Gemini integrates into your workflow is through the <strong>Workspace Side Panel</strong>. Google’s official support explains:</p><blockquote><em>“With the side panel, Gemini can assist you with summarizing, analyzing, and generating content using insights gathered from your email messages, documents, and more — all without switching applications or tabs.”</em></blockquote><h3>✅ What you can do in the side panel:</h3><ul><li><strong>Gmail</strong>: Summarize threads, highlight action items, and draft responses.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3aXSn_XP2BgOI7GF45zHCQ.gif" /></figure><ul><li><strong>Docs</strong>: Generate or refine text based on document context.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RPgU8O4JUZcWb-QePwW8uw.gif" /></figure><ul><li><strong>Sheets</strong>: Summarize data, build pivot tables, and craft formulas via prompts like “Ask Gemini”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7rZ-pQ9a1e45Bz3h-K-0pw.gif" /></figure><ul><li><strong>Slides</strong>: Generate new slides, images, and summaries.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RpuMtv2Orya_50VuhdbwSg.gif" /></figure><ul><li><strong>Drive &amp; Chat</strong>: Search, summarize, and ask questions about files without leaving your workspace.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c6kxTAQylpFeLuJA1cMWYw.gif" /></figure><h3>🔍 Introducing Gemini Deep Research</h3><p>The latest standout feature within Gemini Advanced and Gemini 2.5 Pro is <a href="https://gemini.google/overview/deep-research/?hl=en"><strong>Deep Research</strong></a> — an AI-powered assistant designed for complex research tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*94EAG9CbPTloXgFP9I5u4g.gif" /></figure><h3>How Deep Research works:</h3><ol><li><strong>Planning</strong>: It transforms your prompt into a structured, multi-point research plan.</li><li><strong>Searching</strong>: It autonomously explores the web, gathering relevant and up-to-date information.</li><li><strong>Reasoning</strong>: The model thinks through the data it finds, showing its step-by-step reasoning.</li><li><strong>Reporting</strong>: Within minutes, Deep Research generates a detailed report, complete with source links, optional audio summaries, and export options to Docs or Canvas.</li></ol><h3>Use Case Examples:</h3><ul><li>Conducting <strong>competitive analysis</strong></li><li>Performing <strong>due diligence</strong></li><li>Building <strong>topic deep dives</strong></li><li>Comparing products in-depth</li></ul><p>This transforms Gemini from a task helper into a collaborative research partner — saving you hours of clicking and reading.</p><h3>🎨 Introducing Gemini Canvas</h3><p><a href="https://gemini.google/overview/canvas/?hl=en"><strong>Canvas</strong></a> is a powerful new creative space within Gemini, built on Gemini 2.5 Pro:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*LfM_DtKG0LgWp19H0xIO6A.gif" /></figure><ul><li>🛠️ <strong>Write and iterate</strong>: Generate drafts, adjust tone, length, and structure with quick edits, then export to Google Docs</li><li>💻 <strong>Code with confidence</strong>: Write HTML, React, Python, game prototypes — or debug — while previewing outputs live within Canvas</li><li>📊 <strong>Visualize and share</strong>: Transform Deep Research outputs into infographics, interactive apps, quizzes, and audio overviews — all within Canvas. Generate unique content using Canvas’s “Create”</li></ul><h3>🎯 Final Thoughts</h3><p>Gemini is more than just an AI tool — it’s a partner for modern productivity. By offloading routine tasks and surfacing insights quickly, it lets us focus on higher-value work: decision-making, collaboration, and creativity.</p><p>As generative AI continues to evolve, tools like Gemini will only get smarter. And with the latest advancements in the Gemini 2.5 model, we’re entering a new phase — where your AI assistant doesn’t just help you work faster, but actually thinks alongside you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cef2ec573b80" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use Gemini to Generate Flowcharts with Mermaid and Visualize Them in draw.io]]></title>
            <link>https://kuanhoong.medium.com/how-to-use-gemini-to-generate-flowcharts-with-mermaid-and-visualize-them-in-draw-io-79b9b662510d?source=rss-fe772cae62e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/79b9b662510d</guid>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[mermaidjs]]></category>
            <category><![CDATA[promptings]]></category>
            <category><![CDATA[flowchart]]></category>
            <dc:creator><![CDATA[Kuan Hoong, Ph.D]]></dc:creator>
            <pubDate>Thu, 08 May 2025 05:12:03 GMT</pubDate>
            <atom:updated>2025-05-08T05:19:17.013Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y9EEdQyKq50dso1xiswwUg.jpeg" /><figcaption><a href="https://pixabay.com/photos/laptop-hands-planning-office-2745979/">Pixabay</a></figcaption></figure><p>Creating flowcharts can be tedious — especially when you’re brainstorming or documenting workflows. Luckily, with tools like <a href="https://gemini.google.com/">Google Gemini</a>, <a href="https://mermaid.js.org/">Mermaid.js</a>, and <a href="https://app.diagrams.net/">draw.io</a>, you can go from idea to diagram in minutes using just natural language.</p><p>In this post, I’ll walk you through how to prompt Gemini to generate a flowchart in Mermaid syntax, and how to paste that code into draw.io for easy visualization and editing.</p><p>Mermaid is a syntax similar to Markdown where you can use text to describe and automatically generate diagrams. With Mermaid’s Markdown-inspired syntax, you can generate flow charts, UML diagrams, pie charts, Gantt charts, and more.</p><h3>🔧 Tools You’ll Need</h3><ul><li><strong>Google Gemini</strong> (or any LLM that supports Mermaid code generation)</li><li><strong>Mermaid.js</strong> syntax (we’ll generate it automatically)</li><li><strong>draw.io</strong> (aka <a href="https://draw.io/">diagrams.net</a>) for visualization</li></ul><h3>🚀 Step 1: Prompt Gemini to Generate Mermaid Code</h3><p>The key is giving Gemini a clear, structured prompt that describes your flow. Here’s a sample prompt you can use:</p><blockquote><strong><em>Prompt</em></strong><em>:<br> “Create a flowchart that shows the process of onboarding a new employee. Start with ‘Receive application’, then ‘Screen application’, then a decision point ‘Is qualified?’. If yes, move to ‘Interview’, then ‘Offer job’, then ‘Onboard employee’. If not qualified, move to ‘Send rejection email’. Output the result in Mermaid.js flowchart syntax.”</em></blockquote><p>You’ll receive something like:</p><pre>graph TD<br>    A[Receive application] --&gt; B[Screen application]<br>    B --&gt; C{Is qualified?}<br>    C -- Yes --&gt; D[Interview]<br>    D --&gt; E[Offer job]<br>    E --&gt; F[Onboard employee]<br>    C -- No --&gt; G[Send rejection email]</pre><p>Feel free to adjust the prompt to your specific process — Gemini is great at translating natural language into diagram logic.</p><h3>🎨 Step 2: Paste Mermaid Code into draw.io</h3><p>draw.io doesn’t natively support Mermaid from the main UI, but there’s a trick.</p><h3>Insert Mermaid code into draw.io</h3><ol><li>Go to <a href="https://draw.io/">https://draw.io</a></li><li>Click <strong>“Create New Diagram”</strong> or open an existing one.</li><li>Once enabled, click <strong>Arrange → Insert → Advanced → Mermaid</strong>.</li><li>Paste your Mermaid code and click <strong>Insert</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*yZZ_1hbc-64Hqi_HiPyuSA.png" /><figcaption>Insert the Mermaid code into draw.io</figcaption></figure><p>You’ll see your diagram rendered directly in draw.io, where you can edit and style it as needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v7I9eFj7uWGj1cKjS7kxLA.png" /><figcaption>Flow chart created in draw.io using Mermaid code</figcaption></figure><h3>✏️ Edit the Mermaid code in draw.io</h3><p>To see the Mermaid code for any of the diagrams inserted in this way, select the shape, then press Enter. You can make changes to the code here, then click Apply to update the diagram on the drawing canvas.</p><h3>🧠 Bonus: Tips for Better Mermaid Prompts</h3><ul><li>Use clear node labels in your prompt.</li><li>Use decision points (like Is approved?) with branching logic.</li><li>Ask Gemini to add styling or icons, though keep it simple — Mermaid is mainly for structure.</li><li>If things get complex, ask Gemini to <strong>split the chart into sections</strong> or use <strong>subgraphs</strong>.</li></ul><p>Example of a more advanced request:</p><blockquote><em>“Create a Mermaid flowchart with a subgraph for ‘Hiring Process’ and another for ‘Post-Hiring Process’. Show transitions between them.”</em></blockquote><h3>✅ Wrap-Up</h3><p>With Gemini and Mermaid.js, you can automate the most tedious part of flowchart creation. Just describe your process, let Gemini write the code, and plug it into draw.io to bring it to life.</p><p>This combo is perfect for:</p><ul><li>Workflow documentation</li><li>Technical diagrams</li><li>Planning &amp; brainstorming</li><li>Fast prototyping</li></ul><p>Try it once, and you may never manually drag shapes again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79b9b662510d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying DeepSeek-R1 Models on AWS: A Game Changer for Generative AI]]></title>
            <link>https://kuanhoong.medium.com/deploying-deepseek-r1-models-on-aws-a-game-changer-for-generative-ai-8583508d43e3?source=rss-fe772cae62e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8583508d43e3</guid>
            <dc:creator><![CDATA[Kuan Hoong, Ph.D]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 05:02:40 GMT</pubDate>
            <atom:updated>2025-02-03T05:02:40.673Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*nAfsbyR5lvZlDNNc" /></figure><p>In the fast-paced world of generative AI, the ability to efficiently deploy and scale AI models is critical for businesses and developers looking to stay ahead. AWS has now made it easier than ever to deploy the latest <a href="https://api-docs.deepseek.com/news/news250120">DeepSeek-R1</a> models through Amazon Bedrock and Amazon SageMaker AI, providing flexibility for a variety of use cases. Whether you are looking for quick integrations or deeper model customizations, AWS offers the tools you need to innovate securely and cost-effectively.</p><h3>Choosing the Right Deployment Option</h3><p>AWS provides multiple pathways for deploying DeepSeek-R1 models, each catering to different needs:</p><ul><li><a href="https://aws.amazon.com/bedrock/"><strong>Amazon Bedrock</strong></a>: Best suited for teams seeking a managed API-based approach to integrating pre-trained foundation models into their applications without worrying about infrastructure management.</li><li><a href="https://aws.amazon.com/sagemaker-ai/"><strong>Amazon SageMaker AI</strong></a>: Ideal for organizations requiring more control over model training, fine-tuning, and deployment. This option provides access to underlying infrastructure for optimized performance and customization.</li><li><strong>Amazon EC2 with </strong><a href="https://aws.amazon.com/ai/machine-learning/trainium/"><strong>AWS Trainium</strong></a><strong> and </strong><a href="https://aws.amazon.com/ai/machine-learning/inferentia/"><strong>AWS Inferentia</strong></a>: If cost efficiency is a priority, you can leverage these AWS chips to deploy DeepSeek-R1-Distill models effectively, balancing performance and affordability.</li></ul><p>Watch a demo video for importing the model and inference in the Bedrock playground.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F1aq_ju70qHQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D1aq_ju70qHQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F1aq_ju70qHQ%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7855cec75c525eff1cbbeba3439780e1/href">https://medium.com/media/7855cec75c525eff1cbbeba3439780e1/href</a></iframe><p>Since the release of DeepSeek-R1, various guides of its deployment for Amazon EC2 and <a href="https://aws.amazon.com/eks/">Amazon Elastic Kubernetes Service (Amazon EKS)</a> have been posted. Here is some additional material for you to check out:</p><ul><li><a href="https://community.aws/content/2Z6DlAohx12yuNoEAs7qb5YTH0q/leveraging-deepseek-r1-on-aws">Leveraging DeepSeek-R1 with CPU and GPU options on AWS </a>by <a href="https://community.aws/@wirjo">Daniel Wirjo</a></li><li><a href="https://community.aws/content/2sHGS4Eqeekz32OOzn7am5lnGEX/benefits-of-installing-deepseek-on-an-aws-ec2-instance">Benefits of installing DeepSeek on an Amazon EC2 instance</a> by <a href="https://community.aws/@kikitos">Enrique Aguilar Martinez</a></li><li><a href="https://community.aws/content/2sKnCT05v1WiD0Dw8QB5wfAf1Cm/deploying-deepseek-llama-model-on-amazon-ec2-inferentia-instance">Deploying DeepSeek Llama models on Amazon EC2 inferentia instance</a> by <a href="https://community.aws/@irshadc">Irshad Chohan</a></li><li><a href="https://huggingface.co/blog/deepseek-r1-aws">How to deploy and fine-tune DeepSeek models on AWS</a> by <a href="https://huggingface.co/">Hugging Face</a></li><li><a href="https://community.aws/content/2sJofoAecl6jVdDwVqglbZwKz2E/hosting-deepseek-r1-on-amazon-eks">Hosting DeepSeek-R1 on Amazon EKS Auto Mode</a> by <a href="https://community.aws/@tiagoreichert">Tiago Reichert</a></li></ul><h3>Final Thoughts</h3><p>The availability of DeepSeek-R1 models on AWS marks a significant milestone in the accessibility and scalability of generative AI. Whether you’re a startup looking to experiment with AI-driven solutions or an enterprise seeking a robust AI infrastructure, AWS provides the flexibility and security needed to drive innovation.</p><p>As an AWS Community Builder and AI enthusiast, I’m excited to see how developers and businesses leverage these new capabilities to push the boundaries of AI-driven applications. Let’s build responsibly and innovate together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8583508d43e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>