How offline hybrid search works
How Memorinth searches notes by keyword and by meaning on your own machine: sections by heading, SQLite full-text search, a local model, one score.
On this page
Memorinth’s search runs entirely on your computer. Each note is split into sections by heading, and every section is searched two ways at once: by its words, with SQLite’s full-text index, and by its meaning, with a small embedding model that runs locally. The two scores are blended into one, with meaning weighted more, except when the query looks like code. Nothing is sent anywhere, and after a one-time model download it all works offline.
| Stage | What it does | Runs on |
|---|---|---|
| Chunking | Splits each note into sections by heading | The engine |
| Keyword search | BM25 over the words, titles and headings | SQLite FTS5 |
| Search by meaning | Compares the query’s vector with every section’s | EmbeddingGemma-300M, about 220 MB |
| Blending | One score: 85% meaning, 15% words; 30% meaning for code | The engine |
| Status | Current decisions and facts rank higher; replaced ones are hidden | The index |
The same search serves the app’s search box, Ask, and agents calling search_memory.
Sections, not notes
A note can cover several things, and a long one would drown its best paragraph in the rest. So the index splits every note at its headings. Each section remembers where it sits, as a path like Release process › Signing › Windows, and sections longer than about 1,800 characters are split again at paragraph breaks.
Search ranks sections, then keeps the best one per note. That’s why a result shows the passage that matched, under its heading, rather than the top of the note.
Words: SQLite full-text search
Every section goes into an FTS5 table in the cortex’s .memorinth/ folder, with the Porter stemmer, so “indexing” finds “indexed”. It’s ranked by BM25, with a match in the note’s title counting three times as much as one in the text, and a match in a heading one and a half times.
Common words are dropped from a query, so “where does the spark go” searches for “spark”. And because BM25 has no fixed scale, a section’s keyword relevance is measured against the best match for that query.
Keyword search is fast, exact and needs no model. It’s what search falls back to before the model is downloaded, or when it’s turned off with MEMORINTH_EMBEDDINGS=off.
Meaning: a model on your machine
Words miss paraphrases. A note about “plans and tiers” should answer a search for “pricing”. For that, each section is turned into a vector by EmbeddingGemma-300M, a small multilingual embedding model, run locally in a 4-bit build. It’s about 220 MB, downloaded once, and vectors are stored in the same index.
A query is embedded the same way, with the model’s own prompt for search queries, and compared with every section’s vector. Two adjustments make the comparison fairer:
- Relative, not absolute. Unrelated text rarely scores near zero with any model, so a section’s relevance is measured from the average section up to the best one.
- The whole note counts. A section’s score is blended with how close the rest of its note is to the query, so a passing mention in a note about something else ranks below a note that’s about the query throughout.
One score
Each note found either way gets a relevance from each side, and the two are added with weights: 85% meaning, 15% words. We tried reciprocal rank fusion, the usual way to merge two result lists, and on our evaluation set of labelled queries a weighted sum did better: paraphrases rank higher, and exact words still win when they match.
Some queries are better read literally. One that contains a path, a snake_case or camelCase name, a dotted file name or backticks is treated as code, and gets only 30% meaning. Paste a line of code and you find the note that has it, not one that’s vaguely about the same thing.
A few smaller signals round it out:
- Words close together. A note holding all of a query’s words within a few words of each other gets a bonus: it probably contains the phrase.
- Related terms. Query words are matched against words already in your cortex by meaning, and close ones are searched as keywords too, at a lower weight. “Icon” also finds “pictogram”.
- Shared tags. When several of the best hits share an uncommon tag, other notes with that tag move up a little.
What’s current comes first
Memory has a notion of time that documents don’t. An accepted decision or a valid fact ranks higher; one due for a recheck slightly lower. Superseded decisions and retired facts are hidden from results unless an agent asks for history, so an agent never acts on a choice you’ve since replaced.
Why local
Searching on your machine means your notes never leave it to be searched, there’s no API key or bill, and search works on a plane. One engine serves the app and every agent session, so the model is loaded once, however many agents are running.
The cost is a 220 MB download and a model smaller than the largest hosted ones. For notes, which are short and written in your own words, a small model plus good keyword search is a trade we’re happy with.
Try the query language in Searching, read about Search by meaning in the app, or see how agents use search in a session.