Running an Embedding Model Next to My Notes on an iPhone
How I built private, on-device semantic search for a notes app using a 350M-parameter embedding model, SQLite, ExecuTorch, and llama.cpp.
In March, the reporter wrote a note titled "Rent split with Arjun." In October, they searched for "what does my flatmate owe," but found no results because the two notes shared no words. This prompted the development of VB Notes, a markdown notes app where every note is a .md file in a chosen folder. The app runs embedding models on the device, allowing for private search without sending queries to a server.
The reporter built the app using Expo and React Native, running a 350-million-parameter embedding model alongside the notes on an iPhone. After testing various models, the reporter chose LFM2.5-Embedding-350M as the default, with MiniLM as a "Light" choice in settings, and a multilingual model for those writing in multiple languages.
To efficiently store the vectors, the reporter used int8 vectors in SQLite, reducing the size of each chunk from 4 KB to a quarter of that. The app keeps the original .md files as the source of truth, loading vectors on the first search and storing them in memory. The reporter used cosine scores as a fixed floor and a threshold below the best match to determine which matches to display.
Rewritten by urgent.news; may contain errors — check the original.
Source: hackernoon.com