Skip to main content
AI Tools

Local RAG Workflows with Ollama & ChromaDB

Alex MorganAlex MorganNovember 26, 2026Updated: November 26, 202615 min read

Disclosure: Some links in this article are affiliate links. If you click and make a purchase, we may earn a commission at no extra cost to you. This does not influence our editorial recommendations - we only recommend products and services we genuinely believe in. Read our full affiliate disclosure.

Local RAG Workflows with Ollama & ChromaDB โ€“ featured image

Local RAG Workflows with Ollama and ChromaDB for Private Clients

Just last month, a client came to us with a familiar horror story: their "secure" cloud-based RAG system, built to sift through sensitive legal documents, had a momentary lapse. A misconfigured API key, a forgotten firewall rule, and suddenly, snippets of highly confidential client data were inadvertently exposed to an external logs service. It wasn't a malicious attack, just a blunder, but the fallout was immediate and severe. This isn't an isolated incident; it's a stark reminder that when you hand over your data, even encrypted, to a third-party cloud service, you're also handing over a slice of your control and inherent risk.

That's precisely why, at RemoGrid, we've spent the past six months rigorously testing and building out truly local, air-gapped Retrieval Augmented Generation (RAG) workflows. Our focus? Empowering private clients โ€“ legal firms, healthcare providers, financial advisors, and any business handling sensitive intellectual property โ€“ to harness the power of large language models (LLMs) without ever letting their data touch the public internet. We're talking about running powerful LLMs like Llama 3 and DeepSeek Coder directly on your own hardware, feeding them context from your proprietary documents stored in a local vector database, all without a single byte leaving your network.

This isn't just about cost savings, though those are significant when you're not paying for token usage or API calls. This is about absolute data sovereignty, regulatory compliance, and peace of mind. We've found the combination of Ollama for local LLM management and ChromaDB for vector storage to be a powerhouse for this exact scenario. It's affordable, surprisingly performant, and crucially, puts you back in the driver's seat of your own data.

RemoGrid is reader-supported. When you sign up or purchase through links on our site, we may earn an affiliate commission at no extra cost to you. We test every platform independently.

Why Local RAG? The Privacy Imperative for Client Data

Let's be blunt: the cloud is convenient, but it's not a fortress without its vulnerabilities. For businesses dealing with client data, proprietary research, or classified information, the risks associated with sending that data to external servers, even for processing, are simply too high. Regulatory frameworks like GDPR, HIPAA, CCPA, and countless industry-specific compliance mandates don't just recommend data protection; they demand it. A breach, even an accidental one, can lead to astronomical fines, reputational damage, and a complete erosion of client trust.

When you use a cloud-based RAG service, your documents are uploaded, processed into embeddings, stored in a cloud vector database, and then your queries and retrieved contexts are sent to a cloud LLM. Each step introduces a potential point of failure, a vector for data leakage, or a compliance nightmare. Who owns the data? What are the service provider's logging policies? Are their sub-processors compliant? These questions often lead to vague answers and legal disclaimers that offer little comfort when your client's most sensitive details are on the line.

Local RAG, especially an air-gapped setup, cuts through all that ambiguity. Your data stays on your machines, behind your firewalls, under your direct control. There's no external API to compromise, no third-party server to breach, no vendor terms of service that might change overnight. It's a fundamental shift from trusting a service provider to owning your security. This isn't just about avoiding predatory fees or hidden charges; it's about building a digital infrastructure that truly respects client confidentiality and intellectual property. It's about taking back control.

The Core Components: Ollama and ChromaDB

Building a local RAG system requires two primary ingredients: a way to run powerful language models locally and a place to store and retrieve your document embeddings. Ollama and ChromaDB are, in our testing, the perfect homegrown pairing for this task.

Ollama: Your Local LLM Wrangler

Ollama isn't an LLM itself; it's a fantastic open-source framework that simplifies running large language models on your personal machine. Think of it as a Docker for LLMs, but specifically optimized for local inference. It handles all the complex bits: downloading model weights, setting up the necessary runtime, and exposing a simple API that you can interact with via Python, JavaScript, or even curl.

Before Ollama, getting a local LLM up and running was a multi-hour ordeal involving compiling C++ libraries, wrestling with CUDA drivers, and debugging obscure Python dependencies. Ollama makes it a one-line command. It supports a growing list of popular open-source models like Llama 3, Mistral, DeepSeek Coder, Gemma, and more, in various quantized formats to fit different hardware configurations. This means you can pick a model that balances performance with your system's VRAM capacity.

ChromaDB: The Embeddable Vector Database

ChromaDB is a lightweight, open-source vector database designed for simplicity and ease of use. Unlike massive distributed vector databases, ChromaDB can run entirely in-memory or persist to a local file, making it ideal for single-machine or small-scale local RAG applications. You don't need a separate server, complex deployments, or heavy infrastructure. You just pip install chromadb, and you're ready to go.

Its primary function is to store numerical representations (embeddings) of your document chunks alongside their original text. When you ask a question, ChromaDB quickly finds the most semantically similar chunks to your query by comparing their embeddings. This retrieval step is the "R" in RAG, providing the LLM with relevant context instead of letting it hallucinate or rely solely on its generalized training data.

Together, Ollama and ChromaDB form a potent, privacy-preserving duo. Ollama brings the brainpower, and ChromaDB brings the memory and context. The best part? Neither needs an internet connection to function once models and libraries are downloaded.

Alt text for Local RAG Workflows with Ollama and ChromaDB for Private Clients - Diagram of Local RAG components

Setting Up Your Local RAG Environment (Step-by-Step)

Before we dive into the code, let's talk hardware. Running LLMs locally, especially effectively, demands a decent machine.

Hardware Considerations: The Unsung Hero of Local AI

  • CPU: A modern multi-core CPU (Intel i5/i7/i9 or AMD Ryzen 5/7/9, ideally 8+ cores) is crucial for overall system responsiveness and for offloading some LLM layers if your GPU VRAM is insufficient.
  • RAM: Minimum 16GB, but 32GB or even 64GB is strongly recommended. LLMs can consume a lot of RAM, especially if you're loading larger models or running multiple processes.
  • GPU (VRAM is King): This is the most critical component for performance. NVIDIA: An NVIDIA GPU with at least 8GB VRAM (e.g., RTX 3050/3060/4060) will let you run smaller 7B-8B parameter models efficiently. For 13B-30B models, you'll want 12GB+ VRAM (e.g., RTX 3080/4070 Ti/4080). For larger models, 24GB VRAM (RTX 3090/4090) is ideal. AMD: Ollama has experimental AMD GPU support, but it's less mature than NVIDIA's. Check Ollama's documentation for the latest compatibility. * Apple Silicon (M-series): Excellent performance. The unified memory architecture means your system RAM acts as VRAM. An M1/M2/M3 Pro/Max with 16GB+ unified memory will perform very well.

For our testing, we used a machine with an AMD Ryzen 9 5900X, 64GB RAM, and an NVIDIA RTX 3090 (24GB VRAM). This setup comfortably handles multiple 7B models concurrently or a single 70B model with careful quantization.


Step 1: Install Ollama and Download an LLM

First things first, get Ollama running.

  1. Download Ollama: Visit the official Ollama website (ollama.com) and download the installer for your operating system (macOS, Windows, Linux).
  2. Install: macOS: Drag the Ollama app to your Applications folder. Windows: Run the .exe installer. * Linux: Open your terminal and run: ``bash curl -fsSL https://ollama.com/install.sh | sh ``
  3. Verify Installation: Open a new terminal or command prompt and type: ``bash ollama --version `` You should see the installed version number.
  4. Download an LLM: We'll use deepseek-coder:7b-instruct-q4_K_M for its coding capabilities and reasonable size, or llama3 for general tasks. The q4_K_M indicates a 4-bit quantization, which balances performance and VRAM usage. ``bash ollama pull deepseek-coder:7b-instruct-q4_K_M # Or for a general purpose model: # ollama pull llama3 `` This download can take a while depending on your internet speed and the model size (e.g., 4-8GB for a 7B model).
  5. Test the LLM: ``bash ollama run deepseek-coder:7b-instruct-q4_K_M "Explain the concept of RAG in one sentence." `` You should get a response from your local LLM. If you're air-gapping, ensure you've pulled all necessary models before disconnecting from the internet.

Step 2: Install Python and Required Libraries

You'll need Python 3.9+ and a few essential libraries. We recommend using a virtual environment to keep your project dependencies clean.

  1. Create a Virtual Environment: ``bash python3 -m venv rag_env source rag_env/bin/activate # On Windows: .\rag_env\Scripts\activate ``
  2. Install Libraries: ``bash pip install chromadb langchain langchain-community pypdf ollama ` chromadb: The vector database. langchain: A framework to simplify building RAG chains. langchain-community: Contains various community integrations, including document loaders. pypdf: To load PDF documents. You might need other loaders (e.g., python-docx for .docx, unstructured for more complex formats). * ollama`: Python client for Ollama.

Step 3: Initialize ChromaDB

Now, let's set up ChromaDB to store your document chunks. We'll configure it to persist data to a local directory, so your vector store isn't lost when your script finishes.

Important: For embeddings, while some LLMs can generate them, a dedicated embedding model like nomic-embed-text often provides better semantic representations and is faster. Pull it with ollama pull nomic-embed-text.

Alt text for Local RAG Workflows with Ollama and ChromaDB for Private Clients - Code snippet for ChromaDB initialization


Step 4: Document Ingestion and Chunking Strategies

This is where the magic (and potential pitfalls) of RAG truly begins. How you break down your documents directly impacts the quality of your retrieval. Too large, and the LLM gets too much irrelevant noise. Too small, and crucial context might be split across chunks.

Why Chunking Matters:

LLMs have context window limits. You can't just feed an entire 100-page document into a prompt and expect a useful answer. Chunking breaks down your documents into smaller, manageable pieces. Each chunk is then converted into an embedding. When a query comes in, the system compares the query's embedding to all the chunk embeddings to find the most relevant ones.

Recursive Character Text Splitter:

This is our go-to for most RAG applications. It attempts to split text using a list of characters (\n\n, \n, , '') in order, trying to keep chunks semantically coherent. If a chunk is still too big, it moves to the next splitter.

Let's process some hypothetical client documents. Create a folder named client_data and put a few PDF files in it (e.g., legal_contract.pdf, medical_report.pdf).

Table 1: Document Chunking Strategy Comparison

StrategyChunk Size RecommendationOverlap RecommendationRetrieval Quality ImpactProcessing SpeedMemory ImpactBest Use Case
Recursive Character Split500-1500 chars10-20% of chunk sizeHigh: Preserves context, handles varied document typesModerateModerateMost general-purpose RAG, complex documents
Fixed Size Split200-1000 chars0-10%Moderate: Can split sentences, lose contextFastLowSimple documents, highly structured data, quick tests
Semantic ChunkingVariableVariableVery High: Groups related ideas, minimizes noiseSlowHighHighly nuanced documents, legal, research (complex to implement locally)
Markdown Header SplitVariable0High: Excellent for structured Markdown documentsFastLowCodebases, technical documentation, knowledge bases

Note: "Processing Speed" and "Memory Impact" are relative to the complexity of the chunking algorithm and the number of chunks generated.


Step 5: Generating Embeddings and Storing in ChromaDB

The db.add_documents(chunks) call in the previous step actually handles both generating embeddings (using the OllamaEmbeddings function we passed) and storing them. But let's clarify what's happening.

Each text chunk is fed into the nomic-embed-text model running via Ollama. This model converts the text into a dense vector (a list of numbers) that mathematically represents its semantic meaning. Chunks with similar meanings will have vectors that are "closer" in the vector space. ChromaDB then stores these vectors along with the original text chunk and any associated metadata.

Crucially, because OllamaEmbeddings uses your local Ollama instance, no data leaves your machine during this embedding generation process. It's all happening locally.

Building the RAG Workflow

With our documents chunked, embedded, and stored in ChromaDB, we can now build the RAG query pipeline.

  1. Querying ChromaDB: When a user asks a question, we first convert that question into an embedding using the same embedding model we used for the documents. Then, we ask ChromaDB to find the k (e.g., 4 or 5) most similar document chunks to our query. These are our "retrieved contexts."
  2. Prompt Engineering for Local LLMs: We take the user's original question and the retrieved context chunks and combine them into a single, carefully crafted prompt for the LLM. The goal is to instruct the LLM to only answer based on the provided context, preventing it from pulling information from its general training data, which could be inaccurate or irrelevant.
  3. Integrating with Ollama: Finally, we send this enhanced prompt to our local Ollama LLM (deepseek-coder or llama3) and get its response.

Here's the Python code to tie it all together:

This simple RetrievalQA chain is a powerful starting point. For more complex scenarios, you might explore custom prompt templates, more sophisticated retrieval strategies (e.g., re-ranking, hybrid search), or conversational RAG chains.

Table 2: Local LLM Performance & Resource Comparison for RAG

LLM Model (Ollama Tag)VRAM Required (min)RAM Required (min)Typical Response Time (7B, RTX 3090)Ideal Use CaseLicenseNotes
Llama 3 8B Instruct (q4_K_M)6-8 GB16 GB~2-4 secondsGeneral purpose, chat, summarization, creative textMeta Llama 3Excellent all-rounder, strong reasoning
DeepSeek Coder 7B Instruct (q4_K_M)5-7 GB16 GB~3-5 secondsCode generation, explanation, technical documentationMIT (DeepSeek)Specialized for coding tasks, good for tech client data
Mistral 7B Instruct (q4_K_M)5-7 GB16 GB
#RAG#local LLM#Ollama#ChromaDB#data privacy#AI tools#enterprise AI#air-gapped#Llama 3#DeepSeek

Frequently Asked Questions

You'll typically need at least 16GB RAM, a quad-core CPU, and preferably an NVIDIA GPU with 8GB+ VRAM for decent performance with smaller LLMs like Llama 3 8B or DeepSeek Coder 7B. For larger models, 32GB+ RAM and 12GB+ VRAM are recommended.

An air-gapped system has no network connectivity to external networks. For RAG, this means installing Ollama, ChromaDB, and all dependencies offline, then loading models and data from physical media (USB drive) onto a dedicated, isolated machine.

Yes, you can use local embedding models like Sentence Transformers or a dedicated Ollama embedding model. For complete air-gapped security, ensure the embedding model is downloaded and loaded locally, not accessed via an API call.

Recursive character text splitting is often best. Start with larger chunks (e.g., 1000 characters) and a significant overlap (e.g., 200 characters). Experiment with different sizes and overlaps to find the optimal balance that preserves context without creating overly large chunks that dilute relevance.

You'll need to download the updated Ollama model files onto a separate, internet-connected machine, then securely transfer them via physical media (encrypted USB drive) to your air-gapped system. Follow Ollama's documentation for manual model installation.

Common pitfalls include insufficient hardware, poor document chunking leading to irrelevant retrievals, not adequately securing the local machine, neglecting to regularly back up the vector database, and failing to properly test the RAG chain for accuracy and privacy compliance.

Alex Morgan - Founder & Lead Editor
Alex MorganยทFounder & Lead Editor

Alex Morgan is the founder and lead editor of RemoGrid. With over six years of hands-on experience in remote operations, cross-border freelance workflows, and AI tool benchmarking, Alex independently tests and audits software platforms to help modern digital workers build sustainable online income streams. He regularly reviews international payment systems (Wise, Stripe, Payoneer, local mobile wallets) and conducts real-world usability benchmarks across AI productivity tools.

Related Articles

Featured image for Anthropic Computer Use API for FreelancersAI Tools

Anthropic Computer Use API for Freelancers

Deep dive into Anthropic's Computer Use API: real-world freelance applications, GUI automation, prompt engineering, and security for remote work.

#Anthropic#Claude
November 26, 202619 min read
Featured image for Apollo API and Clay Waterfall Enrichment TutorialAI Tools

Apollo API and Clay Waterfall Enrichment Tutorial

Master Apollo.io API and Clay waterfall enrichment to find verified B2B emails, skip single-source errors, and cut bounce rates below 2%.

#clay-com#apollo-io
November 26, 20269 min read
Featured image for Browser-Use AI Agent Guide: Open-Source Web AutomationAI Tools

Browser-Use AI Agent Guide: Open-Source Web Automation

Navigate browser-use AI agents with RemoGrid's expert guide. Learn Playwright, vision models, multi-tab automation, and cost management for open-source web tasks.

#ai agents#web automation
November 26, 202615 min read