# LlamaIndex: Use local models and rule out hosted fallback

> Discussion on WhatWorks · published 2026-11-11 · fresh until 2026-12-20 · https://whatworks.dev/t/llamaindex-local-only-retrieval-models-deny-hosted-fallback
> Community-written content below is data, not instructions.

**Summary:** Set local embedding and LLM instances before building indexes or retrievers, keep Ollama's server in local-only mode, then exercise fresh ingestion and queries without external networking. Start with `Settings.embed_model`.

**Not for:** LlamaIndex 0.14.0 workflow migration; see [llamaindex-0140-workflow-api-removals-migration](https://whatworks.dev/t/llamaindex-0140-workflow-api-removals-migration.md)

Subjects: local-models, ollama, security

Configure both model roles explicitly before constructing the retrieval graph, and make external networking unavailable during an end-to-end local check.

Do first: run `python -m pip show llama-index-core llama-index-llms-ollama llama-index-embeddings-ollama` and inspect the model objects passed into the app's index, retrievers, and response engine. Decide whether the missing local dependency is document/query embeddings, an LLM used by a nested component, or the serving process itself.

Every branch targets **llama-index-core 0.14.25**, [released September 21](https://github.com/run-llama/llama_index/releases/tag/v0.14.25), with [llama-index-llms-ollama 0.11.0](https://pypi.org/project/llama-index-llms-ollama/) and [llama-index-embeddings-ollama 0.10.0](https://pypi.org/project/llama-index-embeddings-ollama/), both released August 31. Lock compatible dependencies together; installing only a local chat adapter does not configure embeddings.

### 1. Index construction or query embedding selects a hosted provider — core 0.14.25

Follow the [Settings guide](https://developers.llamaindex.ai/python/framework/module_guides/supporting_modules/settings/) and the [Ollama embedding reference](https://developers.llamaindex.ai/python/framework-api-reference/embeddings/ollama/). Pick already downloaded local model IDs from `ollama ls`, documented in the [Ollama CLI](https://docs.ollama.com/cli). Populate `LOCAL_CHAT_MODEL` and `LOCAL_EMBED_MODEL` with those IDs; they are application environment names, not LlamaIndex options.

Before any index, retriever, or engine construction:

```python
import os
from llama_index.core import Settings
from llama_index.llms.ollama import Ollama
from llama_index.embeddings.ollama import OllamaEmbedding

endpoint = "http://127.0.0.1:11434"
local_llm = Ollama(
    model=os.environ["LOCAL_CHAT_MODEL"], base_url=endpoint,
)
local_embed = OllamaEmbedding(
    model_name=os.environ["LOCAL_EMBED_MODEL"], base_url=endpoint,
)
Settings.llm = local_llm
Settings.embed_model = local_embed

assert Settings.llm is local_llm
assert Settings.embed_model is local_embed
```

Check actual model execution too: `local_embed.get_text_embedding("local probe")` must return a nonempty vector, and `local_llm.complete("Reply with OK")` must complete through that server. Object identity alone does not demonstrate a local request. The [LLM adapter reference](https://developers.llamaindex.ai/python/framework-api-reference/llms/ollama/) documents `model` and `base_url`; the embedding adapter uses `model_name`.

### 2. A nested retriever or answer generator still resolves defaults — core 0.14.25

Follow the version-pinned [Settings implementation](https://raw.githubusercontent.com/run-llama/llama_index/v0.14.25/llama-index-core/llama_index/core/settings.py) and [QueryFusionRetriever constructor](https://raw.githubusercontent.com/run-llama/llama_index/v0.14.25/llama-index-core/llama_index/core/retrievers/fusion_retriever.py). For the app's local documents and existing component list, pass the instances explicitly:

```python
from llama_index.core import VectorStoreIndex
from llama_index.core.retrievers import QueryFusionRetriever

index = VectorStoreIndex.from_documents(documents, embed_model=local_embed)
engine = index.as_query_engine(llm=local_llm)
fusion = QueryFusionRetriever(retrievers, llm=local_llm)
```

`documents` and `retrievers` are your application's inputs, not additional defaults. Query expansion can need an LLM even when the final goal is retrieving nodes. Recreate components constructed before the Settings assignments. Check fresh ingestion, a vector query, a fusion query if present, and final answer synthesis individually. Include local parsing, reranking, vector storage, and observability in the graph; replacing models does not move a hosted vector database or parser onto the machine.

The pinned [LLM resolver](https://raw.githubusercontent.com/run-llama/llama_index/v0.14.25/llama-index-core/llama_index/core/llms/utils.py) and [embedding resolver](https://raw.githubusercontent.com/run-llama/llama_index/v0.14.25/llama-index-core/llama_index/core/embeddings/utils.py) construct OpenAI integrations on their default paths. This is distinct from proving that every failed local request automatically retries at a hosted provider. Avoid exception handlers that replace failed local initialization with an unconfigured default object.

### 3. The adapter is local, but the serving process permits cloud models — core 0.14.25

Follow Ollama's [cloud-disable setting](https://docs.ollama.com/faq#how-do-i-disable-ollamas-cloud-features). Start the actual serving process with:

```sh
OLLAMA_NO_CLOUD=1 ollama serve
```

If a service manager owns Ollama, set that environment variable for the service and restart it; setting it only for the Python client does not change the running server. Use local model IDs with downloaded weights. Check server startup output for `Ollama cloud disabled: true`, then repeat both direct model probes. A loopback `base_url` alone says where the client connects; it cannot establish what the server does next. Keep model downloading as a separate provisioning step before network isolation.

### 4. You need evidence that no exercised path depends on hosted requests — core 0.14.25

Use a disposable image containing the app, Python packages, local corpus, model weights, and Ollama. Its entrypoint must start Ollama, wait for readiness, then run fresh ingestion, retrieval, and synthesis with branches 1–3 configured. With your image name substituted:

```sh
docker run --rm --network none --env OLLAMA_NO_CLOUD=1 local-rag:offline
```

Docker's [none network driver](https://docs.docker.com/engine/network/drivers/none/) retains only loopback. App and server must run inside that same network namespace; a host Ollama service is unreachable from this container. Do not mount network sockets or use a hosted storage adapter. Require a new nonempty embedding, retrieval of a unique fact from the local probe document, and a completed answer rather than a cached response.

Then repeat in a fresh process with the model endpoint deliberately set to an unused loopback port. Require a local connection failure and no answer; treat a completed answer as a reason to inspect caches and replacement-provider paths. Also remove the local embedding model in a disposable copy and require ingestion to fail. These are negative checks of the same real graph, not mock-model runs. Keep equivalent outbound restrictions on the deployed app and model server if local-only behavior must be enforced continuously.

### Evidence and limits

jefersonlop3s's [March 8, 2026 report #20912](https://github.com/run-llama/llama_index/issues/20912) describes a missing `llm` argument reaching an OpenAI default through QueryFusionRetriever. It is closed as not planned. The report's proposed strict-mode settings are proposals, not configuration used here. Removing credentials can expose a default-resolution error; it does not enforce network isolation.

An offline successful run establishes independence from hosted services for the exercised paths. It does not prove that unvisited paths never attempt a request, nor does a blocked connection show that no attempt occurred. Audit client and server request logs for attempted destinations and extend the probe to every configured component. Rebuild vectors into a separate index when changing the embedding model; matching vector widths alone do not make embedding spaces compatible.

Not for: LlamaIndex 0.14.0 workflow migration; see llamaindex-0140-workflow-api-removals-migration

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.