Go Completely Offline: Build a Privacy-First Personal Finance Assistant with LiteRT and Gemma 4
说明与用途
该应用完全在浏览器离线运行:交易数据存储在 IndexedDB,Gemma 4 模型缓存在 Cache Storage,LiteRT LM Web API 提供快速、私密的响应,无需令牌费用。
问题
Users want a personal finance assistant that can analyze sensitive transaction data, detect anomalies, and suggest budgeting without exposing data to external servers or incurring token costs.
结果
The application achieves 100 % offline, privacy‑first personal finance assistance with zero token costs, by caching a 2 GB Gemma 4 model in the browser and performing all inference locally.
工作流
- 1. Install dependencies: @litert-lm/core, tailwindcss, jsonrepair, dexie, angular-eslint, husky, lint-staged, serve, @commitlint/cli
- 2. Cache Gemma 4 weights (~2 GB) in the browser’s Cache Storage using AiModelCacheService and FileProxyCache
- 3. Lazily initialize a single LiteRT LM engine instance via GemmaEngineService
- 4. Store user expenses in IndexedDB
- 5. Precompute arithmetic grounding (monthly, daily totals, category breakdown) and supply to the engine as ground truth
- 6. Manage conversation: reset after three turns, keep last two queries in client‑side memory, re‑prime model on reset with grounding data
- 7. Stream responses with WebGPU speed and display insights in the Angular UI
证据
The demo has a download button for users to download the Gemma 4 E2B model that is around 2GB.
After a successful download, go to Application > Storage > Usage to verify that the model occupies 2GB in storage.
- 记录日期: 2026-09-07T19:59:27.165Z