<?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 W Gong on Medium]]></title>
        <description><![CDATA[Stories by W Gong on Medium]]></description>
        <link>https://medium.com/@wen.g.gong?source=rss-7b5395ada3ec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*i_bPwf5oZMOT0mJm.</url>
            <title>Stories by W Gong on Medium</title>
            <link>https://medium.com/@wen.g.gong?source=rss-7b5395ada3ec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 03:36:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wen.g.gong/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[Compression is Understanding]]></title>
            <link>https://medium.com/@wen.g.gong/compression-is-understanding-409b9a7d6779?source=rss-7b5395ada3ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/409b9a7d6779</guid>
            <category><![CDATA[linguistics]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[physics]]></category>
            <category><![CDATA[compression]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[W Gong]]></dc:creator>
            <pubDate>Sun, 05 Jul 2026 20:27:54 GMT</pubDate>
            <atom:updated>2026-07-05T20:45:00.608Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R6JV-A9R98L1owdKYxjjfg.png" /></figure><h3>A cow, a lute, and a lossy encoder</h3><p>There is a Chinese idiom, 对牛弹琴 — “playing the lute to a cow.” Four characters. On the surface it is an absurd little scene: a musician performs; the cow chews on, unmoved. Underneath, it compresses an entire category of human experience — wasted eloquence on an audience that cannot receive it — into four syllables that have survived roughly two thousand years of retelling without version control, checksums, or a single backup server.</p><p>Nobody designed this. No committee optimized the encoding. The idiom survived because it compresses well: a vivid scene, a fixed four-beat rhythm, an internal 2+2 parallelism that resists corruption in oral transmission. Units of language that compress meaning tightly <em>and</em> carry their own retrieval cue — rhyme, rhythm, a funny picture — are the ones that outlive the generations that spoke them. Natural language has been running an evolutionary compression contest for millennia, and idioms are its hall of fame.</p><p>Hold that thought. We’ll need it when we get to the trillion parameters.</p><h3>The ladder</h3><p>Chinese makes the mechanism unusually visible, because the compression operates at every scale and leaves fossils at each rung:</p><pre>scene → pictograph → character → idiom → verse/poem → equation</pre><ul><li><strong>Scene → pictograph.</strong> The bronze-age form of 漢 (hàn, as in 汉字, Chinese characters) is a picture: a hand reaching into a river toward a fish. A lived moment, compressed into strokes.</li><li><strong>Pictograph → character.</strong> Radicals and phonetic components snap together like bricks. 湖 (lake), 海 (sea), and 漢 all share the water radical 氵- the compression scheme is compositional, and it shows its work.</li><li><strong>Character → idiom.</strong> Four characters encode a whole story with a moral: 井底之蛙, “the frog at the bottom of the well,” is a complete parable about narrow-mindedness in the space of a PIN code.</li><li><strong>Idiom → verse.</strong> Buddhist 偈 (gāthā) stanzas used fixed meter and parallel lines so teachings could survive centuries of purely oral relay. The rhythm is a memory container; the meaning is the cargo. Poems work the same way — rhyme is not decoration, it is error-correction.</li><li><strong>Verse → equation.</strong> And at the top of the ladder, the compression champion of all human activity: physics.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*dtEyl__ZSlN_I8cJhv3p4A.png" /></figure><p>Each rung trades surface detail for reach. And each rung was climbed by human brains doing something no one had named yet.</p><h3>The top rung, and the scoreboard</h3><p>Gregory Chaitin, one of the founders of algorithmic information theory, put the whole idea in three words: <strong>comprehension is compression</strong>. A theory is exactly as good as it is shorter than the data it explains. The formal version is Kolmogorov complexity — the best explanation of a dataset is its shortest program. (Marcus Hutter took it seriously enough to fund a long-running prize that treats compressing Wikipedia as a proxy for intelligence itself; Jürgen Schmidhuber has argued for decades that discovery <em>is</em> finding shorter descriptions.)</p><p>By that scoreboard, look at what physics has done: F = ma, in twenty bytes, covers every trajectory of every projectile, planet, and pendulum that has ever moved. Maxwell’s four lines cover every radio wave, every color, every reflection in every mirror. E = mc², Schrödinger’s equation, Dirac’s equation — each a line or less, each covering an unbounded slice of reality. (The full scoreboard, ten equations spanning two and a half centuries, is in the <strong>Appendix</strong> — because once you start this list, stopping at five requires discipline and stopping at ten requires force.)</p><p>Note the time span: compression at this level does not happen overnight. Each line stands on the ones before it, the way an idiom stands on its characters.</p><p>The compression ratio is effectively infinite: finite symbols, unbounded phenomena — including phenomena that hadn’t been measured when the equation was written down. That last part is the tell. Dirac’s equation didn’t just fit the data Dirac had; it kept working on data nobody had. That is the difference between compression that <em>memorizes</em> and compression that <em>understands</em>.</p><h3>Now, about that trillion-parameter model</h3><p>A large language model fits approximately all of humanity’s text using hundreds of billions of parameters. This is genuinely impressive engineering, and it is genuinely compression — terabytes of text distilled into gigabytes of weights that can regenerate the patterns.</p><p>But put it on the same scoreboard:</p><ul><li><strong>An LLM:</strong> terabytes in → gigabytes of parameters out. Compression ratio: maybe two or three orders of magnitude. Extrapolation outside the training distribution: unreliable, politely put.</li><li><strong>A human brain, running on about twenty watts:</strong> all observed motion in → <strong>F = ma</strong> out. Twenty bytes. Predictive reach: centuries, and counting, including regimes no human had ever observed.</li></ul><p>To be precise about what the LLM is good at: give it a ciphertext — a prompt — and it decompresses beautifully, producing plausible, often brilliant continuations. That is real skill. What it has not done is run the other direction: compress the raw, unlabeled chaos of reality into a new ciphertext nobody handed it. F = ma did not decompress a prompt; it compressed the universe. That is the asymmetry between <em>fitting</em> and <em>understanding</em> — a model that interpolates within the space of things it has already seen, versus a mind that derives the invariant law generating them, valid in regions it has never seen. When an AI looks at the world and hands back something as short, as beautiful, and as <em>unreasonably</em> predictive as E = mc², the AGI conversation will deserve its capital letters. Until then, we have built a very large idiom-memorizer that has not yet coined an idiom.</p><p>And to be fair to the machines: coining the idiom is <em>hard</em>. It took natural language millennia of evolutionary A/B testing to produce 对牛弹琴, and it took five of the brightest minds humanity has produced across three centuries to write the five lines in the table above — <strong>Newton</strong>, who compressed all motion, from a falling apple to an orbiting moon, into three laws; <strong>Maxwell</strong>, who unified electricity, magnetism, and light itself into four; <strong>Einstein</strong>, who folded energy, mass, space, and time into each other with a single equals sign; <strong>Schrödinger</strong>, who wrote the one line by which all microscopic systems evolve; and <strong>Dirac</strong>, whose line was so compressed it contained particles nobody had ever seen. Five minds, five lines, three hundred years. The bar at the top of the ladder is not “generate plausible text.” The bar is Newton, Einstein, and Dirac.</p><h3>The punchline is pedagogical</h3><p>Here is the satisfying twist: the same scoreboard explains why some ways of learning work and others don’t.</p><p>A student who memorizes 对牛弹琴 as four arbitrary syllables holds rote, uncompressed knowledge — brittle, unreachable, gone by next Tuesday. A student who <em>sees the compression</em> — the cow, the lute, the wasted music, the 2+2 rhythm that carried it across twenty centuries — holds F = ma knowledge. It decompresses on demand. It generalizes. It predicts the meaning of idioms they have never seen, because they have learned the encoding scheme, not the ciphertext.</p><p>Compression is understanding, in both directions: it is how knowledge was built, and it is the only way knowledge is truly acquired. Everything else is inference at temperature zero over somebody else’s weights.</p><h3>Appendix</h3><h4>The Scoreboard in Chronological Order</h4><p>Ten compressions, two and a half centuries. The first five are the classics from the essay; the second five are the compressions <em>behind</em> the compressions — the ones that either generate the others or compress the very ideas of information and knowledge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*WWBzNgkzqbsSIc3DranV0g.png" /></figure><p>Two footnotes to the scoreboard:</p><ul><li><strong>Symmetry, conservation, invariance</strong> — Noether’s row deserves an extra beat: these three words are the same idea seen from three angles. A symmetry is a transformation that leaves the physics <em>invariant</em>, and Noether proved a 1:1 dictionary between every such invariance and a <em>conservation</em> law. It is the physics version of what this essay says about idioms — the fixed, invariant shell (four characters, 2+2 meter) is precisely what lets the content survive transformation across dialects and centuries. Invariance is what makes transmission lossless.</li><li><strong>The mathematician’s entry</strong> — if physics owns this scoreboard, mathematics owns its mic-drop: <strong>e^iπ + 1 = 0</strong> (Euler’s identity), which links five fundamental constants — e, i, π, 1, 0 — in seven symbols with nothing left over. No phenomena, no apparatus, no universe required; pure structure compressing pure structure. Physicists write the shortest descriptions of the world; Euler wrote the shortest description of mathematics itself.</li></ul><p>The list is not exhaustive, and cannot be — that is rather the point. Ten rows already span 241 years of the brightest minds humanity has produced, each standing on the rows above. No overnight training run appears anywhere in the table.</p><h4>Names worth looking up</h4><ul><li><a href="https://en.wikipedia.org/wiki/Gregory_Chaitin">Gregory Chaitin</a> proposed “Algorithmic Information Theory” in 1987 — <a href="https://www.researchgate.net/scientific-contributions/Gregory-J-Chaitin-81072593">see ResearchGate</a> for his work. He is notable for algorithmic randomness, Chaitin’s constant (Ω), and the principle that “comprehension is compression”.</li><li><a href="https://en.wikipedia.org/wiki/Andrey_Kolmogorov">Andrey Kolmogorov</a> authored ”Three approaches to the quantitative definition of information” in 1965. He is notable for Kolmogorov complexity — the length of the shortest program that produces a given output.</li><li><a href="https://en.wikipedia.org/wiki/Ray_Solomonoff">Ray Solomonoff</a>” established “A Formal Theory of Inductive Inference” in 1964. He is notable for algorithmic probability and universal induction — the foundation of algorithmic information theory.</li><li><a href="https://en.wikipedia.org/wiki/Marcus_Hutter">Marcus Hutter</a> wrote ”Universal Artificial Intelligence” in 2005, <a href="https://www.hutter1.net/">see Personal Page</a> for additional details. He is notable for AIXI theory and the Hutter Prize, which treats compression as an intelligence test.</li><li><a href="https://en.wikipedia.org/wiki/J%C3%BCrgen_Schmidhuber">Jürgen Schmidhuber</a> authored ”Simple Algorithmic Principles of Discovery, Subjective Beauty, Selective Attention, Curiosity &amp; Creativity” in 2007 — <a href="https://www.ai-journal.com/">see Personal Page</a> for more. He is notable for formalizing discovery as data compression and the theory of artificial curiosity.</li><li><a href="https://en.wikipedia.org/wiki/Claude_Shannon">Claude Shannon</a> established ”A Mathematical Theory of Communication” in 1948. He is notable for founding information theory, defining entropy as a measure of information, and establishing the bit as the fundamental unit of information.</li></ul><h4><strong>Author</strong></h4><p><em>Wen G. Gong is a former physics post-doc at Lawrence Berkeley National Laboratory and a data/AI engineer with 20+ years of experience across SQL, Oracle, and enterprise data systems. He is the author of SPL (Structured Prompt Language). He can be reached at </em><a href="/service/mailto:wen.gong.research@gmail.com"><em>wen.gong.research@gmail.com</em></a><em>.</em></p><p><em>© 2026 Wen G. Gong. Licensed under CC BY 4.0. Share freely with attribution.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=409b9a7d6779" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What If LLM Workflow Could Be Orchestrated Like Writing SQL?]]></title>
            <link>https://medium.com/@wen.g.gong/what-if-llm-workflow-could-be-orchestrated-like-writing-sql-b16446d493fd?source=rss-7b5395ada3ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/b16446d493fd</guid>
            <category><![CDATA[spls]]></category>
            <category><![CDATA[stem]]></category>
            <category><![CDATA[neurosymbolic-ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[agentic-workflow]]></category>
            <dc:creator><![CDATA[W Gong]]></dc:creator>
            <pubDate>Tue, 23 Jun 2026 02:46:43 GMT</pubDate>
            <atom:updated>2026-06-23T02:50:36.789Z</atom:updated>
            <content:encoded><![CDATA[<h3>The SQL lesson</h3><p>SQL changed data engineering by separating <strong>what</strong> you want from <strong>how</strong> to get it. Before SQL, every data pipeline was imperative code tied to a specific storage engine. After SQL, you declared the logic once and the engine handled the rest. You don’t rewrite your query when you move from MySQL to Postgres.</p><p>LLM workflows today are where data engineering was before SQL: imperative Python scripts, hard-wired to one LLM provider’s API, unreproducible the moment you swap a model or move to a different machine.</p><p>SPL ( <a href="https://arxiv.org/abs/2602.21257">Structured Prompt Language</a>) was initially introduced to manage prompt and context, and is now extended to orchestrate LLM workflows. Here is what that looks like side by side:</p><pre>-- SQL: declare what data you want<br>SELECT   product, SUM(revenue)<br>FROM     sales<br>WHERE    region = &#39;APAC&#39;<br>GROUP BY product;<br>-- Runs on Postgres, MySQL, SQLite — zero changes.</pre><pre>-- SPL: declare what the workflow does <br>WORKFLOW solve_math_problem<br>  INPUT @problem TEXT<br>  OUTPUT @result TEXT <br>DO <br>  GENERATE decompose(@problem) INTO @plan<br>  SOLVE execute_step(@plan) INTO @answer<br>  ASSERT @answer is valid<br>  GENERATE explain(@problem, @answer) INTO @result <br>END</pre><pre># Runs on local GPU, distributed grid, or cloud API - zero changes. <br>spl3 run solve_math_problem.spl --adapter ollama --model gemma3 <br>spl3 run solve_math_problem.spl --adapter claude_cli --model claude-sonnet-4-6 <br>spl3 run solve_math_problem.spl --adapter momagrid --model gemma4:e2b <br>spl3 run solve_math_problem.spl --adapter openrouter --model qwen/qwen3.6-plus</pre><p>The .spl file is the logical specification. The adapter and model are runtime flags. Same file, same logic, different execution - just like SQL.</p><p>If you have built LLM workflows and hit provider lock-in, unverifiable outputs, or API costs that scale faster than your workload, read on. We try to prescribe <strong>One SPL pill</strong> that <strong>kills three pains.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uwa3HahRIW8kGuRE.png" /></figure><h4>Pain-point #1: Framework lock-in</h4><p>Your LangChain script calls openai.chat.completions.create(). You want to try Claude? Rewrite the glue code. Run locally with Ollama? Rewrite again. Switch to a distributed grid? Start over.</p><p>This is the same problem SQL solved for data. The query says <em>what</em>; the engine handles <em>how</em>. SPL does the same: the .spl file declares the workflow logic, and the --adapter flag at runtime picks the engine. Fourteen adapters ship today - Ollama, Claude, OpenRouter, Momagrid, and others - and adding one means implementing two methods ( generate and generate_multimodal), not rewriting every workflow.</p><p>One workflow file. One --adapter flag. Many providers.</p><h4>Pain-point #2: Output seems right, but unverified</h4><p>LLMs produce fluent, confident answers. Some are correct. Some are wrong. From outside the system, they look identical. We call this failure mode <em>silent unverified success</em> — and it is the default in every agent framework today. The LLM says the answer is right, and there is no structural mechanism to disagree. Keep in mind that no matter how confidently an LLM behaves, it is rooted in statistical learning pre-trained on available data.</p><p>SPL makes verification a language construct, not a convention someone might forget:</p><ul><li><strong>GENERATE</strong> - the LLM. Probabilistic. Drafts plans, translates intent, narrates results.</li><li><strong>SOLVE</strong> - the kernel. Deterministic, bit-perfect. Executes exact computation (SymPy, SageMath, Lean 4).</li><li><strong>ASSERT</strong> - the gate. Deterministic. Passes or fails; the LLM cannot override it.</li></ul><p>Two execution modes, syntactically distinct, in one file. You can <em>grep</em> which parts of a pipeline are LLM output and which are kernel-verified. The LLM plans and explains; the kernel solves and checks. Provenance is structural — baked into the language — not a convention that erodes the moment someone forgets a wrapper function.</p><p>Here is what both modes look like in the same workflow:</p><pre>GENERATE decompose_problem(@problem) INTO @steps_text <br><br>WHILE @i &lt; @n_steps <br>DO <br>  CALL solve_chain_step(@step, @running_expression, @backend) INTO @step_summary <br>  EVALUATE @running_expression <br>    WHEN = &quot;solver_error&quot; THEN <br>      RETURN &quot;[SOLVER FAILURE] Step could not be computed&quot; <br>        WITH status = &quot;solver_error&quot;<br>  END <br>END <br><br>GENERATE explain_chain(@problem, @trace) INTO @result</pre><p>The GENERATE steps are probabilistic - the LLM decomposes and explains. The CALL solve_chain_step dispatches to a deterministic kernel ( SOLVE under the hood) that executes each math step exactly. If any step fails verification, the workflow exits with an explicit error status. The LLM never gets to summarize whether verification happened.</p><h4>Pain-point #3: Token tax and data privacy</h4><p>Every GENERATE call to an external API has a per-token cost. One call is cheap. A batch of overnight experiment runs, document processing jobs, or code review queues? That is a line item that hits the business bottom line.</p><p>And every token sent externally is data that left the building. Proprietary source code, regulated content, student data — these are not theoretical concerns.</p><p><strong>Momagrid</strong> is a lightweight distributed inference grid built for exactly this. Consumer GPUs — gaming PCs, MacBooks with Apple Silicon, developer workstations — each running Ollama plus a thin agent process. The hub sits on the LAN. The models run on-device. No new hardware budget. No API calls. No data egress.</p><p>Two commands to stand up the grid:</p><pre>mg hub up                    # launch the hub on one machine <br>mg join http://192.168.0.1   # any machine with a GPU joins the grid</pre><p>From the SPL workflow’s perspective, nothing changes. Swap --adapter ollama to --adapter momagrid and GENERATE steps distribute across the grid automatically. SOLVE and ASSERT stay local - deterministic operations never cross the network. This is DODA in action: <strong>Design Once, Deploy Anywhere.</strong> The same .spl file runs on a single laptop, a LAN grid of consumer GPUs, or a cloud API - zero code changes.</p><p>The hardware is already there. An office with developer MacBooks sitting idle overnight already owns a distributed inference cluster — it just is not wired up yet. A school or university with a laptop fleet has the same opportunity: free, private inference for educational AI workflows, with zero dependency on commercial API availability or per-student budget allocation.</p><h3>Case study: NeuroSymbolic Math Verification</h3><h4>One SPL pill, three pains killed</h4><p>To demonstrate how it all works together, we use a specific <a href="https://github.com/digital-duck/SPL.py/blob/main/cookbook/77_neurosymbolic/symbolic_math.spl">math workflow</a> that touches all three points:</p><ul><li><em>The same </em><em>.spl file runs on Ollama, Claude, or Momagrid (pain 1 gone);</em></li><li><em>A SymPy/SageMath kernel verifies every math step the LLM produces (pain 2 gone);</em></li><li><em>The grid runs on idle consumer GPUs with zero data egress (pain 3 gone).</em></li></ul><h4>The Math problem</h4><p>We ask ten different LLMs to “differentiate 3x³ − x, then solve for x.” Without verification, most will give you a fluent, confident answer. Some of those answers will be wrong. You cannot tell which ones without checking — and if you are checking by hand, what was the LLM for?</p><p>We ran a controlled A/B across <strong>10 models</strong>, <strong>20 math problems</strong> (algebra, calculus, ODEs, systems), and <strong>2 modes</strong>:</p><ul><li><strong>Solver ON</strong>: the LLM decomposes the problem into steps; a SymPy/Sage kernel executes each step exactly; the LLM narrates the verified trace.</li><li><strong>Solver OFF</strong>: the same problem, the same LLM, no kernel. The LLM solves it end-to-end, unaided.</li></ul><p>Total: <strong>4,700+ experimental cells</strong> across multiple runs, dispatched via Ollama and Momagrid adapters with consumer GPU workers.</p><p>The A/B question: <em>does the deterministic kernel do real work, or would the LLM have gotten there anyway?</em></p><h4>The SPL recipe</h4><p>The workflow is <a href="https://github.com/digital-duck/SPL.py/blob/main/cookbook/77_neurosymbolic/symbolic_math.spl">symbolic_math.spl</a> - 310 lines, including comments. The core loop is what you saw above: GENERATE a plan, SOLVE each step through the kernel, fail-fast on any solver error, GENERATE a narration of the verified trace. The solver backend (SymPy, SageMath, or Lean 4) is a --param backend= flag, not a code change. The LLM provider is an --adapter flag. The same file runs every cell in the benchmark:</p><pre>export PROBLEM=&quot;differentiate 3*x**3 - x, solve for x&quot; <br><br># Local, single GPU <br>spl3 run symbolic_math.spl --adapter ollama --model gemma3 --param problem=$PROBLEM <br><br># Distributed across consumer GPU grid <br>spl3 run symbolic_math.spl --adapter momagrid --model gemma4:e2b --param problem=$PROBLEM <br><br># Cloud API<br>spl3 run symbolic_math.spl --adapter claude_cli --param problem=$PROBLEM</pre><h4>Benchmark results</h4><p>The headline finding — the <strong>auditability gap</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*7ry0iHlNsQ3OCLjz9hLZKg.png" /></figure><p>Read the right column first. Nine out of ten models report <strong>100% pass rate</strong> with the solver off. Every answer looks correct. None are verified.</p><p>Now read the left column. With the kernel checking each step, pass rates drop to 27%-92%. The kernel is catching real errors that the LLM confidently hid. That gap between the two columns — that is the <em>silent unverified success</em> problem, measured at scale.</p><p>The best model (gemma4:e2b) still gets 91.5% verified — meaning even a strong model produces wrong math on roughly 1 in 11 problems that it would have otherwise reported as correct. The weakest (phi3) drops from a claimed 100% to an actual 27.4%. Without the kernel, you would never know.</p><p><strong>Distributed speedup</strong>: the same benchmark that took 60 minutes on a single GPU completed in 20 minutes on 3 consumer GPUs via Momagrid — exactly linear scaling. The workflow code was identical.</p><h3>Try it</h3><p>Both <a href="https://github.com/digital-duck/SPL.py">SPL</a> and <a href="https://github.com/digital-duck/momagrid">Momagrid</a> projects are <strong>Apache 2.0</strong> open-sourced.</p><p><strong>SPL</strong> — the workflow language and runtime:</p><pre># Python runtime + CLI from PyPI <br>pip install spl-llm <br><br># your first SPL workflow <br>spl3 run cookbook/05_self_refine/self_refine.spl --llm ollama:gemma3 \<br>  --param task=&quot;explain linear algebra&quot;</pre><p><strong>Momagrid</strong> — the distributed inference grid:</p><pre>git clone https://github.com/digital-duck/momagrid <br>cd momagrid &amp;&amp; go build       # build from source (Go) <br>mg hub up                     # start the hub <br>mg join http://&lt;HUB-IP&gt;:9000  # workers join from any machine on the same network</pre><p><strong>Reproduce the case-study benchmark:</strong></p><pre># Run Recipe 77 locally (needs Ollama + a model pulled) <br>spl3 run cookbook/77_neurosymbolic/symbolic_math.spl --llm ollama:gemma3 \<br>  --param problem=&quot;differentiate 3*x**3 - x, then solve for x&quot; <br><br># Or run the full experiment grid on Momagrid <br>python cookbook/77_neurosymbolic/run_experiment_momagrid.py --workers 6</pre><p>No API key required to start. Ollama runs free, local models. SPL ships 14 adapters — when you want to compare against cloud models, add --adapter openrouter or --adapter claude_cli and the workflow stays the same. <em>Note:</em> --llm ollama:gemma3 is shorthand for --adapter ollama --model gemma3</p><h4>The honest limits</h4><p><strong>The correspondence gap.</strong> The deterministic kernel verifies the <em>computation</em>, not the natural-language claim. “Differentiate 3x³ − x” goes in; SymPy returns 9x² − 1 exactly. But the link between the prose problem statement and the symbolic expression is the one thing nothing machine-checks. Mitigations that ship: the verified statement and the prose claim are stored side by side for human audit, and an LLM faithfulness judge gates badge assignment — but the judge can only <em>withhold</em> a badge, never grant one. Badges are granted by the kernel.</p><p><strong>The eval surface.</strong> The kernels evaluate LLM-emitted expression strings ( sympify, sage_eval). This is a local research tool running the operator&#39;s own model on the operator&#39;s machine. Do not point it at untrusted input.</p><p><strong>Momagrid today and next step.</strong> The benchmark runs on a home LAN: one hub, three consumer GPU nodes. The architecture scales linearly with agent count — the receipts are at 3-GPU scale. The next milestone is a WAN hub with a public domain, where anyone with a GPU and Ollama can register and contribute capacity.</p><p><strong>Scope.</strong> Computational math: algebra, calculus, ODEs, linear algebra, systems. The Lean 4 integration handles formal proof checking for known results in mathlib. This is not novel theorem proving and not whole-textbook formalization — it is making “an LLM said so” auditable for the claims that matter.</p><p>Author</p><p><em>Wen G. Gong is a former physics post-doc at Lawrence Berkeley National Laboratory and a data/AI engineer with 20+ years of experience across SQL, Oracle, and enterprise data systems. He is the author of SPL (Structured Prompt Language). He can be reached at </em><a href="/service/mailto:wen.gong.research@gmail.com"><em>wen.gong.research@gmail.com</em></a><em>.</em></p><p><em>© 2026 Wen G. Gong. Licensed under CC BY 4.0. Share freely with attribution.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b16446d493fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NeuroSymbolic Math in a Structured Prompt Language]]></title>
            <link>https://medium.com/@wen.g.gong/neurosymbolic-math-in-a-structured-prompt-language-6b920d44d11b?source=rss-7b5395ada3ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b920d44d11b</guid>
            <category><![CDATA[spls]]></category>
            <category><![CDATA[education]]></category>
            <category><![CDATA[neurosymbolic-ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[stem]]></category>
            <dc:creator><![CDATA[W Gong]]></dc:creator>
            <pubDate>Thu, 11 Jun 2026 05:48:49 GMT</pubDate>
            <atom:updated>2026-06-11T06:29:33.824Z</atom:updated>
            <content:encoded><![CDATA[<p><em>What 400 runs of symbolic math say about open-source models, verified reasoning, and who gets access to quality STEM education.</em></p><h3>How this started</h3><p>A few weeks ago I asked nine different LLMs to solve the exact same algebra problem — <em>differentiate 3x³ − x, factor, solve</em> — wired into the exact same pipeline. The answer never changes:</p><pre>d/dx(3x³ − x)            = 9x² − 1 <br>factor(9x² − 1)          = (3x − 1)(3x + 1) <br>solve((3x−1)(3x+1)=0)    = x = −1/3, 1/3</pre><p>The results varied wildly anyway. Some models followed the instructions cleanly. One hallucinated Python code about boiling water at altitude. One burned its entire token budget and returned nothing. And one gave a fluent, confident, <strong>wrong</strong> answer — reported as Status: complete - that was indistinguishable in format and tone from the right ones.</p><p>The natural objection was: <em>“sure, but one problem isn’t a benchmark.”</em> Fair. So we scaled up — <strong>10 models, 20 problems spanning five difficulty tiers, with an A/B control arm built in</strong> — and ran every combination. This is what 400 runs look like.</p><h3>The architecture: neurosymbolic by design</h3><p>The pipeline is written in <a href="https://github.com/digital-duck/SPL.py">SPL</a> (Structured Prompt Language), an open-source language for building pipelines where a language model and an exact math engine each do the part they are best at:</p><ol><li>An LLM breaks the math problem into an ordered list of steps.</li><li><strong>SymPy</strong> — a deterministic symbolic-math engine, not a language model — executes and verifies each step. Exact by design.</li><li>The LLM explains the verified result in plain English.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3BefqCIewXB4OL_X65lFcQ.png" /><figcaption>An integrated hybrid AI architecture that dynamically orchestrates tasks by routing complex queries to either a neurosymbolic engine for structured, logic-based reasoning or a large language model for creative, generative processing.</figcaption></figure><p>The LLM plans and explains; the domain expert computes. The hard math never passes through a pattern-matcher at all.</p><p>Each of the 20 problems ran through two arms:</p><ul><li><strong>solver=true</strong> (neurosymbolic): decompose → SymPy verifies → explain.</li><li><strong>solver=false</strong> (LLM-only): the model answers directly. No math engine, no verification. A clean control.</li></ul><p>The 20 problems cover five tiers of undergraduate mathematics — from single-step differentiation, through limits and transcendental functions, integration and eigenvalues, differential equations and infinite series, up to Laplace transforms with round-trip verification.</p><h3>The ten models</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*-uHgdKQbYifthEfqzmm6vw.png" /></figure><p>Every model except sonnet-4-6 runs locally via <a href="https://ollama.ai/">Ollama</a> - no API key, no bill, on hardware a student already owns.</p><h3>The results</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*o-7-nRpeWjFQC8_e7yQ_zQ.png" /><figcaption><em>Pass criteria: solver=true counts </em><em>complete only (SymPy verified the full chain); solver=false counts</em><em>complete or </em><em>unverified_success (no engine by design).</em></figcaption></figure><p>A note on sonnet-4-6: we included one frontier model deliberately, as a quality reference point - and Claude earned it, with the best verified score in the test. Its single solver-arm failure (p017, an ODE initial-value problem) was a SymPy library bug, not a model error - its decomposition was correct. But a reference point is exactly that: a reference, not a requirement. Every other model in the table runs free and local, and the architecture works the same either way.</p><h3>The standout: rnj-1, a model named after Ramanujan</h3><p>The most striking open-weight result belongs to a newcomer. <a href="https://www.essential.ai/research/rnj-1"><strong>rnj-1</strong></a> is named after <a href="https://www.wikiwand.com/en/Srinivasa_Ramanujan"><strong>Srinivasa Ramanujan</strong></a> — the self-taught Indian mathematician who, with no formal training and almost no resources, produced results that still drive research a century later. A clerk with a notebook out-thought the best-resourced institutions of his era — proof that intelligence is distributed everywhere, indifferent to wealth and power, waiting only for a door to open. It is hard to imagine a more fitting namesake for what this experiment is about: serious mathematics made accessible without institutional privilege.</p><p>The lineage behind the model is just as striking. Essential AI was founded by <strong>Ashish Vaswani</strong> — the first author of “Attention Is All You Need” (2017), the paper that introduced the Transformer architecture underpinning nearly every model in this experiment. The person who started the transformer era chose, as his next act, to build an open-weight math model named after Ramanujan and <a href="https://ollama.com/library/rnj-1">publish it on Ollama</a> for anyone to pull and run locally, free.</p><p>The model lives up to the name. rnj-1 scores <strong>15/20</strong> on the verified solver arm - the best result of any open model in the test - at <strong>4.6 seconds average</strong>, nearly three times faster than the frontier model. It also scores a perfect 20/20 on the direct-answer arm. That combination matters: it can reason through all 20 problems in free form, <em>and</em> it can break them into precise, structured steps that SymPy can run without repair. Those are two different skills, and the second is rarer.</p><p>A specialized open-weight model, running locally, free, in under 5 seconds, within four problems of a frontier API on verified correctness — that is the strongest evidence yet that “better at the exact task you need” can be a smarter bet than “bigger in general.”</p><h3>The A/B gap is the real finding</h3><p>The most useful number in this dataset is not any model’s total score — it is the gap between its two arms.</p><p>Six of the ten models score a perfect 20/20 on solver=false. That sounds impressive until you read what it means: the model answered directly, without any verification, and the answer <em>looked</em> correct. We have no proof it was. On the hardest tiers, several models generate fluent, confident explanations for answers a symbolic check would immediately reject.</p><p>phi4 is the sharpest diagnostic: 17/20 answering directly, 2/20 verified. The intelligence is there - its free-form reasoning gets the right answer most of the time - but it cannot follow the narrow, structured decomposition instruction the solver arm requires. Markdown fences, extra prose, wrong field names: the format slips, SymPy rejects the plan, and 17 correct answers become 2 verified ones. deepseek-r1, a model trained specially for step-by-step reasoning, fails in a related way: it spends its whole token budget thinking instead of producing the structured plan. Reasoning well in free form is not the same skill as reducing a problem to steps an exact engine can verify.</p><p>And that is the failure mode worth designing against — not the wrong answers that look wrong (those are easy to spot), but the wrong answers that look exactly right: same format, same confidence, same Status: complete. In the single-problem run, lfm2.5 once solved the wrong equation entirely and reported success with full fluency. The verified engine catches that immediately. Without it, nothing does.</p><h3>Why scale alone doesn’t close this gap</h3><p>Biology ran this experiment over a timescale no AI lab can replicate. The human brain isn’t the largest brain nature produced — not even close. What set it apart was never raw size; it was deeper, more layered connectivity — structure, not scale. Evolution had every opportunity to keep growing brains and let scale do the work. It didn’t, because past a certain point, that isn’t where the returns are.</p><p>Statistical learning is, at its core, sophisticated pattern-fitting. That is an extraordinary capability — and it is <em>not</em> “exact symbolic computation,” any more than a brilliant essayist is automatically a reliable accountant. No amount of additional fitting closes that gap, because it was never a fitting problem to begin with.</p><p>Which is the sharper way to say what this pipeline does: <strong>we didn’t make the models better at math — we made it so they never had to be.</strong> The lever worth pulling isn’t always “more parameters, more training, more compute.” Sometimes it is “stop asking the pattern-matcher to do the part of the job that was never pattern-matching in the first place.”</p><h3>STEM education is the point</h3><p>A student in an underdeveloped country, or simply a curious kid without institutional resources, has no realistic path to a frontier model API subscription. That is a luxury, full stop. And yet genius has never checked bank accounts before arriving — Ramanujan is the standing proof that the rich and powerful are not automatically the gifted, and the gifted are very often neither rich nor powerful. The next Ramanujan is out there right now, and the only question is whether the tools reach her.</p><p>But rnj-1, qwen2.5, and gemma3 run on a modest laptop and cost nothing. Every answer they deliver through this pipeline is <strong>verified by SymPy - the same verification that runs behind Claude&#39;s 19/20.</strong> And when a model fails, it fails loudly and visibly - a student never receives a wrong answer dressed up as a right one. The neurosymbolic architecture is what makes that possible: by routing computation through SymPy, it shrinks the LLM&#39;s role to parsing intent and explaining clearly - exactly what small open models already do well. The hard math stays exact by design, regardless of which model sits at the top of the pipeline.</p><p>Correct, verified, step-by-step STEM education, on hardware a student already owns, at zero marginal cost. That is not a minor efficiency gain. That is the goal.</p><p>It is also worth honoring who built the open models that make this possible. Google invented the Transformer architecture in 2017 (“Attention Is All You Need,” Vaswani et al.) — the foundation nearly every model here stands on. Alibaba’s qwen2.5, released quietly in September 2024, is still the efficiency champion eighteen months later: 12/20 verified at 2.8 seconds, free. Liquid AI&#39;s lfm2.5 is based on non-transformer architectures rooted in advanced state-space models (SSMs). And Ashish Vaswani - the same Vaswani whose name leads that 2017 paper - chose to name his company&#39;s math model after a genius who proved, a hundred years ago, that talent is distributed everywhere even when resources are not.</p><h3>How to reproduce</h3><p>Every prompt, every token count, every log line is public. Clone and run:</p><ul><li><a href="https://github.com/digital-duck/SPL.py/tree/main/cookbook/67_symbolic_math/sympy_llm.spl">recipe #67 SPL script</a></li><li><a href="https://github.com/digital-duck/SPL.py/blob/main/cookbook/67_symbolic_math/run_experiment.py">run_experiment.py</a></li><li><a href="https://github.com/digital-duck/SPL.py/blob/main/cookbook/67_symbolic_math/logs-spl/case-2-log-rerun-20260610-062904.md">experiment log (rerun 20260610)</a></li><li><a href="https://www.essential.ai/research/rnj-1">rnj-1 announcement (Essential AI)</a></li><li><a href="https://ollama.com/library/rnj-1">rnj-1 on Ollama</a></li></ul><pre># setup <br>git clone https://github.com/digital-duck/SPL.py.git <br>cd SPL.py <br>conda create -n spl123 python=3.11 -y &amp;&amp; conda activate spl123 <br>pip install -e . <br><br># run a single model on all 20 problems (both arms) - m010 is rnj-1: <br>python cookbook/67_symbolic_math/run_experiment.py -m m010 <br><br># run all 10 models (400 runs): <br>python cookbook/67_symbolic_math/run_experiment.py <br><br># explore results in the Streamlit UI: <br>streamlit run cookbook/67_symbolic_math/app_experiment.py</pre><p>To run local models, install <a href="https://ollama.ai/">Ollama</a> first:</p><pre>ollama pull rnj-1 <br>ollama pull qwen2.5 <br>ollama pull gemma3 <br>ollama pull phi4 <br># ... add others from the model list</pre><h3>What’s next</h3><p>These 400 runs answer the “one problem isn’t a benchmark” objection. The next question is whether the pattern holds on harder problems — where breaking the problem down takes layered decisions, not a single flat list of steps. I’m extending the problem set now, together with a mathematician collaborator who is helping curate problems that probe the actual edges of where symbolic engines and LLMs each fail.</p><p>The reframing — <em>let the LLM plan and explain; let the domain expert compute</em> — generalizes far past algebra. Physics, chemistry, structural engineering, formal logic, financial modeling: anywhere hard science has an exact engine to lean on (a simulator, a solver, a verified database, a proof checker), the same shape applies.</p><p>The vision stays the same: a system that is always-verified, always-explained, and within reach of any student with a laptop — not just those with institutional budgets. Quality STEM education should not be a luxury. <a href="https://github.com/digital-duck/SPL.py">SPL</a> is the infrastructure I’m building to make that real, one recipe at a time.</p><p>If you work in STEM education, EdTech, open-source AI, or model evaluation — or if “bigger model” has become the default answer to every capability gap in your world — I’d be glad to hear whether this resonates, or where you think it breaks.</p><h4>Author</h4><p><em>Wen G. Gong is a former physics post-doc at Lawrence Berkeley National Laboratory and a data/AI engineer with 20+ years of experience across SQL, Oracle, and enterprise data systems. He is the author of SPL (Structured Prompt Language). He can be reached at </em><a href="/service/mailto:wen.gong.research@gmail.com"><em>wen.gong.research@gmail.com</em></a><em>.</em></p><p><em>© 2026 Wen G. Gong. Licensed under CC BY 4.0. Share freely with attribution.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b920d44d11b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI@Home with Gemma]]></title>
            <link>https://medium.com/@wen.g.gong/ai-home-with-gemma-369fa8c27e2b?source=rss-7b5395ada3ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/369fa8c27e2b</guid>
            <category><![CDATA[agentic-workflow]]></category>
            <category><![CDATA[spls]]></category>
            <category><![CDATA[local-inference]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ollama]]></category>
            <dc:creator><![CDATA[W Gong]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 01:24:34 GMT</pubDate>
            <atom:updated>2026-04-12T01:38:52.852Z</atom:updated>
            <content:encoded><![CDATA[<p><em>With a $500 mini-PC and an open model, the AI that once lived only in data centers now runs in your garage, your village, your workplace — and it’s surprisingly good.</em></p><h3>The Moment Everything Changed</h3><p>For the past few years, the most capable AI was delivered via API calls. You typed a question, it traveled to a data center somewhere, a thousand-dollar GPU thought about it, and the answer came back. Remarkable — but not yours. Not local. Not private. Not free.</p><p>That changed quietly with the release of Gemma 4.</p><p>Google’s Gemma 4 family — particularly the e2b and e4b variants — crossed a threshold. These are models small enough to run on a single consumer machine, open enough to download and keep, and capable enough to do real work. Not toy work. Not “summarize this paragraph” work. Genuine multi-step reasoning, structured writing, self-critique — the kind of cognitive labor that used to require a cloud subscription.</p><p>But to understand why this moment matters, you have to know how long the road here actually was.</p><h3>A Decade in the Making: 2017 to 2026</h3><p>The story of AI coming home begins not in a garage, but in a Google research paper.</p><h4><strong><em>2017 — “Attention Is All You Need”</em></strong></h4><p>In June 2017, eight Google researchers published a paper with a deceptively modest title: <em>“Attention Is All You Need.”</em> It introduced the <strong>Transformer architecture</strong> — a new way of processing language where every word attends to every other word simultaneously, rather than reading left to right like previous models.</p><p>Nobody outside of research circles noticed. No product launched. No press release. Just a PDF on arXiv.org.</p><p>That paper is now the foundation of every large language model in existence. GPT, Gemma, Claude, LLaMA — every one of them is a Transformer. The authors gave away the blueprint for the AI decade that followed.</p><h4><strong><em>2018–2020 — OpenAI Scales the Blueprint</em></strong></h4><p>OpenAI took the Transformer and asked a simple question: what happens if you make it bigger and feed it more text?</p><p><strong>GPT-1</strong> (2018) — 117 million parameters. Interesting but limited. Mostly a research curiosity.</p><p><strong>GPT-2</strong> (2019) — 1.5 billion parameters. OpenAI was so concerned about misuse they initially refused to release it. In hindsight, the concern was premature — but it signaled that something qualitatively different was emerging.</p><p><strong>GPT-3</strong> (2020) — 175 billion parameters. The first model that genuinely surprised people. You could give it a few examples of a task and it would generalize. It could write code, translate languages, answer questions, and compose essays — without being explicitly trained on any of those tasks. Researchers called this “emergent capability.” Everyone else called it uncanny.</p><p>GPT-3 was still locked behind an API. Still a cloud service. Still not yours.</p><h4><strong><em>2022 — The ChatGPT Moment</em></strong></h4><p>In November 2022, OpenAI wrapped GPT-3.5 in a chat interface and called it <strong>ChatGPT</strong>. Within five days it had one million users. Within two months, one hundred million. It was the fastest consumer product adoption in history.</p><p>Something shifted in the public consciousness. AI was no longer a research topic or a science fiction premise. It was a thing you could open in a browser tab and have a conversation with. Developers, students, writers, doctors, teachers — everyone suddenly had a direct line to a model that could reason, explain, and create.</p><p>The cloud wall was still there. But now everyone could see clearly what was on the other side of it.</p><h4><strong><em>2023–2024 — The Open Infrastructure Revolution</em></strong></h4><p>The release of Meta’s <strong>LLaMA</strong> weights in early 2023 — initially leaked, then officially released — started a cascade. Suddenly anyone with technical skill could run a capable model locally. But weights alone are not enough. What turned LLaMA from a research artifact into a tool anyone could use was a wave of open infrastructure built by the community.</p><p><strong>llama.cpp</strong>, created by Georgi Gerganov, deserves special recognition. Within days of the LLaMA release, Gerganov — working alone — rewrote the inference engine in pure C++, with no dependencies, runnable on a laptop CPU. He introduced <strong>quantization</strong> techniques that compress model weights from 16-bit floats down to 4-bit integers, shrinking a 7-billion-parameter model from 13 GB to under 4 GB with minimal quality loss. This was the technical unlock that made AI genuinely portable. Without llama.cpp, “running AI locally” would have remained the domain of people with research-grade workstations.</p><p><strong>Ollama</strong> wrapped this power in a dead-simple interface. One command — ollama run gemma4:e2b - downloads the model and starts a local API server compatible with the OpenAI standard - ready to chat. No Docker expertise. No CUDA configuration. No dependency hell. Ollama turned what had been a multi-hour setup into a five-minute task, and in doing so opened local AI to a vastly larger audience. It is the layer that made &quot;AI at home&quot; feel like a real product rather than a weekend project.</p><p><strong>vLLM</strong>, developed at UC Berkeley, solved a different problem: how do you serve large language models efficiently when multiple users are making requests simultaneously? Its key innovation — <strong>PagedAttention</strong> — manages the model’s memory the way an operating system manages RAM, allowing far more concurrent requests without wasting GPU memory. While llama.cpp and Ollama target individual users, vLLM targets small teams and organizations running their own on-prem inference servers. Together, these three projects cover the full spectrum: from a single developer’s laptop to a company’s on-prem AI infrastructure.</p><p>None of these tools were built by the companies that created the underlying models. They were built by researchers, engineers, and individual contributors who believed that AI capability should not be gated behind a giant data center. The open-source ecosystem delivered on that belief.</p><p>But the gap between the best open models and the frontier models closed slowly. Running LLaMA locally meant accepting a significant quality penalty compared to GPT-4. For casual use, fine. For real work, frustrating.</p><h4><strong><em>2025–2026 — Claude Code and the New Interface</em></strong></h4><p>Step back and look at how humans have communicated with machines over the past seventy years.</p><p>In the beginning there was the <strong>command line</strong> — precise, powerful, unforgiving. You spoke the machine’s language or nothing happened. Then came the <strong>graphical interface</strong> — point, click, drag. You no longer needed to memorize syntax. Millions more people gained access to computing.</p><p>Each shift was not just a convenience improvement. It was a fundamental expansion of who could participate and how human and machine can communicate.</p><p>Natural language is the third shift. And it is different from the first two in one profound way: <strong>the machine now reasons and talks back.</strong></p><p>A command line executes. A GUI responds. But a natural language interface <em>reasons</em> — it asks clarifying questions, explains its choices, catches your contradictions, and tells you when something won’t work the way you think it will. The interface has become a conversation.</p><p>This is what Anthropic built with <strong>Claude Code</strong>. Not an autocomplete tool. Not a “vibe coding” shortcut. A genuine reasoning partner for software development — one that reads entire codebases, understands architecture, plans changes across multiple files, runs tests, interprets errors, and iterates. It operates the way a thoughtful senior engineer would: understanding context before acting, checking its own work, and pushing back when the direction is unclear.</p><p>To be precise: Claude Code runs as a CLI on your machine, but its reasoning calls go to Anthropic’s servers. It is cloud-native NDD — the ceiling that local NDD is working toward. The code it runs, the files it edits, the tests it executes — all local. The thinking happens in the cloud.</p><p>We call this pattern <strong>Natural-language Driven Development (NDD)</strong> — not because natural language replaces engineering judgment, but because it becomes the primary interface through which that judgment is expressed and acted upon. The programmer’s role shifts from writing syntax to directing intent. The machine’s role shifts from executing instructions to understanding them.</p><p>NDD is not a distant future. The benchmark in this article — the self-refine loop, the prompt logging, the benchmark script, the bug fixes — was built collaboratively with Claude Code in a single session. The human provided direction, context, and judgment. The AI provided implementation, caught its own errors, and explained every change. Neither could have produced the result as quickly alone.</p><p>That is cloud-native NDD at its best. The local version is what this article is actually about — and it is catching up.</p><h4><strong><em>2026 — Gemma 4 Brings AI Home</em></strong></h4><p>Which brings us to <strong>Gemma 4</strong>.</p><p>Google has taken everything learned from the Transformer revolution, the scaling experiments, the open model race, and the agentic breakthroughs — and distilled it into models small enough to run on modest hardware. The e2b variant has 2 billion parameters. The e4b has 4 billion.</p><p>Gemma 4 is released under the <strong>Apache 2.0 license</strong> — and this matters more than it might seem. Apache 2.0 is one of the most permissive open-source licenses in existence. It means you can download the model, use it commercially, modify it, build products with it, and distribute it — all without paying a fee or asking permission. The only requirement is attribution: acknowledge that the work originated with Google. There is no “copyleft” clause requiring you to open-source anything you build on top of it, unlike licenses such as GPL.</p><p>For AI at home, Apache 2.0 is the legal equivalent of the quantization breakthrough: it removes a barrier. You are not renting access to Gemma 4. You own a copy. You can run it in a hospital without sending patient data to a cloud. You can build a commercial product without negotiating a license. You can share it with a colleague in another country without worrying about export restrictions on proprietary software. Openness at the model level, protected by the right license, is what makes “AI at home” a durable reality rather than a temporary loophole.</p><p>The journey from that 2017 research paper to a model on your own machine took almost exactly a decade. It passed through billion-dollar compute budgets, landmark research labs, and the fastest product adoption in history. And it arrived, quietly, as a file you can download freely.</p><p>This is the story of what that actually looks like when you run it.</p><h3>What “AI at Home” Really Means</h3><p>Let’s be concrete. Running locally means the model weights sit on your machine. No internet required after setup. No API key and token charges. No data leaving your house.</p><p>The software stack is equally accessible:</p><ul><li><a href="https://ollama.com/"><strong>Ollama</strong></a> — one command to download and serve any open model locally</li><li><a href="https://github.com/langchain-ai/langgraph"><strong>LangGraph</strong></a> — Python library for building multi-step AI workflows</li><li>A task. Any task.</li></ul><p>That’s it. No cloud account. No API key. No monthly bill.</p><h3>The Experiment: Teaching AI to Improve Its Own Work</h3><p>To test what local models can actually do, we ran a classic agentic pattern called <strong>self-refine</strong> — an AI loop where the model writes something, then critiques it, then rewrites it based on its own critique, repeating until satisfied.</p><p>It looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*Vh7YkCbnN5byhoqNLlVvKg.png" /></figure><p>This is not a single prompt. It is a small agentic workflow — the model acting as both writer and editor roles, iterating toward quality. It is, in miniature, how a thoughtful person actually works.</p><p>The task we gave every model: <em>“What are the benefits of meditation?”</em></p><p>We ran it on five models: <strong>llama3.2</strong>, <strong>gemma3</strong>, <strong>gemma4:e2b</strong>, <strong>gemma4:e4b</strong>, and <strong>Claude Sonnet 4.6</strong> (via Claude Code — CLI local, inference cloud). The first four ran entirely on local hardware via Ollama. Claude served as the cloud ceiling — what the best available model produces on the same task.</p><h3>What Happened</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*m44euVQoG7iTLSJV3FZOTg.png" /></figure><p><em>All local runs via Ollama on CPU, default quantization (Q4_K_M), default sampling (temperature 0.8, top_p 0.9). Each model acted as both writer and critic — a same-model design that measures self-critique capacity; see “The Real Finding” for the methodological implication. Claude Sonnet 4.6 ran via Claude Code (cloud inference) as the ceiling — chosen over Opus for cost efficiency on a development benchmark. The 8-call models spent ~17 min total, but per-call latency is comparable to the faster models — the difference is depth of thought, not raw token speed.</em></p><p>Three things stand out immediately.</p><p>First: <strong>llama3.2 finished fastest and produced the worst output.</strong> It approved its own mediocre prose on the first critique — no suggestions, just [APPROVED]. Fast exit, zero self-criticism.</p><p>Second: <strong>gemma3 gave genuine feedback on round one, improved the draft, then approved with a list of twelve complaints.</strong> That “twelve suggestions + approved” pattern is telling: the critic can identify weaknesses but doesn’t hold itself to fixing them. One honest improvement followed by a polite exit.</p><p>Third: <strong>both gemma4 models refused to approve their own work across all three iterations.</strong> Each round produced a measurably better article, but the critic’s standard moved with the output. Seventeen minutes of relentless self-critique for the e4b. Nine for the e2b. Neither was satisfied.</p><h3>The Outputs</h3><p>Here is what each model actually produced.</p><p><strong>llama3.2</strong> wrote a nine-section article — accurate, flat, no markdown formatting. No thesis, just a list of benefits stated as facts. The critique was a single word: [APPROVED]. Not a single suggestion. The critic applied no standard at all.</p><p><strong>gemma3</strong> wrote a formatted article with science-backed framing — cortisol, neuroplasticity, MBSR for depression — structured like a wellness magazine piece. The first critique gave six actionable suggestions, and the refinement was genuine: the MBSR section gained a mechanism, the pain section expanded, and the meditation types were reorganized thematically. Then the second critique listed twelve issues and still said approved. The model identified its own weaknesses clearly — and chose to exit anyway.</p><p><strong>gemma4:e2b</strong> — a 2-billion-parameter model — wrote a genuinely professional five-section piece on the first pass: cognitive clarity, emotional regulation, physical health, mindfulness, compassion. Its structure was immediately better than any other local first draft. Then it ran three rounds of self-critique and still wouldn’t approve itself. Each iteration produced real improvements: a sharper opening (<em>“stress is no longer an occasional visitor; it is the persistent hum of modern existence”</em>), a stronger causal chain through cardiovascular health, a more direct call to action. The final article is clean, confident, and publishable. It just never satisfied its own critic.</p><p><strong>gemma4:e4b</strong> wrote the most ambitious initial draft — structured with emoji section headers, numbered sub-points, and unusually deep scientific content including the HPA axis, cortisol management, and pain gate theory. The first critique was its sharpest: remove the emojis for a professional feel, add a transitional paragraph between intro and body, explain “non-reactivity” with a concrete analogy, end with a measurable commitment. The model did all of it. Three rounds of revision transformed a listicle into a polished essay with a strong narrative voice and a specific closing challenge: <em>“For the next seven days, dedicate three minutes to mindful breathing immediately upon waking.”</em> Still not approved. The final article is the best of the local models — and the most expensive to produce.</p><p><strong>Claude Sonnet 4.6</strong> wrote a 1,600-word article on the first try. Named citations. Careful evidence qualification — distinguishing well-replicated findings from preliminary ones. A section on spiritual and existential benefits. A closing line that lands: <em>“The question is no longer whether meditation works. The question is why more people are not doing it.”</em> The critic read it and immediately said: approved.</p><h3>The Real Finding</h3><p>The most important result is not which model wrote the best article. It is this:</p><blockquote><strong>The self-critique faculty scales with model quality — and it matters more than raw generation.</strong></blockquote><p>llama3.2 has no meaningful critic at all: it approved a flat, generic draft without a single suggestion. gemma3’s critic can identify real problems but lacks the discipline to withhold approval. Both gemma4 models hold themselves to a standard they can’t quite clear in three iterations — which is actually the right behavior for a self-improvement loop. Claude sets a standard so high that its first draft clears it immediately.</p><p>The loop only improves what the critic is willing to reject. A weak critic produces fast exits and mediocre outputs. A strict critic produces better work — but costs more time. The gemma4 family is now in the “strict critic” tier, running entirely on your own hardware.</p><p>One design note: this benchmark intentionally used the same model as both writer and critic. On CPU-only hardware, swapping between two different models means unloading one set of weights and loading another — adding minutes of overhead per iteration on top of an already slow loop. Using a single model keeps the benchmark reproducible and the timing honest. The tradeoff is that each model’s critic is calibrated to its own generation capacity; a cross-model condition (gemma4 as critic on llama3.2’s draft) would be a natural extension and is on the roadmap.</p><p>One practical caveat: if the critic prompt is calibrated for a stronger model than the writer, you can get <strong>systemic perfectionism</strong> — the critic perpetually identifies problems the writer cannot fix at its current capacity, and the loop never converges. The fix is a higher max_iterations budget, a stronger writer model, or a slightly more lenient critic prompt. In our benchmark, three iterations was enough to see the pattern clearly; production use cases may need tuning.</p><p>This is a fundamentally human dynamic, playing out in a model running on your machine at home.</p><h3>Gemma 4: The Capability Threshold</h3><p>The gap between gemma3 and gemma4:e2b — at roughly the same parameter count — is striking. Both are “small” models by current standards. But gemma4:e2b’s first draft was immediately better than gemma3’s best refined output.</p><p>More importantly: <strong>the self-critical faculty in both gemma4 variants is qualitatively different from gemma3.</strong> It doesn’t just suggest surface polish. It identifies structural problems — transitions, argument flow, the relationship between sections, whether the conclusion earns its tone. It asks whether the evidence chain is causal or merely correlational. That is a form of reasoning, not just generation. And critically, it refuses to approve work that doesn’t meet that standard — even after multiple rounds of revision. That’s a harder discipline than simply writing well.</p><p>This is what “Claude Code capability at home” means in practice. Not that gemma4 equals Claude — it doesn’t, not yet. But the <em>type</em> of reasoning — multi-step, self-correcting, iterative — is now available on your own hardware, at a quality level that is genuinely useful.</p><h3>The Stack Anyone Can Run</h3><p>Here is the complete <strong>LangGraph</strong> implementation of the self-refine pattern — the actual code we used:</p><pre>from langchain_ollama import ChatOllama<br>from langgraph.graph import END, StateGraph<br>from typing import TypedDict<br><br>DRAFT_PROMPT = &quot;&quot;&quot;You are a professional writer. Write a comprehensive article on the topic below.<br>Output only the article — no preamble, no notes after.<br><br>Topic: {task}&quot;&quot;&quot;<br><br>CRITIQUE_PROMPT = &quot;&quot;&quot;You are a professional editor. If the article needs no further improvement,<br>reply with exactly: [APPROVED]<br><br>Otherwise output a numbered list of specific, actionable improvements. Nothing else.<br><br>ARTICLE:<br>{current}<br><br>IMPROVEMENTS:<br>1.&quot;&quot;&quot;<br><br>REFINE_PROMPT = &quot;&quot;&quot;You are a seasoned writer. Rewrite the draft incorporating the feedback.<br>Stay true to the original topic: {task}<br>Output only the rewritten article — no preamble, no notes after.<br><br>DRAFT:<br>{current}<br><br>FEEDBACK:<br>{feedback}&quot;&quot;&quot;<br><br>class RefineState(TypedDict):<br>    task: str<br>    max_iterations: int<br>    writer_model: str<br>    critic_model: str<br>    current: str<br>    feedback: str<br>    iteration: int<br><br>def _invoke(model, prompt):<br>    return ChatOllama(model=model).invoke(prompt).content.strip()<br><br>def node_draft(state):<br>    return {&quot;current&quot;: _invoke(state[&quot;writer_model&quot;],<br>                               DRAFT_PROMPT.format(task=state[&quot;task&quot;])),<br>            &quot;iteration&quot;: 0}<br><br>def node_critique(state):<br>    return {&quot;feedback&quot;: _invoke(state[&quot;critic_model&quot;],<br>                                CRITIQUE_PROMPT.format(current=state[&quot;current&quot;]))}<br><br>def node_refine(state):<br>    i = state[&quot;iteration&quot;] + 1<br>    return {&quot;current&quot;: _invoke(state[&quot;writer_model&quot;],<br>                               REFINE_PROMPT.format(task=state[&quot;task&quot;],<br>                                                    current=state[&quot;current&quot;],<br>                                                    feedback=state[&quot;feedback&quot;])),<br>            &quot;iteration&quot;: i}<br><br>def _route(state):<br>    if &quot;[APPROVED]&quot; in state[&quot;feedback&quot;]:<br>        return &quot;commit&quot;<br>    if state[&quot;iteration&quot;] &gt;= state[&quot;max_iterations&quot;]:<br>        return &quot;commit&quot;<br>    return &quot;refine&quot;<br><br>g = StateGraph(RefineState)<br>g.add_node(&quot;draft&quot;,    node_draft)<br>g.add_node(&quot;critique&quot;, node_critique)<br>g.add_node(&quot;refine&quot;,   node_refine)<br>g.add_node(&quot;commit&quot;,   lambda s: s)<br>g.set_entry_point(&quot;draft&quot;)<br>g.add_edge(&quot;draft&quot;, &quot;critique&quot;)<br>g.add_conditional_edges(&quot;critique&quot;, _route,<br>                         {&quot;commit&quot;: &quot;commit&quot;, &quot;refine&quot;: &quot;refine&quot;})<br>g.add_edge(&quot;refine&quot;, &quot;critique&quot;)<br>g.add_edge(&quot;commit&quot;, END)<br>graph = g.compile()</pre><p>To run it:</p><pre># install dependencies<br>pip install langgraph langchain-ollama click <br><br># download model<br>ollama pull gemma4:e2b <br><br># run workflow<br>python self_refine.py \<br> --task &quot;What are the benefits of meditation?&quot; \<br> --max-iterations 3 \<br> --writer-model gemma4:e2b \<br> --critic-model gemma4:e2b</pre><p>That is the complete picture. A multi-step agentic workflow, running entirely on your machine, on a model that fits in a few gigabytes of RAM.</p><h3>AI Has Come Home</h3><p>Think about what this means beyond a benchmark.</p><p>A <strong>village health worker</strong> with a laptop and a local model can generate, critique, and refine patient education materials in any language — without sending sensitive data to any cloud.</p><p>A <strong>small business owner</strong> can run an AI writing assistant that drafts, reviews, and improves communications — offline, privately, for free after setup.</p><p>A <strong>student in a low-bandwidth region</strong> can run a tutor that explains a concept, critiques their understanding, and re-explains — without a reliable internet connection.</p><p>A <strong>developer in a garage</strong> can build and deploy AI-powered applications without a cloud budget, without rate limits, without worrying about API terms of service changes.</p><p>None of this requires a breakthrough. It requires Ollama, a model called Gemma 4 that is free to download today, and hardware you can buy on Amazon for $500.</p><p>One honest caveat on throughput: on CPU-only hardware, a full self-refine loop takes several minutes per task. For high-volume use cases, a consumer GPU (an NVIDIA RTX 3060 runs around $250) reduces generation time by 5–10×, bringing single-pass responses to seconds. The $500 mini-PC is the entry point — not the optimal configuration. The vision is real; the latency or speed of inference depends on your hardware budget.</p><h3>What’s Coming: SPL 3.0</h3><p>The LangGraph code above works. But notice how much of it is plumbing — state management, graph edges, routing logic. The actual intent — <em>draft, critique, refine until approved</em> — is buried inside the implementation.</p><p>We are building <strong>SPL (Structured Prompt Language) 3.0</strong>, a declarative language for agentic AI workflows. The same self-refine pattern in SPL looks like this:</p><pre>-- SPL script equivalent to LangGraph python code<br>WORKFLOW self_refine<br>  INPUT: @task TEXT, @writer_model TEXT, @critic_model TEXT<br>  OUTPUT: @result TEXT<br>DO<br>  GENERATE draft(@task) USING MODEL @writer_model INTO @current<br><br>  WHILE @iteration &lt; @max_iterations DO<br>    CALL critique_workflow(@current, @critic_model) INTO @feedback<br>    -- the intelligence lives here<br>    EVALUATE @feedback                         <br>      WHEN contains(&#39;[APPROVED]&#39;) THEN<br>        RETURN @current WITH status = &#39;complete&#39;<br>      ELSE<br>        GENERATE refined(@task, @current, @feedback)<br>          USING MODEL @writer_model INTO @current<br>    END<br>  END<br><br>  RETURN @current WITH status = &#39;max_iterations&#39;<br>END</pre><p>SQL-like clarity. No state boilerplate. Model names as runtime parameters. The orchestration reads like a specification, not an implementation.</p><p>To run it:</p><pre>spl3 run self_refine.spl \<br> --adapter ollama \<br> --param task=&quot;What are the benefits of meditation?&quot; \<br> --param max-iterations=3 \<br> --param writer-model=&quot;gemma4:e2b&quot; \<br> --param critic-model=&quot;gemma4:e2b&quot;</pre><p>SPL 3.0 is experimental and under active development. LangGraph is the baseline today — reproducible, stable, production-ready. SPL is where this is going: agentic AI workflows that anyone can read, write, and reason about.</p><h3>The Takeaway</h3><p>The AI that once lived only in data centers — capable of multi-step reasoning, self-critique, iterative improvement — now runs on the machine in your home. Not perfectly. Not at the level of the best cloud models. But well enough to be genuinely useful, and improving with every model release.</p><p>Gemma 4 is not the end of this story. It is the beginning of a different chapter: the one where AI stops being a service you subscribe to and starts being a capability you own.</p><p>Your garage. Your village. Your workplace.</p><p>The artificial intelligence is at home.</p><h3>References</h3><ol><li>Vaswani, A. et al. (2017). <strong>Attention Is All You Need.</strong> <em>arXiv:1706.03762.</em> <a href="https://arxiv.org/abs/1706.03762">https://arxiv.org/abs/1706.03762</a></li><li>Meta AI. (2023). <strong>LLaMA: Open and Efficient Foundation Language Models.</strong> <em>arXiv:2302.13971.</em> <a href="https://arxiv.org/abs/2302.13971">https://arxiv.org/abs/2302.13971</a></li><li>Gerganov, G. et al. <strong>llama.cpp</strong> — LLM inference in plain C/C++. <a href="https://github.com/ggml-org/llama.cpp">https://github.com/ggml-org/llama.cpp</a></li><li><strong>Ollama</strong> — Get up and running with large language models locally. <a href="https://ollama.com/">https://ollama.com</a> · <a href="https://github.com/ollama/ollama">https://github.com/ollama/ollama</a></li><li>Kwon, W. et al. (2023). <strong>Efficient Memory Management for Large Language Model Serving with PagedAttention.</strong> <em>SOSP 2023.</em> <a href="https://arxiv.org/abs/2309.06180">https://arxiv.org/abs/2309.06180</a> · <a href="https://github.com/vllm-project/vllm">https://github.com/vllm-project/vllm</a></li><li>Google DeepMind. (2026). <strong>Gemma 4: Byte for byte, the most capable open models.</strong> <a href="https://blog.google/innovation-and-ai/technology/developers-tools/gemma-4/">https://blog.google/innovation-and-ai/technology/developers-tools/gemma-4/</a></li><li>Anthropic. <strong>Claude Code</strong> — The agentic coding tool. <a href="https://docs.anthropic.com/en/docs/claude-code">https://docs.anthropic.com/en/docs/claude-code</a></li><li>LangChain. <strong>LangGraph</strong> — Build resilient language agents as graphs. <a href="https://github.com/langchain-ai/langgraph">https://github.com/langchain-ai/langgraph</a></li><li>Gong, Wen G. (2026). <strong>Structured Prompt Language (SPL): Declarative Context Management for LLMs</strong> <em>arXiv:2602.21257.</em> <a href="https://arxiv.org/abs/2602.21257">https://arxiv.org/abs/2602.21257</a></li><li><strong>SPL 3.0</strong> — Source code, cookbook, and self-refine benchmark. <a href="https://github.com/digital-duck/SPL30">https://github.com/digital-duck/SPL30</a></li></ol><p><strong>Note: </strong><em>All local model runs used Ollama on a $500 Intel mini-PC running Ubuntu 24.04, CPU only. With dedicated GPU (even consumer-grade), the latency will be much shorter. Claude Sonnet 4.6 ran via Claude Code (claude_cli adapter over subscription account, no per-token billing during development.)</em></p><h4>Author</h4><p><em>Wen G. Gong is a former physics post-doc at Lawrence Berkeley National Laboratory and a data/AI engineer with 20+ years of experience across SQL, Oracle, and enterprise data systems. He is the author of SPL (Structured Prompt Language) and SPL-flow. He can be reached at </em><a href="/service/mailto:wen.gong.research@gmail.com"><em>wen.gong.research@gmail.com</em></a><em>.</em></p><p><em>© 2026 Wen G. Gong. Licensed under CC BY 4.0. Share freely with attribution.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=369fa8c27e2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Momahub Moment]]></title>
            <link>https://medium.com/@wen.g.gong/the-momahub-moment-df852c42f3da?source=rss-7b5395ada3ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/df852c42f3da</guid>
            <category><![CDATA[structured-prompts]]></category>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[physics]]></category>
            <category><![CDATA[gamer]]></category>
            <category><![CDATA[decentralized-gpu-network]]></category>
            <dc:creator><![CDATA[W Gong]]></dc:creator>
            <pubDate>Mon, 09 Mar 2026 01:46:28 GMT</pubDate>
            <atom:updated>2026-03-09T03:30:51.637Z</atom:updated>
            <content:encoded><![CDATA[<h3>Physics Labs and the Infrastructure of Human Connection</h3><p>There is a pattern in the history of technology that almost nobody talks about.</p><p>The most transformative public infrastructure of the modern era — the infrastructure that democratized entire domains of human activity — did not come from commercial incentive. It came from <strong>physics labs</strong>.</p><p>In 1989, <a href="https://en.wikipedia.org/wiki/Tim_Berners-Lee">Tim Berners-Lee</a> was a software engineer at <a href="https://home.cern/"><strong>CERN</strong></a> — the European particle physics laboratory in Geneva. The problem he was trying to solve was mundane: physicists at CERN generated enormous amounts of data and struggled to share it across institutions, computers, and continents. His proposal was called <a href="https://www.w3.org/History/1989/proposal.html">”Information Management: A Proposal”</a>. His supervisor’s response, written in the margin:<em>”Vague but exciting.”</em></p><p>That vague, exciting proposal became the <strong>World Wide Web</strong>.</p><p>CERN did not set out to build the infrastructure of human knowledge. It set out to study quarks. The Web was a side effect — an act of physics-lab problem-solving that happened to change everything.</p><p>A decade later, in 1999, another physics lab did it again.</p><h3>A Memory from Berkeley, 1999</h3><p>I was a physics post-doc at <a href="https://www.lbl.gov/"><strong>Lawrence Berkeley National Laboratory</strong></a> — the same institution that discovered plutonium, built the first cyclotron, and gave the world the standard model of particle physics — when <a href="https://setiathome.berkeley.edu/">SETI@home</a> launched in May 1999.</p><p>The idea was almost absurdly simple: the search for extraterrestrial intelligence required an enormous amount of signal processing — more than any single university computing cluster could handle. So Berkeley asked for help. Not people’s money. Not their expertise. Just their <strong>idle CPU cycles</strong>.</p><p>Five million people said yes.</p><p>Their screensavers flickered to life with visualizations of radio telescope data being crunched in the background — while people slept, while they made coffee, while they were in meetings. Over 21 years, those contributing computers collectively processed data that no institution could have afforded to process alone.</p><p>In January 2026, the Berkeley team announced that this community-powered analysis had winnowed <a href="https://setiathome.berkeley.edu/"><strong>12 billion detections down to 100 candidate signals</strong></a> — now being followed up with <a href="https://www.wikiwand.com/en/Five-hundred-meter_Aperture_Spherical_Telescope">China’s FAST telescope</a>, the most sensitive radio telescope ever built.</p><p>The contributors did real science. The model worked.</p><p>I was inside that lab when it launched. I watched it happen.</p><p>I have been thinking about that moment a lot lately. Because I believe something structurally similar — but economically far more significant — is about to happen to AI.</p><h3>The Pattern</h3><p><a href="https://home.cern/">CERN</a> did not build the Web to make money. <a href="https://www.lbl.gov/">LBL</a> did not build <a href="https://setiathome.berkeley.edu/">SETI@home</a> to disrupt the computing industry. In both cases, physicists faced a data problem that no existing infrastructure could solve — and built something new.</p><p>The Web democratized <strong>information</strong>: knowledge that once lived in university libraries and corporate archives became universally reachable, at near-zero marginal cost, to anyone with a connection.</p><p>SETI@home democratized <strong>scientific computing</strong>: processing power that once required institutional supercomputers became collectively achievable by aggregating idle cycles from millions of participants.</p><p>But the pattern goes deeper than two examples. In 1983, <a href="https://en.wikipedia.org/wiki/Richard_Stallman">Richard Stallman</a> gave up his position at the <a href="https://www.csail.mit.edu/">MIT AI Lab</a> to launch the <a href="https://www.gnu.org/gnu/manifesto.html">GNU Project</a> — the founding act of the open-source software movement. His manifesto, published in 1985, made a case that software itself should be a commons: auditable, improvable, and redistributable by anyone. He was not building a product. He was building a principle.</p><p>I arrived in the United States in 1985 — the same year that manifesto appeared. Reading Stallman’s story planted something. I watched Linux follow from it. Then Apache, MySQL, PostgreSQL. A generation of open-source infrastructure emerged and became the silent foundation under almost everything we use.</p><p>GNU/Linux democratized the <strong>operating system</strong>: the software layer that once ran only on machines you licensed from IBM or Sun became collectively buildable, ownable, and freely redistributable.</p><p>All three revolutions followed the same logic: the asset already existed (knowledge, computing cycles, software), scattered and underutilized or artificially restricted. The innovation was a <strong>protocol</strong> — a coordination layer, or a legal framework, or a distributed network — that made the latent value collectively accessible.</p><p>We are not starting from scratch. We are a molecule in a cluster that has been building for forty years.</p><h3>The Problem Worth Solving</h3><p>The AI industry is building the most expensive infrastructure in human history.</p><p>Frontier AI labs — <a href="https://openai.com/">OpenAI</a>, <a href="https://deepmind.google/">Google DeepMind</a>, <a href="https://www.anthropic.com/">Anthropic</a>, <a href="https://ai.meta.com/">Meta AI</a> — are racing to build ever-larger models that require ever-larger context windows, which require ever-larger data centers, which require ever-larger energy budgets. <a href="https://www.microsoft.com/">Microsoft</a> and <a href="https://openai.com/">OpenAI</a> announced a $500 billion data center investment. Governments are writing energy policy around AI power consumption. The <a href="https://www.mitsloantechsummit.com/">MIT Sloan AI/Tech Summit</a> I attended in early 2026 had “Energy Bottleneck” as its central theme.</p><p>The result: AI capability is rationed by ability to pay. You bring your data to their compute. You pay per token. You depend on their uptime, their pricing, their terms of service.</p><h3>The Scenario We Must Not Wait For</h3><p>In February 2026, Citrini Research published a thought exercise called <a href="https://www.citriniresearch.com/p/2028gic">“The 2028 Global Intelligence Crisis”</a> — a fictional macro memo written from June 2028, looking back at how everything went wrong. It is not a prediction. It is a scenario. And it should keep you up at night.</p><p>The thesis: AI works. It works so well that it triggers a negative feedback loop with no natural brake. Companies adopt AI agents that are faster, cheaper, and more reliable than white-collar workers. Margins expand. Stocks rally. Corporate profits reach record highs.</p><p>The result: <strong>Ghost GDP</strong> — output that shows up in national accounts but never circulates through the real economy.</p><h3>The Gamers Who Built Nvidia</h3><p><a href="https://www.nvidia.com/">Nvidia</a> is today the most valuable company on Earth, worth over $3 trillion. How did it get here? Not through data centers. Through <strong>gamers</strong>.</p><p>The people who built Nvidia’s business already own the hardware. What they lack is a coordination layer that lets them <strong>put that hardware to work — and earn from it.</strong></p><p>There are an estimated <strong>50–100 million consumer GPUs</strong> in gaming PCs and workstations worldwide right now. RTX 4070s, 4080s, 4090s, GTX 1080 Tis, M2 and M3 MacBooks. They are already purchased. They are already powered on. They are already drawing electricity whether their owners use them or not.</p><p>And every one of them can run <a href="https://ollama.com/">Ollama</a>.</p><h3>We, the Users, Have a Choice</h3><p>There is another path — one where the compute is distributed, where GPU owners are participants rather than casualties, where the value created by AI inference flows to millions of households rather than a handful of data center operators.</p><p>The infrastructure for that path already exists:</p><ol><li><strong>Open-weight models</strong> — <a href="https://llama.meta.com/">Llama</a>, <a href="https://github.com/QwenLM/Qwen">Qwen</a>, <a href="https://mistral.ai/">Mistral</a>, <a href="https://www.deepseek.com/">DeepSeek</a> <em>(already here)</em></li><li><strong>A local inference runtime</strong> — <a href="https://ollama.com/">Ollama</a> <em>(already here)</em></li><li><strong>50–100 million consumer GPUs</strong> — in gaming PCs worldwide <em>(already purchased)</em></li><li><strong>A declarative orchestration layer</strong> — <a href="https://arxiv.org/abs/2602.21257">SPL</a> <em>(available now, open-source)</em></li><li><strong>A coordination and reward platform</strong> — <a href="https://pypi.org/project/momahub/">Momahub</a> <em>(v0.2.5 published to PyPI)</em></li></ol><p>We do not need permission from <a href="https://www.nvidia.com/">Nvidia</a>, or <a href="https://openai.com/">OpenAI</a>, or any frontier lab. We do not need to wait for government policy. We do not need new hardware. We need a protocol that connects what already exists.</p><p>We propose <a href="https://pypi.org/project/momahub/">Momahub</a> as that coordination protocol and community layer — one more step in a tradition forty years in the making, not the first act, but hopefully a meaningful continuation.</p><h3>Proven Performance: The 3-GPU Milestone</h3><p>This isn’t just theory. On <strong>March 8, 2026</strong>, we validated the Momahub architecture in a real-world LAN deployment. Two <strong>NVIDIA GTX 1080 Ti</strong> (11GB VRAM each) and one <strong>NVIDIA GTX 1050 Ti</strong> (4GB VRAM) ran as a three-node grid — hub-and-spoke, fully automated — with 14/14 cookbook recipes completing successfully.</p><p>Here are measured results from the run:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*oR8BmoYP-04Gbdsm9RxWYQ.png" /></figure><p>The nodes didn’t just contribute — they functioned as a coherent, programmable compute surface. Load was automatically balanced between a PLATINUM-tier and a GOLD-tier node with zero manual configuration.</p><p>The full cookbook with source code and logs is available at: <a href="https://github.com/digital-duck/momahub.py/tree/main/cookbook">github.com/digital-duck/momahub.py/tree/main/cookbook</a></p><h3>What Is Momahub?</h3><p>Momahub — <strong>Mixture of Models on Ollama</strong> — is four things braided together:</p><p><strong>MoM — Mixture of Models.</strong> Specialist models coordinated by a single declarative script.</p><p><strong>Ollama — Open, Privacy-first, Local LLM inference.</strong> An open-source runtime for open-weight models.</p><p><strong>SPL — Structured Prompt Language.</strong> The declarative orchestration layer ( <a href="https://arxiv.org/abs/2602.21257">arXiv:2602.21257</a>).</p><p><strong>Momahub — The distributed inference platform.</strong> Modelled after <a href="https://hub.docker.com/">Docker Hub</a> and <a href="https://github.com/">GitHub</a>, where owners of <em>already purchased, already powered, already idle</em> GPUs can <strong>participate economically in the AI transition</strong>.</p><p>The diagram below shows how these four layers compose into a full pipeline — from a plain-English request down to parallel specialist models running across community nodes at four tiers of scale:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/0*heB08AXMRuGQmSkm.png" /></figure><h3>Momahub Rewards: Distributed Prosperity</h3><p>Momahub Rewards is designed to test a counter-model: what happens when AI compute value flows to millions of distributed GPU owners instead of a handful of data center operators?</p><p>The economic model is not new. In 2009, <a href="https://en.wikipedia.org/wiki/Uber">Travis Kalanick and Garrett Camp</a> asked: what if your car could earn money between trips? In 2008, <a href="https://en.wikipedia.org/wiki/Airbnb">Brian Chesky and Joe Gebbia</a> asked: what if your spare room could pay rent? Both companies unlocked billions of dollars of latent value from assets people already owned. Momahub asks the same question about the GPU in your gaming PC.</p><p>Every time a Momahub node processes an inference task, the hub records the work in an append-only reward ledger. One credit per 1,000 tokens. No blockchain waste. The “proof” is the useful inference itself.</p><h3>The Energy Argument</h3><p>An RTX 4090 running Llama 3.1 8B uses roughly <strong>150W under load</strong>. An overnight run (8 hours) consumes 1.2 kWh — about<strong>$0.15</strong> at average US electricity prices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*jngXhB4pbyykZVgTC1GDDQ.png" /></figure><p>The consumer GPU is <strong>6× to 20× cheaper</strong> for equivalent inference volume.</p><h3>What the Code Actually Looks Like</h3><p>SPL is an SQL-inspired language to manage context as resource. Here is the script that ran on our 3-GPU grid for the chain relay recipe — three reasoning steps dispatched automatically across available agents:</p><pre>-- chain.spl: multi-step reasoning pipeline<br>PROMPT research_chain<br>USING MODEL &#39;llama3&#39;<br>ON GRID<br>WITH research AS (<br>    SELECT system_role(&#39;You are a research assistant.&#39;)<br>    GENERATE llm(&#39;Research the topic: quantum computing. Key facts and trends.&#39;)<br>),<br>analysis AS (<br>    SELECT system_role(&#39;You are a critical analyst.&#39;)<br>    GENERATE llm(&#39;Analyze the key challenges: &#39; || research.output)<br>),<br>summary AS (<br>    SELECT system_role(&#39;You are a concise technical writer.&#39;)<br>    GENERATE llm(&#39;Summarize in 3 bullet points: &#39; || analysis.output)<br>)<br>SELECT summary.output;</pre><p>Each CTE ( research, analysis, summary) is dispatched as an independent task. The hub routes each to the best available GPU agent node. The.spl file is identical whether run locally, against a cloud API, or across the community grid. Here, CTE stands for Common Table Expression in the SQL standard, it expresses a unit of work in data processing or prompt engineering.</p><h3>Where to Start</h3><p>If you want to run SPL today — on your own machine, with Ollama, at zero cost:</p><pre>pip install spl-llm      # SPL engine<br>pip install spl-flow     # Agentic orchestration layer<br><br>ollama pull llama3.1     # One-time model download <br><br>spl init<br>spl execute examples/hello_world.spl</pre><p>If you want to run your own hub node (e.g. on a home server or LAN):</p><pre>pip install momahub<br><br># Start a local hub<br>moma hub up --host 0.0.0.0 --port 8000</pre><p>If you prefer to join an existing public hub instead:</p><pre>pip install momahub<br><br># Join a public hub as a contributing agent (requires Ollama running locally)<br>moma join http://&lt;hub-ip&gt;:8000<br><br># Monitor your contribution and credits<br>moma status<br>moma rewards<br><br>moma --help</pre><blockquote>We are <strong>not</strong> building an alternative to frontier AI labs — we are building the community layer that makes AI infrastructure more accessible: as decentralized as the Internet, as open and cost-free as Linux, and as economically inclusive as the Uber economy.</blockquote><h3>References</h3><p><strong>Open-Source &amp; Historical Movements</strong></p><p><a href="https://en.wikipedia.org/wiki/Richard_Stallman">Richard M. Stallman</a>, <a href="https://www.gnu.org/gnu/manifesto.html"><em>The GNU Manifesto</em></a>, Dr. Dobb’s Journal (March 1985).<em>(Stallman announced the GNU Project in September 1983 and resigned from the </em><a href="https://www.csail.mit.edu/"><em>MIT AI Lab</em></a><em> in January 1984 to pursue it full-time.)</em></p><p><a href="https://en.wikipedia.org/wiki/Tim_Berners-Lee">Tim Berners-Lee</a>, <a href="https://www.w3.org/History/1989/proposal.html"><em>Information Management: A Proposal</em></a>, <a href="https://home.cern/">CERN</a> (March 1989).</p><p><a href="https://setiathome.berkeley.edu/">UC Berkeley SETI Research Center</a></p><p><strong>The Gig Economy Precedents</strong></p><p><a href="https://en.wikipedia.org/wiki/Uber">Uber</a> — founding story (2009), Travis Kalanick and Garrett Camp, San Francisco.</p><p><a href="https://en.wikipedia.org/wiki/Airbnb">Airbnb</a> — founding story (2008), Brian Chesky, Joe Gebbia, and Nathan Blecharczyk, San Francisco.</p><p><strong>Blogs, Codes &amp; Papers</strong></p><p>Citrini Research and Alap Shah, <a href="https://www.citriniresearch.com/p/2028gic"><em>The 2028 Global Intelligence Crisis: A Thought Exercise in Financial History, from the Future</em></a> (February 2026).</p><p>Wen G. Gong, <a href="https://arxiv.org/abs/2602.21257"><em>SPL: Structured Prompt Language for Generative AI</em></a>, arXiv:2602.21257 (2026).</p><p><a href="https://github.com/digital-duck/momahub.py/tree/main/cookbook">Momahub Cookbook</a> — 14 validated recipes with logs and HTML reports, Apache 2.0.</p><p><em>The author is a former physics post-doc at Lawrence Berkeley National Laboratory (LBNL) and a data/AI engineer with 20+ years of experience across SQL, Oracle, and enterprise data systems. He can be reached at </em><a href="/service/mailto:wen.gong.research@gmail.com"><em>wen.gong.research@gmail.com</em></a><em>.</em></p><p><em>© 2026 Wen G. Gong. This blog is licensed under CC BY 4.0. Share freely with attribution.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df852c42f3da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an AI-Powered LLM Finder]]></title>
            <link>https://medium.com/@wen.g.gong/building-an-ai-powered-llm-finder-afc6b3d6f8dd?source=rss-7b5395ada3ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/afc6b3d6f8dd</guid>
            <dc:creator><![CDATA[W Gong]]></dc:creator>
            <pubDate>Sun, 27 Jul 2025 19:06:47 GMT</pubDate>
            <atom:updated>2025-07-28T04:24:00.951Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How we solved the LLM selection problem with a Streamlit app that transforms 320+ models into actionable business intelligence</em></p><h3><strong>🎯 The Problem of Too Many Choices</strong></h3><p>Every AI developer faces the same overwhelming question: <strong>”<em>Which LLM should I use?</em>”</strong></p><p>With 320+ models from 68+ providers, costs ranging from free to $0.000003/1M tokens, and new models launching weekly, choosing the right LLM has become a critical business decision that can make or break your AI project’s ROI.</p><p>The hidden costs of wrong choices:</p><pre>- 🔥 Budget overruns: Using GPT-4 when a free model would suffice<br>- ⚡ Performance gaps: Choosing a cheap model that can&#39;t handle your use case<br>- 🕐 Time waste: Manually researching dozens of models for each project<br>- 📊 Missed opportunities: Not knowing about powerful free alternatives</pre><p>We built <a href="https://github.com/digital-duck/llm_finder"><strong>LLM Finder</strong></a> to solve this exact problem — and the results speak for themselves.</p><h3><strong>💡 What We Built: From 30-Minute Prototype to Production Tool</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4QrVZh9hGmRo8J9S0O6gkg.png" /></figure><p><strong>LLM Finder</strong> started as a simple data parsing exercise and evolved into a comprehensive business intelligence platform for AI model selection.</p><h3><strong>The Journey: Rapid Evolution</strong></h3><pre>- Hour 1: Messy OpenRouter data → Clean, structured dataset<br>- Hour 2: Basic Streamlit dashboard → Interactive analytics<br>- Hour 3: Keyword search → AI-powered semantic search<br>- Day 2: Single page → Multi-page professional application<br>- Day 3: Static data → Live API integration</pre><p><strong>Core Capabilities:</strong></p><pre>- 🤖 AI-powered chat interface for natural language model queries<br>- 🔍 Advanced filtering by provider, cost, capabilities, and use case<br>- 📊 Market intelligence with cost analysis and provider comparisons<br>- 💡 Smart recommendations based on your specific needs<br>- 📥 Live data sync from OpenRouter&#39;s 320+ model catalog</pre><h3><strong>📈 Immediate Business Value: Real Results</strong></h3><p><strong>💰 Cost Optimization Insights</strong></p><p>Our analysis of 320+ models reveals massive cost-saving opportunities:</p><p><strong>Key Market Findings:</strong></p><pre>- 55 models (17.2%) are completely free - perfect for development and testing<br>- Budget tier models (≤$0.000001/1M): 74 options for cost-conscious projects<br>- Premium models (&gt;$0.000002/1M): Only 65 models - use sparingly for critical tasks</pre><p><strong>🎯 Strategic Provider Intelligence</strong></p><p><strong>Market Leaders Revealed:</strong></p><pre>- Mistral: 35 models (aggressive volume strategy)<br>- OpenAI: 35 models (ecosystem dominance play)<br>- Qwen: 28 models + 10 free options (accessibility-first approach)<br>- Google: 25 models + 7 free (market penetration strategy)</pre><p><strong>For procurement teams:</strong> Diversify across providers to avoid vendor lock-in and leverage competitive pricing.</p><p><strong>⚡ Natural Language Model Discovery</strong></p><p><strong>AI Chat Interface Example:</strong></p><pre>👤 User: &quot;What are the cheapest models for code generation?&quot;<br>🤖 Assistant: Here are some affordable options:<br>• Coder 32B Instruct (free) by Qwen2.5 - $0/1M<br>• Qwen3 Coder (free) by Qwen - $0/1M<br>• Codex Mini by OpenAI - $0.000015/1M<br>💡 Tip: DeepSeek and OpenAI models are particularly strong for code generation!</pre><p><strong>Business Impact:</strong> Reduce model selection time from hours to minutes with intelligent recommendations.</p><h3><strong>🛠 The Technical Journey: From Messy Data to Smart Insights</strong></h3><p><strong>Challenge 1: Inconsistent Data Format</strong></p><p><strong>The problem: </strong>OpenRouter model descriptions came in chaotic formats:</p><pre>&quot;Meta: Llama 3.2 11B Vision Instruct (free) ($0/1M)&quot;<br>&quot;Midnight Rose 70B ($0.0000008/1M)&quot;  <br>&quot;Mistral: Magistral Medium 2506 (thinking) ($0.000002/1M)&quot;</pre><p>Notice the inconsistencies:</p><pre>- Some have colons, others don&#39;t<br>- Multiple parenthetical expressions<br>- Varying cost formats<br>- Different provider naming conventions</pre><p><strong>Our solution:</strong> Flexible parsing logic that handles format variations:</p><pre>def parse_openrouter_model(description):<br>    &quot;&quot;&quot;Parse any OpenRouter model description format&quot;&quot;&quot;<br>    description = description.strip().strip(&quot;&#39;\&quot;&quot;)<br>    <br>    if &quot;:&quot; in description:<br>        # Format: &quot;Provider: Model Name (extras) (cost)&quot;<br>        parts = description.split(&quot;:&quot;, 1)<br>        llm_provider = parts[0].strip()<br>        remaining_text = parts[1].strip()<br>        <br>        # Find the last occurrence of parentheses for cost<br>        last_paren_start = remaining_text.rfind(&quot;(&quot;)<br>        if last_paren_start != -1:<br>            model_name = remaining_text[:last_paren_start].strip()<br>            cost_part = remaining_text[last_paren_start:]<br>            model_cost = cost_part[1:-1] if cost_part.startswith(&quot;(&quot;) and cost_part.endswith(&quot;)&quot;) else cost_part<br>        else:<br>            model_name = remaining_text<br>            model_cost = &quot;Unknown&quot;<br>    else:<br>        # Format: &quot;Provider Model Name (cost)&quot;<br>        parts = description.split(&quot; &quot;)<br>        llm_provider = parts[0]<br>        <br>        # Progressive fallback logic...<br>        if parts[-1].startswith(&quot;(&quot;) and parts[-1].endswith(&quot;)&quot;):<br>            model_cost = parts[-1][1:-1]<br>            model_name = &quot; &quot;.join(parts[1:-1])<br>        else:<br>            model_name = &quot; &quot;.join(parts[1:])<br>            model_cost = &quot;Unknown&quot;<br>    <br>    return {<br>        &#39;provider&#39;: llm_provider,<br>        &#39;model_name&#39;: model_name,<br>        &#39;cost&#39;: model_cost<br>    }</pre><p><strong>Key Insights:</strong></p><pre>- **Flexibility over precision**: Handle 90% of cases gracefully rather than 100% perfectly<br>- **Progressive fallbacks**: Multiple parsing strategies for different formats<br>- **Real-world resilience**: Built for messy, inconsistent data<br>- **Result:** 99.7% parsing accuracy across 320+ models.</pre><p><strong>Challenge 2: Making Data Searchable with AI</strong></p><p><strong>The problem:</strong> Users think in concepts (“affordable coding assistant”), not keywords.</p><p><strong>Our solution:</strong> Semantic search with sentence transformers:</p><pre>from sentence_transformers import SentenceTransformer<br>from sklearn.metrics.pairwise import cosine_similarity<br><br>@st.cache_resource<br>def load_embedding_model():<br>    return SentenceTransformer(&#39;all-MiniLM-L6-v2&#39;)<br><br>@st.cache_data<br>def create_embeddings(df):<br>    &quot;&quot;&quot;Create searchable embeddings for each model&quot;&quot;&quot;<br>    model = load_embedding_model()<br>    <br>    # Create rich text descriptions<br>    model_texts = []<br>    for _, row in df.iterrows():<br>        text = f&quot;{row[&#39;model_name&#39;]} by {row[&#39;provider&#39;]}. &quot;<br>        text += f&quot;Cost: {row[&#39;cost&#39;]}. &quot;<br>        text += f&quot;{&#39;Free model&#39; if row[&#39;is_free_bool&#39;] else &#39;Paid model&#39;}. &quot;<br>        <br>        # Add inferred capabilities based on model name<br>        name_lower = row[&#39;model_name&#39;].lower()<br>        if &#39;vision&#39; in name_lower:<br>            text += &quot;Supports vision and image analysis. &quot;<br>        if &#39;code&#39; in name_lower:<br>            text += &quot;Optimized for code generation. &quot;<br>        if &#39;chat&#39; in name_lower:<br>            text += &quot;Designed for conversation. &quot;<br>            <br>        model_texts.append(text)<br>    <br>    # Generate embeddings<br>    embeddings = model.encode(model_texts)<br>    return embeddings, model_texts<br><br>def semantic_search(query, df, embeddings, top_k=5):<br>    &quot;&quot;&quot;Perform semantic search on models&quot;&quot;&quot;<br>    query_embedding = model.encode([query])<br>    similarities = cosine_similarity(query_embedding, embeddings)[0]<br>    top_indices = np.argsort(similarities)[::-1][:top_k]<br>    <br>    results = df.iloc[top_indices].copy()<br>    results[&#39;similarity&#39;] = similarities[top_indices]<br>    return results</pre><p><strong>The Results Are Magic ✨</strong></p><p>Now our search understands context:</p><p><strong>Query</strong>: “affordable models for creative writing”</p><p><strong>Results</strong>:</p><pre>- Mistral 7B Instruct (free) - 98% relevance<br>- Meta Llama 3.1 8B (free) - 95% relevance<br>- DeepSeek Chat ($0.00000027/1M) - 92% relevance</pre><p><strong>Business impact:</strong> Users find relevant models 3x faster than traditional keyword search.</p><h3><strong>🚀 Why Streamlit Was the Perfect Choice</strong></h3><p><strong>From Prototype to Production in Days, Not Weeks</strong></p><p><strong>Traditional approach would require:</strong></p><pre>- ❌ Frontend team (React/Vue setup)<br>- ❌ Backend API development<br>- ❌ Database design and setup<br>- ❌ DevOps and deployment pipeline<br>- ❌ Weeks of development time</pre><p><strong>Our Streamlit approach:</strong></p><pre>- ✅ Pure Python development<br>- ✅ Built-in interactive components<br>- ✅ Automatic responsive design<br>- ✅ Zero frontend knowledge required<br>- ✅ Production-ready in days</pre><p><strong>Multi-Page Architecture: Enterprise-Grade UX</strong></p><pre># Professional page structure<br>pages/<br>├── 1_🤖_AI_Chat.py # Natural language model queries<br>├── 2_🔍_Model_Browser.py # Advanced filtering and search<br>├── 3_📊_Overview.py # Market statistics and trends<br>├── 4_📈_Analytics.py # Cost analysis and provider intelligence<br>├── 5_💡_Recommend.py # Use case recommendations<br>└── 6_📥_Load_Model.py # Live data sync from OpenRouter</pre><p><strong>Why this works better than traditional dashboards:</strong></p><pre>- **Focused workflows**: Each page solves one specific problem<br>- **Better performance**: Only active page loads, faster response times<br>- **Scalable**: Easy to add new analysis modules<br>- **User-friendly**: Clear navigation, no cognitive overload<br>- **The magic of Streamlit:**<br>   - `@st.cache_data` automatically optimizes performance<br>   - Interactive widgets update the entire app in real-time<br>   - Plotly integration creates publication-ready charts<br>   - No HTML, CSS, or JavaScript required!</pre><h3><strong>📊 Advanced Analytics: Business Intelligence Features</strong></h3><p><strong>Market Intelligence Dashboard</strong></p><p>Our analysis revealed fascinating provider strategies:</p><pre>- **Cost Distribution Analysis:**<br>- **Cheapest paid model**: $0.000000003/1M (Llama 3.2 3B by Meta)<br>- **Most expensive**: ~$0.000003/1M (01.AI)<br>- **Sweet spot**: 74 models under $0.000001/1M for budget-conscious teams<br>- **Provider Strategy Visualization:**</pre><pre># Provider comparison scatter plot reveals market positioning<br>provider_stats = df.groupby(&#39;provider&#39;).agg({<br>    &#39;numeric_cost&#39;: [&#39;mean&#39;, &#39;count&#39;],<br>    &#39;is_free_bool&#39;: &#39;sum&#39;<br>}).round(6)<br><br>fig = px.scatter(<br>    provider_stats,<br>    x=&#39;Total_Models&#39;,<br>    y=&#39;Avg_Cost&#39;, <br>    size=&#39;Free_Models&#39;,<br>    hover_name=&#39;provider&#39;,<br>    title=&quot;Provider Strategy: Volume vs Cost vs Free Offerings&quot;<br>)</pre><p>This single chart reveals each provider’s market strategy at a glance!</p><p><strong>Professional Data Tables with AgGrid</strong></p><p><strong>Enterprise-grade model browser</strong> enables:</p><pre>- Multi-criteria filtering (provider + cost + capability)<br>- Bulk model comparison and export<br>- Real-time search across 320+ models<br>- Professional table interface with sorting and pagination</pre><p><strong>Intelligent Recommendation Engine</strong></p><p>Smart use case matching system:</p><pre>🎯 Code Generation → DeepSeek Coder, OpenAI GPT-4<br>💬 Customer Support → OpenAI GPT models, Anthropic Claude<br>🎨 Creative Writing → Meta Llama, Mistral Large<br>🔍 Research &amp; Analysis → Google Gemini, Anthropic Claude</pre><h3><strong>🔧 Live Data Integration: Always Current</strong></h3><p><strong>Real-Time API Sync</strong></p><p><strong>The problem:</strong> Static datasets become outdated quickly in the fast-moving LLM space.</p><p><strong>Our solution:</strong> Live API integration with smart caching:</p><pre>@st.cache_data<br>def save_openrouter_models(models, model_path=&quot;./models&quot;):<br>    &quot;&quot;&quot;Fetch and cache latest model data&quot;&quot;&quot;<br>    openrouter = OpenRouter(api_key)<br>    available_models = openrouter.get_available_models()<br>    <br>    # Parse and save with timestamp...<br>    dt_str = datetime.now().strftime(&quot;%Y-%m-%d&quot;)<br>    file_path = model_path / f&quot;openrouter-models-{dt_str}.csv&quot;<br>    <br>    # Smart caching prevents unnecessary API calls<br>    if file_path.exists():<br>        st.success(&quot;Models already loaded from today&#39;s cache&quot;)<br>        return file_path</pre><p><strong>Result:</strong> Always current data without manual updates, with intelligent caching to respect API limits.</p><h3><strong>🚀 Getting Started: Deploy in 5 Minutes</strong></h3><p><strong>Quick Setup</strong></p><pre>git clone https://github.com/digital-duck/llm_finder<br>cd llm_finder<br>pip install -r requirements.txt<br>streamlit run LLM_Finder.py</pre><p><strong>Key Features to Explore</strong></p><pre>1. **🤖 AI Chat:** Ask &quot;What&#39;s the best free model for writing?&quot;<br>2. **🔍 Model Browser**: Filter by provider, cost, and capabilities<br>3. **📊 Overview**: See market trends and provider strategies<br>4. **📈 Analytics**: Deep-dive into cost optimization opportunities<br>5. **💡 Recommendations**: Get use case-specific suggestions<br>6. **📥 Load Models**: Sync latest data from OpenRouter API</pre><p><strong>Performance Optimizations</strong></p><pre>- **Initial load**: ~3 seconds (embedding generation)<br>- **Subsequent searches**: &lt;100ms<br>- **Chat responses**: &lt;200ms<br>- **Memory usage**: ~150MB (including sentence transformer model)</pre><h3><strong>💡 Key Takeaways for Business Leaders</strong></h3><pre>**1. LLM Selection is a Strategic Business Decision**<br>- **Cost impact**: Wrong model choice can 5x your AI budget<br>- **Performance risk**: Cheap models may not deliver business value<br>- **Competitive advantage**: Smart model selection = faster iteration + lower costs<br>**2. Data-Driven Tools Beat Guesswork**<br>- **Market intelligence**: Understand provider strategies and pricing trends<br>- **Use case optimization**: Match model capabilities to business needs<br>- **Cost modeling**: Predict and optimize AI infrastructure spend<br>**3. Streamlit Enables Rapid Business Value**<br>- **Fast iteration**: Prototype to production in days<br>- **Low maintenance**: Python-only stack, minimal DevOps<br>- **User adoption**: Familiar interface, no training required<br>**4. Technical Lessons Learned**<br>**Data Engineering is 80% of the Work**<br>- Flexible parsing beats rigid regex<br>- Real-world data is always messier than expected<br>- Build for exceptions, not just happy paths<br>**Semantic Search is a Game-Changer**<br>- Users think in concepts, not keywords<br>- Sentence transformers are production-ready<br>- Small models (384MB) deliver excellent results<br>**Conversational Interfaces Lower Barriers**<br>- Natural language beats complex filters<br>- Intent detection enables smart responses<br>- Chat history creates context</pre><h3><strong>🔮 What’s Next: The Future of AI Model Selection</strong></h3><p><strong>Immediate Roadmap</strong></p><pre>- **Performance benchmarks**: Add speed/quality metrics from major leaderboards<br>- **Cost calculator**: &quot;What will 10M tokens cost across providers?&quot;<br>- **A/B testing tools**: Compare model performance on your data<br>- **Enterprise features**: Team collaboration, usage analytics<br>- **Real-time pricing**: Track model costs like stock prices<br>- **Performance alerts**: Get notified when better models launch<br>- **Usage optimization**: ML-powered recommendations based on your patterns<br>- **Market intelligence**: Predict which providers/models will succeed</pre><p><strong>The Bigger Picture</strong></p><p>This project demonstrates a powerful pattern:</p><p><strong>Raw Data → Intelligent Processing → Conversational Interface</strong></p><p>The same approach works for any domain:</p><pre>- **E-commerce**: &quot;Find me sustainable running shoes under $100&quot;<br>- **Real estate**: &quot;Show me family homes near good schools&quot;<br>- **Finance**: &quot;Which ETFs have low fees and high ESG ratings?&quot;</pre><h3><strong>🙏 Try It, Improve It, Share It</strong></h3><p><strong>Get Started Today</strong></p><pre>- **🔗 GitHub**: https://github.com/digital-duck/llm_finder<br>- **📊 Live Demo**: Clone and run locally in 5 minutes<br>- **💬 Feedback**: Issues and PRs welcome!</pre><p><strong>Built With Love and These Amazing Tools</strong></p><pre>- **Streamlit**: Rapid web app development<br>- **Plotly**: Interactive data visualizations<br>- **AgGrid**: Professional data tables<br>- **Sentence Transformers**: Semantic search magic<br>- **OpenRouter API**: Live model data<br>- **Pandas**: Data manipulation powerhouse</pre><p>Help us democratize AI model selection. Whether you’re:</p><pre>- **Building AI products**: Use our tool to optimize your model choices<br>- **Researching AI trends**: Contribute market intelligence insights<br>- **Developing tools**: Fork the repo and add new features</pre><h3><strong>👥 About the Authors</strong></h3><p><a href="https://www.linkedin.com/in/wen-g-gong"><strong>Wen Gong</strong></a> — Senior Machine Learning Engineer and Data Engineer passionate about making complex technology accessible and solving real business problems with elegant solutions.</p><h3><strong>🫶 Acknowledgement</strong></h3><p><strong>Claude (Anthropic)</strong>, <strong>Gemini (Google)</strong>, <strong>Qwen (Alibaba)</strong> are amazing AI assistants specializing in turning messy real-world challenges into practical, production-ready tools at thought-speed. Without their partnership, this work would have taken many weeks rather than a few days.</p><p><strong>🚀 Star the repo if this helped you make better AI decisions!</strong></p><p><strong>Tags:</strong> #LLM #AI #Streamlit #DataScience #MachineLearning #OpenRouter #CostOptimization #BusinessIntelligence #Python #TechStrategy #SemanticSearch</p><p><em>*💡 Want to see more projects like this? Follow me for practical AI tools that solve real business problems, built with modern Python stacks that deliver immediate value.*</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afc6b3d6f8dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>