Setup Guide
Walks through cloning, installing dependencies, setting up Ollama, and choosing between a FAISS or Cosmos DB RAG implementation.
What this file does
Walks through cloning, installing dependencies, setting up Ollama, and choosing between a FAISS or Cosmos DB RAG implementation.
When to use it
- Setting up a local RAG system with Ollama embeddings
- Deciding between a simple FAISS backend and a Cosmos DB emulator
- Troubleshooting Cosmos DB connection timeouts or Ollama issues
- First-time configuration of a multi-option RAG project
Assumes this stack
Setup Guide
Complete Setup Instructions
1. Clone Repository
git clone <your-repo-url>
cd localRagComosDB
2. Install Python Dependencies
# Create virtual environment (recommended)
python -m venv .venv
# Activate virtual environment
# Windows:
.venv\Scripts\activate
# Linux/Mac:
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
3. Install and Setup Ollama
Windows / Mac / Linux
- Download from https://ollama.com/
- Install and start Ollama
- Pull required models:
ollama pull mxbai-embed-large
ollama pull llama3
Verify:
ollama list
4. Setup Environment Variables
Copy the example file:
cp .env.example .env
The .env file is already configured with defaults that work for the emulator.
5. Choose Your Implementation
Option A: Simple (FAISS) - No Docker Required
# Load data
python simple/simple_load_data.py
# Test search
python simple/simple_vector_search.py "What is vector search?"
# Run interactive chat
python simple/simple_rag_chain.py
Option B: Cosmos DB - Docker Required
Step 1: Start Cosmos DB Emulator
Using Docker Compose (recommended):
docker-compose up -d
Or using Docker directly:
docker run \
--publish 8081:8081 \
--publish 10250-10255:10250-10255 \
--name cosmos-emulator \
--env AZURE_COSMOS_EMULATOR_PARTITION_COUNT=10 \
--env AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=127.0.0.1 \
--detach \
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
Step 2: Wait for emulator to start (60-90 seconds)
Check status:
docker logs cosmos-emulator
Look for: "Started"
Step 3: Run the application
# Load data
python cosmosdb/load_data.py
# Test search
python cosmosdb/vector_search.py "vector embedding policy"
# Run interactive chat
python cosmosdb/cosmos_rag_chain.py
Troubleshooting
Cosmos DB Connection Timeout
Error:
Connection to 172.17.0.2 timed out
Fix: Make sure you started the emulator with:
--env AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=127.0.0.1
This is already included in docker-compose.yml.
Ollama Not Found
# Check if Ollama is running
curl http://localhost:11434/api/tags
# Restart Ollama
ollama serve
Import Errors
Make sure you installed dependencies:
pip install -r requirements.txt
Certificate Errors
The code automatically handles self-signed certificates with connection_verify=False. No manual certificate installation needed!
Next Steps
- Read
README.mdfor detailed documentation - Explore the code in
simple/for FAISS implementation - Explore the code in
cosmosdb/for Cosmos DB implementation - Customize the data sources in
load_data.pyfiles - Adjust RAG parameters in
.envfile
Quick Reference
Environment Variables
USE_EMULATOR=true # Use local emulator vs cloud
DATABASE_NAME=rag_local_llm_db # Database name
CONTAINER_NAME=docs # Container name
EMBEDDINGS_MODEL=mxbai-embed-large # Ollama embedding model
DIMENSIONS=1024 # Vector dimensions
CHAT_MODEL=llama3 # Ollama chat model
TOP_K=5 # Number of context docs to retrieve
Docker Commands
# Start emulator
docker-compose up -d
# Stop emulator
docker-compose down
# View logs
docker logs cosmos-emulator
# Access Cosmos DB Explorer
# Open in browser: https://localhost:8081/_explorer/index.html
Project Commands
# Simple version
python simple/simple_load_data.py
python simple/simple_vector_search.py "your query"
python simple/simple_rag_chain.py
# Cosmos DB version
python cosmosdb/load_data.py
python cosmosdb/vector_search.py "your query"
python cosmosdb/cosmos_rag_chain.py
What's inside
8 sections: clone, install, Ollama setup, env vars, two implementations, troubleshooting, next steps, quick reference
Change this for your project
- Replace
localRagComosDBwith your own repository name - Replace
mxbai-embed-largeandllama3with your chosen Ollama models - Replace
rag_local_llm_dbanddocswith your own database and container names
Where it goes
A standard operating procedure. Keep where the team or agent running the process will find it.
Worth borrowing
- Offering two implementation paths (simple vs. emulator) lets users start without Docker
- Including a quick reference with environment variables and Docker commands saves repeated scrolling
Related Documents
Comprehensive AI Assistant Tools Reference
Lists 80+ tools with MCP server associations, bulk support, parallel capability, resource impact, and execution type for AI agent workflows.
iOS Deployment Guide
Walks through setting up an iOS development environment, building a Tauri app for iOS, and publishing to the App Store or alternative channels.
How to Add Resources to Your FastMCP Server
Teaches how to add static and dynamic MCP resources to a FastMCP server, with six ready-to-copy examples for a GitHub crawler.
Continue.dev MCP Integration Setup Guide
Walks through configuring Continue.dev to connect an MCP server for spatial transcriptomics tasks, with local and remote setup options.