Inspiration
Notes are personal, so sending every note to a server felt wrong. But on-device models are not on every device, and they are weaker on long text. Hybrid inference lets one app use both.
What it does
Smart Notes lets you add, search and delete notes, then get a summary or a list of action items for any note. Short notes run on the device with Gemini Nano in Chrome, so nothing leaves the browser. Long notes go to the cloud Gemini model, which handles bigger inputs better. Every result shows a badge (On-device · Gemini Nano, Cloud · Gemini, or Local fallback) so the user can see where the answer came from. An AI mode selector (Auto, Prefer on-device, Always cloud) lets users choose the behaviour.
How we built it
All AI calls go through Firebase AI Logic (Web SDK) with the Gemini Developer API.
- Two models are created with getGenerativeModel: one with InferenceMode.PREFER_ON_DEVICE and one with InferenceMode.ONLY_IN_CLOUD.
- Short notes use the on-device model, long notes use the cloud model.
- The on-device model is initialized from a user click with initializeDeviceModel and shows download progress. While it downloads, the SDK answers from the cloud.
- result.response.inferenceSource is read after every call and shown as a badge.
- Firebase App Check (reCAPTCHA Enterprise, with a debug token for local testing) protects the AI requests.
- If both models fail, a small local algorithm still returns a summary, so the user always gets an answer.
- The app is built with Vite and plain JavaScript, tested with node:test, and hosted on Firebase Hosting.
Challenges
Gemini Nano is not available on every device, and the first use needs a model download. We designed the fallback so the app works either way. Setting up App Check for a web app and for local development also took some care.
What we learned
Hybrid inference is mostly about routing and graceful fallback. Showing the source of every answer makes the behaviour clear to users.
What's next
Streaming responses, more tasks (rewrite, translate), and syncing notes with Firebase
Built With
- firebaseailogic
- firebaseappcheck
- firebasehosting
- gemini
- gemininano
- javascript
- recaptchaenterprise
- vite