Paperless-ngx and Ollama: organizing your documents

Paperless-ngx scans, OCRs, and files invoices, letters, and contracts; connecting Ollama to it adds title and tag suggestions, plus natural-language querying of your documents. This paperless-ngx ollama guide covers a setup where the model runs on the same machine, how to build the index, and above all where human review fits in: the AI suggests, you decide. It's based on the Paperless-ngx 3.4.0 documentation; the procedure was not reproduced for this guide, and no model output in it is presented as observed.
#Paperless-ngx and Ollama: what AI adds to document filing
Paperless-ngx can already classify without an LLM. Each document goes through OCR (OCRmyPDF and Tesseract), then a classic machine learning classifier, trained locally on your own documents, suggests the correspondent, type, tags, and storage path according to the matching rules (Auto, exact word, regular expression, etc.). This works well as soon as you have a few dozen documents already sorted by category, and it requires neither a GPU nor a language model.
The AI features described in the version 3.4.0 documentation (the AI section of docs/advanced_usage.md) add two things the classic classifier doesn't do: generating a readable title from the content, and answering a question about one document or across all indexed documents. The model can be served by Ollama, which lets you keep processing on your machine, provided you verify each link in the chain described below.
- Suggestions
- Title, tags, and other metadata suggested from the document text. These are suggestions shown in the interface for you to accept or ignore.
- Document Q&A
- A conversation about a single document or the indexed collection, following the RAG approach: relevant excerpts are retrieved through semantic search and then passed to the model along with the question.
- What AI doesn't replace
- OCR, the classic classifier, matching rules, and workflows all stay in place. A language model can get a date, amount, or correspondent wrong, so a human still needs to check before you rely on any metadata.
#Paperless-ngx version and prerequisites
Benefit from our experience and a guided path to build your local RAG and work with your own documents.
- Lifetime online access
- PDF + files
- Refunded within 30 days
AI features are a recent addition to Paperless-ngx, and their settings change from one version to the next. This guide follows the documentation frozen at tag v3.4.0 of the official repository. Before making any changes, note the version you actually have installed and read the documentation for that tag, not the main branch.
- Paperless-ngx deployed with Docker Compose
- The examples are based on the official Compose files, where the main service is named webserver. Adjust accordingly if you use a bare-metal installation.
- Recent backup
- Run an export with document_exporter and back up the volumes before changing the configuration. Suggestions don't change anything on their own, but an image update does.
- OCR configured for French
- PAPERLESS_OCR_LANGUAGE: fra if your documents are in French. The model reads only the extracted text: mediocre OCR yields mediocre suggestions.
- Memory for the model
- Rough guide at Q4_K_M: a 7B needs about 5 GB of VRAM, a 14B about 9 GB. A model with 8 to 9 billion parameters such as qwen3.5:9b falls between the two; a 12 GB RTX 3060 or a 24 GB Mac M4 Pro is enough for this size. Without a GPU, processing is still possible on the CPU, just more slowly.
- Fictitious test documents
- Three or four made-up PDFs (an invoice from a fictional supplier, a template letter) to validate the pipeline before running real documents through it.
#Step 1: Run Ollama alongside Paperless-ngx
Paperless-ngx runs in a container, so from its point of view, localhost means the container itself, not your machine. Ollama's default address, http://localhost:11434, therefore won't work as-is from Paperless. The cleanest solution is to add Ollama as a service in the same Compose file without publishing its port: only the project's containers can then reach it, at http://ollama:11434.
If Ollama is already installed natively on the machine, you can keep it: the address to give Paperless then becomes the host's address as seen from the container (host.docker.internal under Docker Desktop, or an extra_hosts entry with host-gateway on Linux). In that case, Ollama must listen on an interface reachable by the container, which potentially exposes it to the local network as well: Ollama has no built-in authentication, so filter it at the firewall or use the Compose variant above instead.
#Step 2: Enable Paperless-ngx AI with the Ollama backend
AI is disabled by default. You enable it through environment variables on the webserver service, described on the Configuration page of the documentation (docs/configuration.md for the same tag). Depending on the version, some settings can also be changed from the application configuration in the admin interface. The names below belong to the PAPERLESS_AI_ family: check them against the Configuration page for your version before copying them, because a typo in a variable name is silently ignored.
- PAPERLESS_AI_LLM_BACKEND
- Selects the language model provider. With ollama, requests go to the address set in PAPERLESS_AI_LLM_ENDPOINT. The other documented value targets an OpenAI-compatible API, which may be a remote service.
- PAPERLESS_AI_LLM_MODEL
- The exact model name as shown in ollama list, including the tag. A name that doesn't exist on the server causes an error when a suggestion is generated, not at startup.
- PAPERLESS_AI_LLM_EMBEDDING_BACKEND
- The model that turns documents into vectors for the index. The Hugging Face backend computes embeddings inside the Paperless container, but the model first has to be downloaded from the Hub: plan for that network access on first use, or a pre-populated cache if the machine is isolated.
- Choosing the language model
- A mid-size multilingual instruct model is enough to suggest a title and tags. A bigger model won't fix bad OCR, so start small and compare results on your dummy documents.
#Step 3: Build and maintain the document index
Document chat relies on a vector index that is separate from Paperless's full-text search index. It's built from each document's OCR text, which is split into chunks and then converted into vectors by the embedding model. Until this index exists and is up to date, chat can't retrieve the relevant passages.
- 01Initial indexingThe documentation provides a management command for the AI features index (document_llmindex), with a full rebuild and an incremental update. In the Docker image, management commands are called directly by name via docker compose exec webserver. Display the help first to confirm which subcommands are available in your version.
- 02Scheduled updateA scheduled task updates the index regularly; its frequency is set with a cron-style variable documented on the Configuration page (PAPERLESS_AI_LLM_INDEX_TASK_CRON). Between two runs, a newly added document may not be queryable yet.
- 03Rebuilding after changing the embedding modelVectors computed by two different models are not comparable. If you change PAPERLESS_AI_LLM_EMBEDDING_BACKEND or the associated model, run a full rebuild rather than an update.
- 04Monitor the durationOn a large archive, the first run can take a long time, especially on CPU. Run it outside working hours and watch the worker logs; no reference duration is given here, since it depends on volume, hardware, and model.
#Step 4: title and tag suggestions, with human review
Once AI is enabled, suggestions appear in a document's detail view, in the same place as the classic classifier's suggestions. They aren't applied automatically: you click the ones you want to keep, then save. That's the behavior to preserve in your workflow, so avoid any automation that would accept suggestions without review.
- 01Flag incoming documents with an inbox tagPaperless-ngx lets you designate a tag as an inbox tag: it's applied to every new document. Use it as your “to review” queue instead of inventing a parallel workflow.
- 02Open the document and compare it with the fileRead the title suggestion alongside the document preview, not just the OCR text. A date or amount misread by OCR can end up in the suggested title.
- 03Accept, correct, or ignoreKeep only tags that already exist in your filing scheme. If the model suggests a new tag, check whether it duplicates an existing one ("Facture" and "Factures") before creating it.
- 04Remove the inbox tagThis step records human approval: a document without this tag has been reviewed. A saved view filtered on the tag lists everything still waiting for review.
- 05Fix the rules instead of repeating correctionsIf you keep correcting the same thing, adjust the correspondent or document type matching, or create a deterministic workflow. The classic classifier also learns from your corrections when it's retrained.
#Step 5: Query your documents in natural language
Chat lets you ask a question about an open document or about all indexed documents, for example "What is the end date of the Exemple SARL contract?". Paperless retrieves the closest chunks from the index, passes them to the model along with the question, and the model writes an answer. This is how a classic RAG works, with its strengths and limitations.
- Verify the source
- A fluent answer is not proof. Open the cited document and find the relevant sentence before acting on a due date or an amount.
- Long documents
- Only a few chunks are sent, and the context window configured on the Ollama side limits what the model reads. Information outside the selected chunks can be ignored without warning.
- Index lagging behind
- A document added after the last update run can't be queried yet. If you just imported a batch, run the update again.
- Access permissions
- If multiple accounts share the instance, use dummy documents and an account with restricted permissions to verify that the conversation draws only on documents visible to that account. Don't assume this behavior without checking it in your version.
#Where your document data goes
Enabling AI in Paperless-ngx doesn't, on its own, guarantee that your documents stay on the machine. Document text is sent to the language model for every suggestion and every conversation, and to the embedding model during indexing. So everything depends on where these two models run.
- Ollama in the same Compose project, local model
- The text stays on the machine. This is the setup described in this guide.
- Ollama on another server
- The text travels over the network to that server, in plaintext if the connection isn't encrypted. On a local network you control, that's a defensible choice; over the Internet, your documents leave your infrastructure.
- OpenAI-compatible backend pointing to a third-party service
- Your documents' text is sent to this provider and is subject to its terms. The Paperless-ngx documentation itself flags this privacy concern.
- Cloud model via Ollama
- Same situation as a third-party service, despite a local address on the Paperless side (see the warning in step 1).
- Downloads
- Pulling the Docker images, the Ollama model, and the Hugging Face embedding model requires network access. These downloads don't send out your documents, but they do reveal that the installation exists.
#Troubleshooting Paperless-ngx with Ollama
- No AI suggestions in the UI
- Check that PAPERLESS_AI_ENABLED is actually being read (container recreated with docker compose up -d after the change), that the installed version offers these features, and review the webserver logs at startup.
- Connection error to Ollama
- The localhost address was used from inside the container, the ollama service isn't running, or native Ollama is listening only on 127.0.0.1. Rerun the Python test from step 1 inside the webserver container.
- Model not found
- The name in PAPERLESS_AI_LLM_MODEL doesn't exactly match ollama list (missing tag, capitalization). Copy the name from the command output.
- Suggestions very slow or failing
- Either the model is loading on the first request, or there isn't enough VRAM and Ollama falls back to the CPU. Check docker compose logs ollama, and pick a smaller model or a Q4_K_M quantization.
- Inconsistent titles
- First, check the document's OCR content in Paperless: empty or error-ridden text (wrong OCR language setting, poor-quality scan) explains most nonsensical suggestions.
- Chat ignores a document
- The index is out of date, or it was built with a different embedding model. Run an update, or a full rebuild if you changed models.
#Go further
- Understanding document chat
- Local RAG: an introduction (/guide/rag-local-introduction), covering chunking, embeddings, and the limits of semantic search.
- Improve OCR upstream
- Free PDF OCR with OCRmyPDF (/guide/ocr-pdf-gratuit-ocrmypdf), the engine used by Paperless-ngx, to understand what determines the quality of the extracted text.
- Ollama in a container
- Ollama with Docker: installation and first model (/guide/ollama-docker-installation-guide), covering GPU access in Docker and model management.
- Don't expose Ollama
- Securing your Ollama server (/guide/securiser-serveur-ollama), if Ollama runs on a different machine from Paperless-ngx.
Feedback, an error, or a clarification? Let us know—it improves the guide for everyone.