How to Set Up and Use Local Ollama Models for Offline Wiki Generation with DeepWiki

You can run DeepWiki completely offline by configuring it to use Ollama as both the embedding engine and text generator, eliminating the need for external API keys while keeping all data processing local.

DeepWiki is an open-source tool that transforms code repositories into interactive documentation wikis. By leveraging local Ollama models for offline wiki generation with DeepWiki, you can create comprehensive documentation without sending proprietary code to third-party cloud services. This guide walks through the exact configuration steps, source code architecture, and practical implementation based on the AsyncFuncAI/deepwiki-open repository.

Why Use Local Ollama Models for Offline Wiki Generation?

Running DeepWiki with local Ollama models provides three critical advantages for developers working with sensitive codebases. First, complete data privacy ensures your source code never leaves your local machine during the embedding and generation phases. Second, zero API costs eliminate per-token pricing associated with commercial LLM providers. Third, offline capability allows documentation generation in air-gapped environments or locations with unreliable internet connectivity.

The architecture achieves this by routing all LLM and embedding requests to a local Ollama server running on http://localhost:11434 (or your configured OLLAMA_HOST), rather than external endpoints.

Architecture Overview

Understanding how DeepWiki integrates with Ollama requires examining the specific components that handle model communication, configuration dispatching, and document processing.

OllamaClient and API Communication

The OllamaClient class serves as the primary interface between DeepWiki and your local Ollama instance. Located in api/websocket_wiki.py and api/simple_chat.py, this client communicates via HTTP requests to the Ollama API endpoints. When you select the local model option in the UI, the backend instantiates OllamaClient instead of cloud-based providers, ensuring all generate and embed requests route to localhost:11434.

Configuration Dispatcher

The configuration system in api/config.py dynamically loads embedder and generator settings based on environment variables. When DEEPWIKI_EMBEDDER_TYPE is set to ollama, the get_embedder_config() function injects the OllamaClient class into the runtime configuration. Similarly, get_model_config() in api/config.py reads api/config/generator.json to determine that the ollama provider should use the qwen3:1.7b model by default, constructing the appropriate model_kwargs payload for local inference.

Embedding Processor

Unlike cloud providers that support batch embedding, Ollama processes documents individually. The OllamaDocumentProcessor in api/ollama_patch.py handles this limitation by iterating over each code chunk, obtaining single-vector embeddings using the nomic-embed-text model, and validating dimensional consistency across all processed documents. This processor also implements the model-availability guard, checking that required models are installed before attempting generation and logging clear warnings if ollama pull is needed.

Prerequisites and Model Installation

Before configuring DeepWiki, you must install Ollama and download the specific models used for embedding and generation.


# Install Ollama (Linux one-liner)

curl -fsSL https://ollama.com/install.sh | sh

# For Windows or macOS, download from https://ollama.com/download

# Pull the required models

ollama pull nomic-embed-text        # Embedding model for code chunks

ollama pull qwen3:1.7b              # Default generator model for wiki content

Verify Ollama is running by accessing http://localhost:11434 in your browser or running ollama list to confirm both models appear in your local registry.

Step-by-Step Configuration for Offline Wiki Generation

With Ollama installed and models downloaded, configure DeepWiki to route all AI operations locally.

Environment Variables

Create or edit the .env file in the project root to specify Ollama as the embedder and set the local server endpoint:

PORT=8001
OLLAMA_HOST=http://localhost:11434
DEEPWIKI_EMBEDDER_TYPE=ollama

# No API keys required for offline operation

The DEEPWIKI_EMBEDDER_TYPE=ollama variable triggers the configuration dispatcher in api/config.py to load the Ollama-specific embedder client.

Embedder Configuration

DeepWiki uses JSON configuration files to define embedder parameters. Copy the Ollama-specific template to activate local embeddings:

cp api/config/embedder.ollama.json.bak api/config/embedder.json

This file specifies the OllamaClient class and configures it to use the nomic-embed-text model for converting code chunks into vector representations. The OllamaDocumentProcessor in api/ollama_patch.py handles the per-document embedding logic required by Ollama's API structure.

Generator Configuration

The generator configuration in api/config/generator.json already includes the Ollama provider definition, defaulting to the qwen3:1.7b model. When the frontend sends a request with the local model flag enabled, get_model_config() in api/config.py constructs the appropriate model_kwargs payload, specifying the model name and any local-specific parameters required by the Ollama API.

Running DeepWiki with Local Ollama Models

With configuration complete, start both the backend and frontend services to begin generating wikis offline.

Start the Backend

Navigate to the API directory and launch the FastAPI server using Poetry:


# Install Poetry if not present

python -m pip install poetry==2.0.1

# Install dependencies

poetry install -C api

# Run the server

python -m api.main

The backend will connect to Ollama at the OLLAMA_HOST specified in your .env file, validating that the required models are available before accepting generation requests.

Start the Frontend

In a separate terminal, install and launch the Next.js frontend:

npm install
npm run dev

The UI will be available at http://localhost:3000.

Generate Your Wiki

  1. Open http://localhost:3000 in your browser.
  2. Enter a public repository URL (e.g., https://github.com/AsyncFuncAI/deepwiki-open).
  3. Check the "Local Ollama Model" checkbox in the generation options.
  4. Click Generate Wiki.

DeepWiki will now process the repository using OllamaDocumentProcessor for embeddings via nomic-embed-text and generate documentation using qwen3:1.7b (or your configured model) through the local Ollama server, producing a fully interactive wiki without any external API calls.

Summary

Running DeepWiki with local Ollama models provides a complete offline documentation pipeline. Key takeaways include:

  • Privacy-first architecture: All code processing happens locally via the OllamaClient in api/websocket_wiki.py and api/simple_chat.py, ensuring proprietary code never leaves your machine.
  • Configuration-driven setup: Setting DEEPWIKI_EMBEDDER_TYPE=ollama in .env and copying embedder.ollama.json.bak to embedder.json activates the local pipeline.
  • Model-specific processing: The OllamaDocumentProcessor in api/ollama_patch.py handles Ollama's single-document embedding limitation and validates model availability before generation.
  • Default model stack: DeepWiki defaults to nomic-embed-text for embeddings and qwen3:1.7b for generation, both pulled via standard Ollama commands.

Frequently Asked Questions

What hardware requirements are needed to run DeepWiki with Ollama locally?

You need a machine capable of running the selected Ollama models efficiently. For the default qwen3:1.7b generator and nomic-embed-text embedder, a modern CPU with at least 8GB RAM is sufficient, though a GPU with 4GB+ VRAM significantly improves generation speed. Ollama automatically utilizes available CUDA or Metal acceleration on compatible systems.

Can I use different Ollama models than the defaults?

Yes, you can configure alternative models by modifying the configuration files. Edit api/config/generator.json to change the default model name in the ollama provider section, or set environment variables to override the model selection. Ensure you run ollama pull <model-name> to download your chosen model before starting DeepWiki, as the OllamaDocumentProcessor in api/ollama_patch.py validates model availability before processing.

How does DeepWiki handle Ollama's lack of batch embedding support?

The OllamaDocumentProcessor class in api/ollama_patch.py implements a sequential processing strategy. Instead of sending batches of documents to the embedding endpoint, it iterates through each code chunk individually, obtains the embedding vector from the nomic-embed-text model, and validates that all vectors maintain consistent dimensions before storing them. This approach ensures compatibility with Ollama's API while maintaining embedding quality.

Is it possible to run DeepWiki with Ollama in a Docker container?

Yes, DeepWiki supports containerized deployment with Ollama. The README.md file in the repository includes a "Quick Start" section with Docker instructions that allow you to run both DeepWiki and Ollama within containerized environments. You can mount the Ollama socket or use network bridging to connect the DeepWiki container to an Ollama container running on the same Docker network, ensuring the OLLAMA_HOST environment variable points to the correct container address.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →