<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: dhuang0808</title>
    <description>The latest articles on DEV Community by dhuang0808 (@dhuang0808).</description>
    <link>https://dev.to/dhuang0808</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4197609%2Fac9f07a6-3442-4987-8c06-08dbad6619a1.png</url>
      <title>DEV Community: dhuang0808</title>
      <link>https://dev.to/dhuang0808</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dhuang0808"/>
    <language>en</language>
    <item>
      <title>Three Lines Before Class: Live Search Meets Local Gemma</title>
      <dc:creator>dhuang0808</dc:creator>
      <pubDate>Sun, 25 Oct 2026 12:33:44 +0000</pubDate>
      <link>https://dev.to/dhuang0808/three-lines-before-class-live-search-meets-local-gemma-4bnm</link>
      <guid>https://dev.to/dhuang0808/three-lines-before-class-live-search-meets-local-gemma-4bnm</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week3-2026-10-19"&gt;Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;Four minutes. Three web pages. Still only a rough idea of gradient descent.&lt;/p&gt;

&lt;p&gt;I'd never studied it before. I'm a first-year university student, and I wanted a quick way into an unfamiliar topic before class. Searching gave me plenty to read. Working out where to begin was still my job.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;Preclass in Three Lines&lt;/strong&gt;. Type a topic into the terminal, and SerpApi fetches five live search titles and snippets. Gemma 3 4B, running locally through Ollama, turns them into three short Chinese lines: what it is, why it matters, and one example.&lt;/p&gt;

&lt;p&gt;A little less tab-hopping seemed like a reasonable goal for Slow and Steady.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;Here's the gradient-descent run. Enter a topic, wait for the search and local generation, and out come the three lines.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0lovdqp56cpv4f6zl6z2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0lovdqp56cpv4f6zl6z2.gif" alt="Animated terminal demo: a gradient-descent query followed by three Chinese summary lines" width="759" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the exact Chinese output from that same run:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;它是什么：梯度下降法是一种迭代优化算法，通过计算损失函数梯度来调整模型参数，从而降低损失函数值。&lt;/p&gt;

&lt;p&gt;为什么重要：理解梯度下降法有助于掌握机器学习模型训练的基本原理，是后续学习更高级优化算法的基础。&lt;/p&gt;

&lt;p&gt;一个例子：假设一个图像识别模型，通过梯度下降法不断调整参数，以减少识别错误，提高准确率。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Line-by-line English translation:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; Gradient descent is an iterative optimization algorithm that adjusts model parameters by calculating the gradient of the loss function, thereby reducing the value of the loss function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt; Understanding gradient descent helps you grasp the basic principles of training machine learning models and provides a foundation for learning more advanced optimization algorithms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An example:&lt;/strong&gt; Suppose we have an image recognition model. Gradient descent continually adjusts its parameters to reduce recognition errors and improve accuracy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/dhuang0808/preclass-3-lines" rel="noopener noreferrer"&gt;Source code on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Python code uses the MIT license. The README has setup instructions and a real output example. You'll need Python, a SerpApi account and the local Gemma model. There are no third-party Python packages to install. Search providers and model weights keep their own terms.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;p&gt;First, I gave the model some sample notes. Could it turn them into three useful lines? Once that worked, I connected real search results.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Topic → SerpApi → five titles and snippets → local Gemma → validation → three lines&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The app uses the first five organic results returned by SerpApi. A failed search or missing snippets produces an error instead of a made-up fallback. It reads titles and snippets, not the full pages.&lt;/p&gt;

&lt;p&gt;Gemma returns three structured fields. Python checks for Chinese text and a limit of 64 characters per printed line, including the label. If the answer fails, it gets one retry. Credentials stay in an ignored project-local &lt;code&gt;.env&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Getting three lines was easier than getting three useful lines. An early search brought in marketing placeholder names. Another answer included editing instructions inside valid JSON. Both problems led to checks in the code, and I kept the failed outputs.&lt;/p&gt;

&lt;p&gt;The core acceptance set has &lt;strong&gt;17 passing unit tests&lt;/strong&gt; and &lt;strong&gt;five live runs across three topics&lt;/strong&gt;: a data-science concept, the ongoing challenge and a file-organization question. I repeated the concept three times. All five outputs fit the format; the repeated topic produced two different phrasings.&lt;/p&gt;

&lt;p&gt;A separate RAG test had two successful calls and one search connection failure. The successful previews appeared in &lt;strong&gt;4.56 seconds and 4.99 seconds&lt;/strong&gt;. The &lt;a href="https://github.com/dhuang0808/preclass-3-lines/blob/main/notes/lazy-payoff-measurement.md" rel="noopener noreferrer"&gt;measurement notes&lt;/a&gt; keep the failure alongside those timings.&lt;/p&gt;

&lt;p&gt;Then I tried four topics closer to my coursework. Limits, the geometric meaning of derivatives, overfitting and matrix multiplication took &lt;strong&gt;15.62, 6.12, 8.74 and 7.38 seconds&lt;/strong&gt; respectively.&lt;/p&gt;

&lt;p&gt;The matrix-multiplication answer was bad. It confused rows and columns, then offered a projection example without showing a multiplication. The basic explanation should have used row-by-column dot products. You can see the original answer in the &lt;a href="https://github.com/dhuang0808/preclass-3-lines/blob/main/notes/day3-results.md" rel="noopener noreferrer"&gt;follow-up results&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;All four new answers passed the format checks, which says something about the checks' limits. This is a first explanation to question and check against a textbook. Short snippets and a small model can leave gaps or give the wrong idea; a tidy three-line answer doesn't fix that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Does Open Innovation Matter?
&lt;/h2&gt;

&lt;p&gt;With Gemma running on my own computer, I can see and change the part that writes the explanation. I can edit the prompt, adjust the checks and try again on my own computer. Having those pieces within reach matters when I'm still learning how they fit together.&lt;/p&gt;

&lt;p&gt;It also means the snippets and summarization prompt don't need to go to another hosted LLM. &lt;strong&gt;The query still goes to SerpApi&lt;/strong&gt;, so live search needs the internet. With the model and cached snippets already available, the summary stage can run locally.&lt;/p&gt;

&lt;p&gt;I paid no hosted-model API charge in these experiments. I still need the hardware, electricity, setup time and search quota. Installing a small model is extra work, and its output needs checking. Those are tradeoffs I can inspect and change alongside the code.&lt;/p&gt;

&lt;p&gt;Publishing the failed examples gives the next person a place to start, too. They can try a better prompt or check a source and see whether their change helps.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Agent Session
&lt;/h2&gt;

&lt;p&gt;I've collected the build's &lt;a href="https://github.com/dhuang0808/preclass-3-lines/blob/main/notes/unit-tests.txt" rel="noopener noreferrer"&gt;test results&lt;/a&gt;, &lt;a href="https://github.com/dhuang0808/preclass-3-lines/blob/main/notes/product-validation.txt" rel="noopener noreferrer"&gt;live-run transcripts&lt;/a&gt; and &lt;a href="https://github.com/dhuang0808/preclass-3-lines/blob/main/notes/article-measurements-initial.json" rel="noopener noreferrer"&gt;initial flawed outputs&lt;/a&gt; in the repository. I haven't shared an unredacted agent-session transcript.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Lazy Payoff
&lt;/h2&gt;

&lt;p&gt;Looking up gradient descent the traditional way took me &lt;strong&gt;four minutes&lt;/strong&gt; the first time. I opened &lt;strong&gt;three web pages&lt;/strong&gt; and came away with only a rough understanding. The tool produced its three-line preview in &lt;strong&gt;18 seconds&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That's about &lt;strong&gt;13 times faster to an initial preview&lt;/strong&gt;: 240 divided by 18 is approximately 13.3. It's a personal timing comparison with different endpoints. The four minutes include searching and reading; the 18 seconds stop when the output appears. I didn't report a separate reading time for the preview, and seeing the topic once could affect the second attempt. It doesn't establish how quickly I learned it.&lt;/p&gt;

&lt;p&gt;The RAG experiment measured text volume separately. Its five titles and snippets had 531 and 547 characters; the previews had 143 and 158 characters, including labels. That's &lt;strong&gt;about 71–73% less displayed text&lt;/strong&gt;, rather than a percentage improvement in learning or accuracy. Those figures belong to the RAG runs, not my 18-second gradient-descent experience.&lt;/p&gt;

&lt;p&gt;I still have the maths to learn. At least now I have a shorter starting point.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prize Categories
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Best Use of SerpApi&lt;/strong&gt; — provides the five real search titles and snippets for each live preview.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Best Use of Gemma&lt;/strong&gt; — local Gemma 3 4B writes the three-line summary at the core of the app.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  AI Usage Disclosure
&lt;/h2&gt;

&lt;p&gt;GPT/Codex helped with paired programming, code generation, testing, debugging and this article draft. I supplied the personal timing figures. This draft is marked as primarily AI-generated; my approval alone doesn't make it human-authored. The app doesn't call a GPT API: &lt;strong&gt;local Gemma is its core summarization model&lt;/strong&gt;, and SerpApi supplies live search. I'm responsible for checking the final text, evidence and claims before publication.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
    </item>
  </channel>
</rss>
