New Tool Radar

AI Concepts

How to Run an Embedding Model Locally and Search Your Own Notes by Meaning

Turn your own notes into vectors with a local embedding model, then compare a question's vector with each note's vector to find the note that means the same thing.

Schematic diagram with three steps: embed the notes with ollama.embed and embeddinggemma, embed the question with the same model, and rank matches by cosine similarity.

Keyword search finds notes that contain the same words. Embedding search finds notes that mean the same thing, even when the words differ. Ollama’s embeddings documentation says embeddings “turn text into numeric vectors you can store in a vector database, search with cosine similarity, or use in RAG pipelines”, and that the vector length depends on the model, typically 384 to 1024 dimensions. A small local model can do this for your own notes, on your own computer, with nothing uploaded.

Pick an embedding model and embed three notes

Use a model made for embeddings, not a chat model. Ollama’s embeddings documentation gives embeddinggemma as its example model, with the Python call ollama.embed(model='embeddinggemma', input='The quick brown fox jumps over the lazy dog.'). Pull it first with ollama pull embeddinggemma, then embed each note separately. The documentation’s tip is to use cosine similarity for most semantic search, and to use the same embedding model for both indexing and querying — so the question must be embedded with the same model as the notes.

Fictional practice note What it is about What the search should find
“Mara checks the lighthouse lamp at noon.” The lamp check Closest match to “When is the lamp checked?”
“The supply boat arrives on Tuesdays.” The boat A weaker match to the lamp question
“Tomatoes are watered on Mondays.” The garden The weakest match to the lamp question

Embed the question too — “When is the lamp checked?” — with the same model, then compare its vector with each note’s vector using cosine similarity. The documentation says a batch of embeddings is made by passing an array of strings to input, so the three notes can be embedded in one call, and the reply’s embeddings list holds one vector per note.

Try it: find the lamp note

Write the three fictional notes above into a practice file, embed all three with embeddinggemma, embed the question “When is the lamp checked?”, and rank the notes by cosine similarity to the question. For a fictional example, the lamp note ranks first, the boat note second, and the garden note last — and you can confirm the ranking by reading the notes yourself, since the lamp note is the only one that answers the question. Expected result. We checked the Ollama embeddings documentation. We did not run an embedding model or compute any vectors on this machine.

Limits

Embeddings measure similarity of meaning, not truth: the closest note can still be wrong, out of date, or incomplete, so read the note it finds before you act on it. Mixing models breaks the search — the documentation’s tip to use the same model for indexing and querying exists because vectors from different models cannot be compared. A vector also has a fixed length for its model, and the documentation says that length typically runs 384 to 1024 dimensions, so a different model will give a different length. We did not test any search ourselves.

Sources

See all