Ollama Embeddings: Turn Text into Vectors for Local Search and RAG
Note: Some future links on this site may be affiliate links. We never claim hands-on testing; guides are researched from the public sources listed in each article.
How we wrote this: A summary of Ollama's official Embeddings page and its API reference for the embed endpoint (linked below), checked October 29, 2026. Commands are copied from those docs; model names and options can change between Ollama releases.
Chat models answer questions. Embedding models do something quieter: they turn a piece of text into a list of numbers (a vector) so a program can tell which pieces of text mean similar things. That is the engine behind "search my notes by meaning" and behind most retrieval-augmented generation (RAG) setups, where an app finds the right passages first and only then hands them to a chat model.
Ollama can produce these vectors on your own machine, so the text you index never has to leave your computer. If you haven't installed Ollama yet, start with running a local AI model with Ollama.
What an embedding is, in Ollama's words
Ollama's docs describe embeddings as text turned into numeric vectors that you can store in a vector database, search with cosine similarity, or use in RAG pipelines. The vector length depends on the model; the docs say it is typically 384 to 1,024 dimensions.
The examples in the docs use a model called embeddinggemma. Any embedding model from Ollama's library works the same way.
Try it from the command line
The quickest test is the CLI:
ollama run embeddinggemma "Hello world"
You can also pipe text in:
echo "Hello world" | ollama run embeddinggemma
According to the docs, the output is a JSON array: the vector itself.
Use the local API
Apps usually call Ollama's local server instead (see Ollama's local API basics). The embeddings endpoint is POST /api/embed:
curl -X POST http://localhost:11434/api/embed \
-H "Content-Type: application/json" \
-d '{
"model": "embeddinggemma",
"input": "The quick brown fox jumps over the lazy dog."
}'
The response includes an embeddings field. Ollama's official Python and JavaScript libraries wrap the same call as ollama.embed(...); the docs show reading embeddings[0] to get the first vector and checking its length.
One detail worth knowing: the docs note that /api/embed returns L2-normalized (unit-length) vectors.
Embed many texts in one call
To index a folder of notes you don't need one request per paragraph. Pass an array of strings as input and you get one vector back per string:
{
"model": "embeddinggemma",
"input": ["First sentence", "Second sentence", "Third sentence"]
}
Options you may need
The API reference for the embed endpoint lists a few optional fields:
| Field | What the reference says |
|---|---|
truncate |
Defaults to true: inputs longer than the model's context window are truncated. Set it to false and the request returns an error instead. |
dimensions |
The number of dimensions to generate embeddings for. |
keep_alive |
How long the model stays loaded after the request. |
options |
Model options, as with other Ollama endpoints. |
If you set truncate to false, long passages fail loudly instead of being silently cut, which is useful while you are tuning how you split documents. Context length works the same way here as with chat models.
Two rules from the docs
Ollama's Embeddings page closes with two tips:
- Use cosine similarity for most semantic search use cases.
- Use the same embedding model for indexing and for querying.
The second rule matters more than it looks. Vectors from different models live in different "spaces", so if you switch models you need to re-embed everything you stored.
Where this fits
A minimal private search tool has three steps: split your documents into passages, embed each passage once and store the vectors, then embed each question and return the passages whose vectors are closest. A RAG app adds a fourth step: send those passages to a chat model with the question. Tools such as Open WebUI and the approaches in chatting with your documents locally do this for you; the embed endpoint is what they call underneath.