Serving embedding models with Ollama for self-hosted search: when teams need it
If your team wants semantic search or retrieval over internal documents and needs the data to stay in infrastructure you control, Ollama can serve the embedding model alongside the chat model you already run. Ollama generates vectors through the CLI and the /api/embed endpoint, and those vectors can be written to a self-hosted vector database for search. The vector length depends on the model, typically 384 to 1024 dimensions, so the first decision is which model you embed with, because that choice fixes the dimension your database collection or column must use. Changing the embedding model later means re-embedding the whole corpus, so treat it as a versioned decision, not a setting you tweak.
Reuse of one Ollama server makes sense when query volume is modest, the same team owns both models, and you want a single runtime to patch and monitor. A dedicated embedding model is the better fit when you need to index large document sets, when indexing jobs would compete with interactive chat for GPU memory, or when retrieval quality matters more than the convenience of one server. Confirm with your own data whether a general chat model or a purpose-built embedding model gives acceptable recall, since Ollama does not decide that for you.
Ollama is MIT licensed, and the local API at localhost:11434 does not require authentication. That default is acceptable only on a single workstation. Once the server listens on a network interface through OLLAMA_HOST, anyone who reaches it can generate embeddings, so access control, a reverse proxy with authentication and network restrictions belong in the plan before the first document is indexed. Your indexed vectors also carry information about your documents, so treat the embedding path with the same data handling rules as the source content.
How Ollama, the application and the vector database connect
The flow starts with documents and user queries entering the application, which calls the /api/embed endpoint on Ollama over a private network. Ollama returns vectors, the application writes them to Qdrant or pgvector, and chat models run on the same Ollama server. The trust boundary wraps Ollama and the vector database, and an authentication proxy sits in front of Ollama because its local API has no authentication. Check that Ollama stays off public interfaces and that the vector store is not exposed without its own access controls.
Documents and queries flow through the application to Ollama embeddings and the vector store.
Qdrant or pgvector: choosing the vector store
Qdrant is a dedicated vector search engine licensed under Apache-2.0 and written in Rust. It is built for similarity search as its main job, so collections, shards and replicas are managed through the engine itself rather than through another database's tooling. Teams that expect vector workloads to grow, or that want a separate service with its own scaling and access model, usually find this path easier to reason about.
- Access controls: Qdrant supports admin and read-only API keys, TLS for REST and gRPC, and JWT-based granular access with per-collection read or write permissions.
- Audit trail: JSON audit logging of authenticated API operations is available in the version line that introduced it, so confirm the release you deploy includes it.
- Clustering: Distributed mode uses Raft for cluster topology and splits collections into shards. The distributed deployment documentation recommends at least three nodes for production quorum.
- Secure defaults: A self-deployed instance listens on all interfaces with no authentication until you configure it, so network placement and keys must be set during the build.
- Operating cost: The engine is free to self-host, but the team must run another stateful service with its own upgrades, backups and monitoring.
Before choosing this path, confirm the current release and its security and cluster features against the Qdrant release notes.
pgvector is a PostgreSQL extension released under the PostgreSQL License. Vectors sit in the same database as your relational data, so joins, transactions, backups and existing PostgreSQL access controls apply without a second system. This suits teams that already run PostgreSQL well and want embeddings next to the records they describe.
- Version support: The README states support for PostgreSQL 13 and later, and PostgreSQL ships a major version about once a year, with five years of support for each.
- Dimension limits: The vector and halfvec types go up to 16,000 dimensions, but a vector column can be indexed for approximate search only up to 2,000 dimensions. Check your embedding model's output size against this limit before choosing the index type.
- Distance operators: L2, inner product, cosine, L1, Hamming and Jaccard operators are supported.
- Exact search by default: Without an approximate index, search is exact, which can be slower on large tables.
- Shared capacity: Vector queries compete with transactional workloads for the same CPU, memory and storage unless you plan separate instances.
Before choosing this path, confirm the current extension version and index limits in the pgvector changelog and README.
Filtering changes search results in both products, and the behavior differs in ways that affect retrieval quality. In pgvector, approximate indexes such as HNSW and IVFFlat are scanned first and filters are applied afterward. A narrow filter can therefore return fewer rows than requested. The extension offers iterative index scans in strict or relaxed ordering modes to fetch more candidates when filters remove too many results.
- Post-scan filtering: With approximate indexes, a selective filter (for example, one tenant or one document set) may leave few matches after the index returns its candidates.
- Iterative scans: Strict and relaxed ordering modes let the query fetch more results, at the cost of extra work per query.
- Test with real filters: Measure recall using the same filter combinations your application will send, not only unfiltered queries.
- Qdrant filtering: Confirm in the Qdrant documentation how payload filters interact with its index design for your query patterns, and test them the same way.
- Embedding dimension: Filter tests should run with the same vector size your model produces, since index behavior depends on it.
Before deciding, run a recall test with your production filters and confirm the current filter and index behavior in the pgvector README and Qdrant documentation.
Storage decides where each store can run, and this often rules out an option before features are compared. Qdrant requires block-level storage with a POSIX-compatible file system and cannot run on network file systems such as NFS or on object storage such as S3. The installation documentation recommends SSD or NVMe drives. pgvector stores its data in PostgreSQL's own storage, so it follows whatever storage your PostgreSQL deployment already uses.
- Qdrant storage: Use local block devices or block volumes that present a POSIX file system, and verify this with your storage platform team before sizing.
- Qdrant replicas: A replication factor of 2 doubles stored data, so storage planning must include copies.
- pgvector storage: Index size grows with the vector column and index type, so measure index size on a sample load.
- Backups: Qdrant snapshots and PostgreSQL backups follow different procedures, and both need restore tests.
- Infrastructure fit: Confirm which storage classes your Kubernetes or virtualization platform provides before choosing a Qdrant deployment model.
Before committing, ask your storage team which volume types are available and confirm the storage requirements in the current Qdrant installation documentation.
No single store fits every organization, and the choice usually follows from three facts: whether PostgreSQL is already a supported platform, how large and filter-heavy the vector workload will be, and whether a separate stateful service fits the team's operating capacity. The question is less about which product is more capable and more about which set of controls and operations your organization can run and audit.
- Favor pgvector: PostgreSQL is already operated with tested backups and access controls, the embedding size is within the indexed limit, and the workload is modest.
- Favor Qdrant: Vector search is a core service, filtering and scale are central, and the team can run a clustered service with keys, TLS and audit logging.
- Compare patching: Each path adds its own upgrade cycle, so count the number of stateful systems you will maintain.
- Compare audit evidence: Document which product provides authentication, logs and key rotation for your assessment.
- Pilot first: A short pilot with your embedding model and filters gives better evidence than a feature matrix.
Before deciding, confirm the latest Qdrant and pgvector release notes, since both projects change frequently, and ask DeployOpen to test the chosen option in your environment.
Configuration options and when each fits
This table compares the Ollama settings and application choices that govern embedding throughput, memory and exposure on one shared server. Read each row as a decision: the default is the starting point, and the trade-off column shows what changing it costs. The main takeaway is that embedding and chat models draw on the same memory pool, so concurrency settings should be planned for both workloads together.
| Option | What it controls | Trade-off | When it fits |
|---|---|---|---|
| Embedding model and vector length | Dimensions per vector, typically 384 to 1024 depending on the model | Longer vectors increase index size and memory in the vector database | Choose once per collection, since changing models requires re-embedding all stored documents |
| OLLAMA_NUM_PARALLEL | Parallel requests per loaded model, default 1 | Higher values serve more callers but raise memory use per model | Raise it when indexing jobs and live search queries wait on each other |
| OLLAMA_MAX_LOADED_MODELS | How many models stay in memory at once, default 3 per GPU or 3 on CPU | Keeping the embedding and chat models resident saves reload time but uses shared memory | Keep the embedding model loaded when search latency matters alongside a chat model |
| OLLAMA_MAX_QUEUE | Requests waiting before the server rejects new ones, default 512 | A deep queue hides overload and delays failures for indexing clients | Lower it when callers should fail fast and retry rather than wait |
| OLLAMA_HOST | Interface and port the API listens on, default 127.0.0.1:11434 | Binding beyond localhost exposes an API with no built-in authentication | Keep the default and place a authenticated proxy in front for other hosts |
| OLLAMA_MODELS | Directory where model files are stored | Moving storage to a larger or faster volume needs matching file permissions | Use when model files outgrow the system disk or must sit on managed storage |
| Batch size in the application | Number of text chunks sent per embedding request | Larger batches improve throughput but raise peak memory and per-request latency | Start small, measure, then increase while watching memory on the server |
Planning memory and batching for mixed embedding and chat workloads
Embedding and chat models can share one Ollama server, but they compete for the same memory and the same request slots, so the plan has to treat indexing as a load source in its own right. Each model loaded into memory takes space that chat sessions also need, and the server's limits decide what happens when both kinds of traffic arrive together. The three controls that matter are OLLAMA_NUM_PARALLEL, which defaults to 1 parallel request per model, OLLAMA_MAX_LOADED_MODELS, which defaults to 3 times the number of GPUs (or 3 on CPU), and OLLAMA_MAX_QUEUE, which defaults to 512 queued requests. During a bulk indexing job, an embedding client can fill the queue with thousands of pending requests, and chat users then wait behind them. Before you run a backfill, confirm these values on your hardware and decide whether a separate Ollama instance for indexing is cheaper than sharing one server.
Batching input reduces the number of HTTP round trips, because /api/embed accepts multiple inputs in one request, but a larger batch raises peak memory while the request runs. Start with small batches, watch memory and latency with the server's logs and ollama ps, and increase the batch size only while chat response times stay within what your users will accept. Set the client's concurrency to match OLLAMA_NUM_PARALLEL so the indexer does not flood the queue. The number of inputs per batch and the number of concurrent workers are the two settings to tune together, and neither has a universal value.
Run the first full index in an off-peak window, then measure load behavior on the actual hardware rather than relying on any published figure. Benchmark with your own documents, since document length, chunk size and vector dimension (typically 384 to 1024 for embedding models, depending on the model) all change memory use and speed. Record chat latency during the indexing run and set a threshold for it before you start. If the threshold is breached, lower the batch size or worker count, or move indexing to a dedicated instance. Confirm the exact behavior of these settings for your Ollama version against the Ollama FAQ before you publish a capacity plan.
Setup sequence for embeddings on Ollama with Qdrant or pgvector
This sequence takes an embedding model from a pulled model on your own Ollama server to a tested vector store that returns relevant results, with a check at each stage so problems surface before the data is loaded.
Confirm hardware and model storage location
The platform team confirms the host has enough memory for the chosen embedding model alongside any chat models, and sets where models are stored. Ollama keeps models in a default directory per operating system, and the OLLAMA_MODELS variable moves them to another directory. Check the chosen path has free space and is on local disk that the Ollama service user can write to. Done means the server reports the expected storage path and free space is recorded for capacity planning.
Pull the chosen embedding model
The engineer pulls the embedding model onto the server with the Ollama CLI, using the exact model name and tag approved by the team. Record the model's license and source alongside the pull, since model licenses are separate from Ollama's MIT license. Done means the model appears in the local model list with the expected name and tag, and a small test request to the server completes without error.
Bind Ollama to a private interface if needed
By default Ollama listens on 127.0.0.1 port 11434, so other services on different hosts cannot reach it. If Qdrant, pgvector clients or an ingestion job run on other machines, set OLLAMA_HOST to a private interface address, not a public one. Ollama's local API has no authentication, so place it behind a reverse proxy with access control or restrict it at the network layer. Done means a request from the intended client host succeeds and a request from an unapproved network is refused.
Call /api/embed and record the vector length
Send a sample string to the /api/embed endpoint and count the number of values in the returned vector. The length depends on the model, and the documented range for embedding models is typically 384 to 1024 dimensions, so confirm the exact figure from the model you pulled rather than assuming it. Write the dimension and the distance metric to your configuration file. Done means the returned length is recorded and sent twice with the same input produces matching vectors.
Create the vector collection or table
Create the Qdrant collection or the pgvector table with the vector size recorded in the previous step and the distance metric the model is designed for. In pgvector, the column is declared with the dimension, and the vector type supports up to 16,000 dimensions, while approximate indexes apply to columns up to 2,000 dimensions. In Qdrant, the collection is created with the same size. Done means the schema reports the dimension, and a test insert of one vector from Ollama is accepted without error.
Index a test set
Load a small, representative set of documents, generating each embedding through /api/embed and writing it with its metadata and identifiers. Keep batch sizes modest and watch server queueing, since Ollama's parallel request and queue limits are set by configuration. Confirm every returned vector matches the store schema dimension, and count how many records were written against how many were sent. Done means the record count matches the input count and no dimension mismatch errors occurred.
Run a retrieval check
Run a set of known questions with expected source documents through the same embedding model and query the store. Check that the expected documents appear in the top results and that any metadata filters return only permitted records. For pgvector, confirm that filtered queries return enough results, since filtering is applied after the approximate index is scanned. Done means the retrieval results are written up with pass or fail for each question, and failures are fixed before the collection is used by people.
Security and operational risks of exposing embeddings
Embedding models and vector stores are often treated as internal plumbing, but both hold sensitive content in another form. The cards below cover the access, data, provenance and recovery risks that connect the Ollama embedding endpoint to the vector database behind it.
Ollama API has no default authentication
The local Ollama API on port 11434 accepts requests without authentication, and the default bind address is 127.0.0.1. If you change OLLAMA_HOST to serve other machines, anyone who can reach the port can request embeddings, so place an authenticating proxy or gateway in front of it and confirm that nothing listens on a public interface by accident. Check this from a host outside the trusted network.
Qdrant ships without authentication
By default, self-deployed Qdrant instances listen on all network interfaces and have no authentication configured. Before any application connects, enable API keys or JWT-based access control, turn on TLS for REST and gRPC, and confirm the ports are reachable only from the services that need them. Treat a fresh install as exposed until these steps are verified.
Qdrant security docsEmbeddings still carry sensitive content
A vector is a numeric representation of source text, and similarity queries can reveal which documents are close to a given query. Restrict read and write access per collection, keep the vector store on the same trust boundary as the source documents, and enable audit logging of authenticated API operations so you can show who queried what.
Model provenance and patching
The embedding model defines the vector space, so an unapproved or altered model changes search results without any visible error. Record the model name, tag and digest for every embedding, pin the version in your deployment, and keep a schedule for applying Ollama and Qdrant releases. Re-embedding the corpus after a model change is a planned task, not a patch.
Ollama releasesSnapshots and recovery for the vector store
Vector collections are derived data, but rebuilding them means re-embedding the full corpus, which takes compute and time. Schedule Qdrant snapshots, copy them off the cluster, and test a restore into a separate environment. Store snapshots under the same access and encryption rules as the source data, since they contain the vectors and payloads.
Qdrant snapshots docsQuestions buyers ask before serving embeddings on Ollama
Does serving embeddings with Ollama cost money?
The Ollama runtime is free to run on your own hardware. Ollama is open source under the MIT license, and its pricing page states that running models on your own hardware is always unlimited. The paid plans apply to cloud models, which an embeddings deployment on your own servers does not need. The real costs sit elsewhere: the servers or GPUs that hold the embedding model and chat models, the staff who build and operate the pipeline, and the vector store that holds the results. Ask for each of these to be quoted separately. Model licenses also vary, so confirm the license of each embedding model you select before you index production data.
How long does a pilot take, and what drives the timeline?
The timeline depends on the scope you agree in writing, not on the runtime, which installs quickly. The main drivers are document volume and variety, because large or messy corpora take longer to clean and index. Chunking strategy matters next, since the way you split documents changes retrieval quality and needs testing against real questions. The choice of vector store (Qdrant or pgvector) affects the setup and the operational work. Access design is often the longest item: deciding who may search which documents, and enforcing that in the store, takes review with data owners. Most engagements are fixed-scope, so request a written schedule that lists these items separately.
What does the work need from our team?
A pilot needs four roles from your side, and naming them early prevents delays. The first is hardware: a server with enough memory for the embedding model next to any chat model, sized against the model's needs and your expected concurrency. The second is a network owner who decides how the Ollama API and the vector store are reachable, since Ollama binds to 127.0.0.1 port 11434 by default. The third is a data owner who approves which documents are indexed and who may search them. The fourth is a security reviewer who checks access controls, logging and retention. Ask the partner to list which decisions each role must make and by when.
Can our own engineers build this without a partner?
Yes, a capable internal team can build a self-hosted embeddings pipeline, and the tools are open source. The work involves installing Ollama, calling the /api/embed endpoint, choosing a vector store, writing the ingestion and chunking code, and tuning search. The harder parts are usually operational and governance work: sizing memory for two kinds of models, setting up authentication in front of an API that has none by default, configuring Qdrant security since its default instances listen on all interfaces without authentication, and documenting the result for an assessment. Assess whether your team has time for those steps alongside normal duties. A partner is most useful when the review and hardening work is the bottleneck.
Does Ollama see our documents and queries when we run it locally?
No. Ollama states that when it runs locally it does not see your prompts or data. Embedding requests go to your own server, and the text you index stays on infrastructure you control. Two details still need checking. Cloud features can be turned off with OLLAMA_NO_CLOUD=1 or in the server configuration file, which is worth setting explicitly and verifying. Direct cloud inference requires an API key, so keep those keys out of any local pipeline that should stay private. Your vector store and logs are separate systems, so review what they retain as well. Ask your security reviewer to confirm each data path against your policy.
Which vector store should we pair with Ollama embeddings?
The choice depends on your scale, your existing database skills and your access model. Qdrant is an open-source vector search engine under the Apache-2.0 license and is free to self-host, though it needs block storage (SSD or NVMe is recommended) and cannot run on NFS or S3. Its distributed mode is usually run with at least three nodes for quorum. pgvector adds vector search to PostgreSQL, so vectors sit next to relational data and fall under the same backup and access practices. Check the vector length your chosen model produces, since dimension limits and index support differ between the two. Benchmark both against your own documents before committing.
How do we plan memory for embedding and chat models on one server?
Start by listing every model that will be loaded at the same time, then size memory for the total, not for each model alone. Ollama's concurrency settings control how much work runs at once: OLLAMA_NUM_PARALLEL defaults to one parallel request per model, OLLAMA_MAX_LOADED_MODELS limits how many models stay in memory, and OLLAMA_MAX_QUEUE caps queued requests. Embedding batches add load during indexing, which often runs at a different time than search. Plan for indexing jobs and interactive search to compete for the same resources, and test both under realistic document volumes. Confirm the exact defaults for your Ollama version in the FAQ before you set them.
How DeployOpen scopes and delivers self-hosted embedding search
DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside the client's own infrastructure. For embedding search, that means scoping the Ollama embedding model, the vector database and the access path together, then building and testing them in your environment before handover.
How we scope
- Written scope names the embedding model, vector length, document sources and expected query paths before any build starts.
- The scope records whether Ollama shares a host with chat models and how memory will be planned for both.
- Vector database choice between Qdrant and pgvector is documented with storage, filtering and access control requirements.
- Engagements are fixed-scope, with deliverables and timelines agreed in writing. Ongoing support is available as a retainer.
How we build
- Ollama is installed and bound to a private address, with OLLAMA_HOST set and the model directory moved through OLLAMA_MODELS.
- Concurrency settings such as OLLAMA_NUM_PARALLEL and OLLAMA_MAX_QUEUE are tuned against the indexing and query load you define.
- Embedding calls through /api/embed are tested with batching, and the returned vector length is checked against the database schema.
- The vector store is deployed on block storage with authentication, TLS and per-collection or per-table access rules configured.
How we hand over
- Documentation covers the model version, vector dimensions, index settings and the re-embedding steps required when the model changes.
- Runbooks describe how to back up the vector store, restore it and confirm that search results match after a restore.
- Security evidence includes network exposure checks, credential handling and audit logging settings for your compliance team to review.
- Your staff are walked through monitoring, log locations and the upgrade path for Ollama and the chosen database.
How we support
- Retainers can cover Ollama and database upgrades, after the vendor release notes are reviewed against your configuration.
- Security testing of the search API and the Ollama endpoint can be repeated after changes to the model or access rules.
- Support scope, response expectations and change handling are written into the retainer before work begins, so you can confirm them with us.
- Changes to the embedding model are planned as a re-indexing project, with the scope and effort quoted from the written change request.

