<?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"><channel><title><![CDATA[Yogin Parmar · Build notes]]></title><description><![CDATA[Notes from a DevOps engineer in Ahmedabad on CI/CD, release pipelines and running a small fine-tuned language model fully offline on Android.]]></description><link>https://yoginparmar.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6b051d1dec31921a09697f54/93d52836-8e01-455e-bcf4-92d63c50feb6.jpg</url><title>Yogin Parmar · Build notes</title><link>https://yoginparmar.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 11:29:52 GMT</lastBuildDate><atom:link href="https://yoginparmar.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[I fine-tuned a 385 MB model to give money advice offline. It isn't allowed to write a number.]]></title><description><![CDATA[DailyBudget, the Android budgeting app I'm building, has an "Ask" tab. You type or say a money question, in English or Hinglish ("kitna bacha hai?"), and…]]></description><link>https://yoginparmar.hashnode.dev/i-fine-tuned-a-385-mb-model-to-give-money-advice-offline-it-isn-t-allowed-to-write-a-number</link><guid isPermaLink="true">https://yoginparmar.hashnode.dev/i-fine-tuned-a-385-mb-model-to-give-money-advice-offline-it-isn-t-allowed-to-write-a-number</guid><category><![CDATA[Android]]></category><category><![CDATA[AI]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[Kotlin]]></category><dc:creator><![CDATA[Yogin Parmar]]></dc:creator><pubDate>Tue, 24 Nov 2026 05:45:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b051d1dec31921a09697f54/9b6ac88a-dcfd-4aa3-9096-0e0ef40989f4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>DailyBudget, the Android budgeting app I'm building, has an "Ask" tab. You type or say a money question, in English or Hinglish ("kitna bacha hai?"), and it answers. It works with the phone in flight mode, because the app has no internet permission at all.</p>
<p>The rule that makes it work: <strong>the AI writes words, the app writes numbers.</strong> The model that runs on the phone is never allowed to put a single rupee amount in its answer.</p>
<p>Below is why, and what it took to make a 385 MB model useful.</p>
<h2>Two layers, one answer</h2>
<p>Every question goes through the app's own code first.</p>
<p>If it's an exact question ("how much is left today?", "what did I spend on petrol this month?"), a plain Kotlin class called <code>Advisor</code> answers it instantly from the transactions it already parsed from bank SMS. No model involved.</p>
<p>If it's a judgement question ("can I buy shoes this week?", "where am I going wrong?"), the app builds a fact sheet first: today's number, the cycle so far, the biggest spending categories and payees, and any notes the user saved with "remember …". The model gets those facts and writes advice.</p>
<p>The reply you see is two parts. The exact numbers come from <code>Advisor</code>, computed in integer paise. Under them is the model's advice in words.</p>
<h2>Why the model can't write numbers</h2>
<p>My first version used stock Qwen2.5-1.5B and let it write freely. It read the facts correctly most of the time and still put real numbers in the wrong places. One answer told the user they had "₹598 today" when ₹598 was how much they'd overspent across the whole cycle. The number existed in the facts, so checking each amount against the fact sheet didn't catch it.</p>
<p>So now a small filter, <code>NumberGuard</code>, drops any sentence from the model where it writes a ₹ amount or a percentage. The numbers on screen all come from code. The model only gets to say things like "you're over for this cycle, so wait for salary before the shoes, and the biggest leak is late-night food orders."</p>
<h2>Fine-tuning a 0.5B model on a laptop</h2>
<p>Stock models were bad at following that rule. I wrote a 40-question held-out exam that scores each answer the way the app would use it: no figures, English only, names the user's real top spending category or a real payee, honest about being over or under budget, says "wait" on purchase questions when over budget, and 15 to 90 words long. Stock Qwen2.5-1.5B passed every check on only 7.5% of questions. Stock 0.5B passed 5%.</p>
<p>So I trained a LoRA adapter on Qwen2.5-0.5B-Instruct:</p>
<ul>
<li><strong>Data:</strong> 440 examples. The prompts were generated by the app's own fact-sheet code, so training saw exactly what the phone sends. The answers follow a written style spec: no digits, plain English, two to four sentences, name the real categories and payees, and say "wait for salary" when the user is over budget.</li>
<li><strong>Training:</strong> LoRA rank 16, alpha 32, all projection layers, 2 epochs, learning rate 2e-4. It ran on CPU in fp32 on an Intel Mac, because Apple's MPS backend gave wrong numerics.</li>
<li><strong>Export:</strong> converted with llama.cpp and quantised to Q4_K_M. The final file is 385 MB.</li>
</ul>
<p>On the same exam the fine-tuned 0.5B passed 80% of questions, against 7.5% for the stock 1.5B. Answers that named the user's real top category or payee went from 25% to 98%. It's also about twice as fast as the 1.5B.</p>
<h2>Running it on a mid-range phone</h2>
<p>My test phone has a Snapdragon 695 and 5.5 GB of RAM. A few things mattered more than I expected:</p>
<ul>
<li><strong>2 threads beat 4 or 6.</strong> Prompt processing ran at 38 tokens/s on 2 threads against 27 on more, because the little cores drag the big ones down.</li>
<li><strong>No mmap.</strong> With memory-mapped weights, Android evicted pages mid-answer on this RAM-tight phone and generation fell to about 1 token/s. Loading the weights fully fixed it.</li>
<li><strong>Gates before loading.</strong> The model only loads on phones with at least 4 GB of RAM, and only if the model file is no bigger than 30% of that RAM. Otherwise the Ask tab still works, with exact answers only.</li>
<li><strong>Warm-up and cache reuse.</strong> Opening the tab loads the model and pre-reads the system prompt and facts, so a follow-up question only processes its own words.</li>
</ul>
<p>llama.cpp is built into the app through CMake and a small JNI bridge, for arm64 only.</p>
<h2>The offline part has a cost</h2>
<p>The app can't download anything, so it can't download the model either. Right now you add the model file yourself through Android's file picker. That's clunky, and it's the price of being able to say the app never goes online. I haven't solved this one yet.</p>
<p>Voice works offline too, as long as the phone has an on-device speech recogniser: questions go to the phone's own recogniser and answers are read out by its text-to-speech engine.</p>
<h2>What I'd tell anyone adding a small model to an app</h2>
<p>Let code own every fact and every number, and give the model one narrow job. Then measure it with an exam that scores exactly that job. The 0.5B model knows less than the 1.5B one. It wins because it was trained for exactly one job.</p>
<p>If you've shipped an on-device model in an Android app: how do you get the model file onto people's phones?</p>
]]></content:encoded></item><item><title><![CDATA[My budget app has no INTERNET permission. Here's what that costs.]]></title><description><![CDATA[I'm building DailyBudget, an Android app that reads bank SMS on the phone and turns a salary into one number: what you can spend today. It has no INTERNET…]]></description><link>https://yoginparmar.hashnode.dev/my-budget-app-has-no-internet-permission-here-s-what-that-costs</link><guid isPermaLink="true">https://yoginparmar.hashnode.dev/my-budget-app-has-no-internet-permission-here-s-what-that-costs</guid><category><![CDATA[Android]]></category><category><![CDATA[privacy]]></category><category><![CDATA[Devops]]></category><category><![CDATA[buildinpublic]]></category><dc:creator><![CDATA[Yogin Parmar]]></dc:creator><pubDate>Tue, 24 Nov 2026 05:33:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b051d1dec31921a09697f54/050b0cda-e404-47ce-814e-8b088d38d295.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I'm building DailyBudget, an Android app that reads bank SMS on the phone and turns a salary into one number: what you can spend today. It has no <code>INTERNET</code> permission. The manifest opens with a comment saying so:</p>
<pre><code class="language-xml">&lt;!-- No INTERNET permission on purpose: financial data never leaves the device. --&gt;
</code></pre>
<p>That one missing line shapes almost every engineering decision in the app. Here's what it costs, what it doesn't protect against, and how you can check any app yourself.</p>
<h2>Why go this far</h2>
<p>Bank SMS are a diary. Salary, EMIs, rent, the food order at 2am, which shop you were in on Saturday. Many money apps that read them send them to a server to categorise spends, because server-side parsing is faster to ship and easier to fix.</p>
<p>I wanted a stronger promise than "we encrypt it" or "we don't sell it". With no <code>INTERNET</code> permission, the app itself can't open a socket. You don't have to trust my privacy policy. You can check the permission list.</p>
<h2>Check the final APK, not the manifest you wrote</h2>
<p>The manifest in <code>src/main</code> is only half the story. Libraries ship their own manifests and Gradle merges them in. Any dependency could add <code>INTERNET</code> and you'd never see it in your own file.</p>
<p>So I check the built release APK:</p>
<pre><code class="language-bash">aapt2 dump permissions app/build/outputs/apk/release/app-release.apk
</code></pre>
<p>Output for DailyBudget:</p>
<pre><code>uses-permission: name='android.permission.RECEIVE_SMS'
uses-permission: name='android.permission.READ_SMS'
uses-permission: name='android.permission.POST_NOTIFICATIONS'
uses-permission: name='android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS'
uses-permission: name='android.permission.RECORD_AUDIO'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.RECEIVE_BOOT_COMPLETED'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
</code></pre>
<p>No <code>INTERNET</code>. The last four came from WorkManager, which runs the 9am and 10pm summaries. <code>ACCESS_NETWORK_STATE</code> looks alarming but only lets the app ask whether a connection exists. It can't send anything.</p>
<p>If I ever add a library that pulls in <code>INTERNET</code>, this check catches it before a release goes out.</p>
<h2>What it costs</h2>
<p><strong>No crash reporting.</strong> No Crashlytics, no Sentry. When something breaks on someone's phone, I find out only if they tell me. The project's own rules file says it plainly: don't add analytics, crash reporting or network libraries.</p>
<p><strong>No analytics.</strong> I can't see which screens people use or where they drop off. Every product decision comes from what people tell me.</p>
<p><strong>No cloud sync.</strong> Change phones and your history doesn't follow you. Backup is off too (<code>android:allowBackup="false"</code>), so it doesn't quietly end up in a cloud backup either.</p>
<p><strong>No server-side fixes.</strong> The SMS parser runs on the phone. If a bank changes its message format, the fix has to ship as an app update. To keep that from hurting, every bank pattern lives in one file and every format has a test fixture. I ran about 1,800 of my own bank SMS through the parser, and the roughly 45 formats in them are now redacted fixtures. There are 73 unit tests in total.</p>
<p><strong>Some features need a workaround.</strong> The "Ask" tab takes voice input, which normally means a cloud speech API. Instead the app hands audio to the phone's own speech recognition service, so this app still never touches the network.</p>
<h2>What it doesn't protect against</h2>
<p>I want to be precise about this one, because "can't go online" is easy to overclaim.</p>
<p>Without <code>INTERNET</code> the app can't make network calls itself. Data can still leave the phone another way: Android lets apps hand data to other apps through intents. If I wrote code that opened a browser with your balance in the URL, or offered a share sheet, another app could send it. What the missing permission removes is the easy, invisible path: no SDK or library can phone home on its own. Any hand-off to another app is code I'd have to write on purpose, and it would show up in a review.</p>
<p>So the honest promise is: no internet permission, and nothing uploaded by the app.</p>
<h2>The part that's still open</h2>
<p>Crash reports are the problem I haven't solved. Options I'm weighing:</p>
<ol>
<li>Write crashes to a local file and add a "Send crash log" button that opens the user's email app with the log attached. User-initiated, visible, no network code in my app.</li>
<li>A "Copy debug info" button for people to paste into a chat or a form.</li>
<li>Ship more defensively: more tests, slower releases, a beta channel of people who'll actually report bugs.</li>
</ol>
<p>Option 1 feels right, but it depends on users bothering to press the button.</p>
<p><strong>Update after the first comments on dev.to:</strong> two readers pointed out that people who hit a real crash are the most likely to press a send button (so option 1 it is for sideloaded builds), and that Android vitals in the Play Console gives crash and ANR data with zero network code in the app once it's on Google Play.</p>
<h2>Why this matters for the product</h2>
<p>The product idea is one number a day instead of twelve budget categories. Privacy is what might get someone who's nervous about giving an app their bank SMS to try it anyway.</p>
<p>If you've shipped an app with no network access, how did you handle crash reports? I'd like to hear what actually worked.</p>
]]></content:encoded></item></channel></rss>