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