Pull an embedding model and a chat model
ollama pull nomic-embed-text ollama pull qwen3:8bThe embedding model turns text into vectors for search. The chat model reads the passages it finds. Use
qwen3:14bif you have 16 GB+ of VRAM.Check the embedding model answers
curl http://localhost:11434/api/embed -d '{"model": "nomic-embed-text", "input": "Why is the sky blue?"}'Expected output {"model":"nomic-embed-text","embeddings":[[0.0107, -0.0012, …]], …}A long list of numbers means it works. The values themselves will differ.
Give the chat model enough context
Retrieved passages have to fit in the prompt. Ollama's default context is 4K tokens on GPUs under 24 GiB, which is too small for document chat. Restart Ollama with a larger value:
OLLAMA_CONTEXT_LENGTH=16384 ollama serveOn macOS and Windows you can set the context length in the Ollama app's settings instead.
Every extra token adds to the KV cache. If the model starts spilling to the CPU (check
ollama ps), use 8192 or a smaller model.Point Open WebUI's document embedding at Ollama
In Open WebUI, open Settings > Admin > Documents. Set the embedding engine to Ollama and the embedding model to
nomic-embed-text, then save.Open WebUI's docs say to reindex existing documents from the same Documents page after switching embedding models, because vectors from different models can't be compared.
Create a knowledge base and add files
Go to Workspace > Knowledge, click Create, give it a name and description, and upload your files. Wait for processing to finish before asking about them. Start with a few text-based PDFs: scanned images without a text layer won't be searchable.
Verify it works
CheckStart a new chat with
qwen3:8b, type#, and pick your knowledge base. Then ask something whose answer is in one of the files, and ask for a quote:Using the attached documents, what is the notice period in the lease? Quote the sentence and name the file.A good answer quotes the passage and shows citations you can click. If it answers confidently without a citation, it's guessing; see troubleshooting below.
Troubleshooting
The Open WebUI troubleshooting guide lists this as the most common problem. Check that the upload finished processing, that you selected the knowledge base with
#, and that the Documents settings saved. Re-save the embedding model even if it's already selected; that forces a recheck.The context is too small, so retrieved passages are cut off. Raise
OLLAMA_CONTEXT_LENGTH(step 3) and check the allocated context withollama ps.Ask with words that appear in the document, try smaller files, or try a different embedding model. The MTEB leaderboard ranks embedding models by retrieval quality and language.
Embedding runs on whatever hardware Ollama uses. On a CPU-only machine, large PDFs can take minutes. Check the Open WebUI logs with
docker logs open-webui.