Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 

Repository files navigation

🧠 Local RAG System - Complete Guide

Build Your Own Private AI Expert That Answers From YOUR Documents

No cloud. No subscriptions. Your data stays on your machine.

Ollama AnythingLLM License Platform


What is RAG?

RAG (Retrieval Augmented Generation) lets your AI answer questions from YOUR documentsβ€”not just generic internet knowledge.

Instead of the AI making things up, it:

  1. Searches your documents for relevant information
  2. Retrieves the most relevant chunks
  3. Generates an answer grounded in your actual data

Result: No hallucinations. Real answers. From your files.


What You'll Build

By the end of this guide, you'll have:

  • βœ… AI that reads and understands your documents
  • βœ… Ask questions in plain English, get accurate answers
  • βœ… Upload PDFs, TXT, DOCX, MD files
  • βœ… 100% local and private
  • βœ… Works offline

πŸ“‹ 1. Prerequisites

System Requirements

Requirement Minimum Recommended
OS Windows 10/11, macOS 12+, Ubuntu 22.04+ Windows 11, macOS 14+
RAM 8GB 16GB+
Storage 10GB free 20GB+ free
GPU Not required NVIDIA GPU (faster)

Software Requirements

Software Purpose
Ollama Runs local LLM models
AnythingLLM RAG platform with UI

Verify System

Windows (PowerShell):

# Check Windows version
winver

# Check available RAM
systeminfo | findstr "Total Physical Memory"

# Check if Ollama is installed (if you have it)
ollama --version

Linux/macOS:

# Check RAM
free -h

# Check Ollama
ollama --version

πŸ¦™ 2. Install Ollama

Skip this section if you already have Ollama running.

What is Ollama?

Ollama is a local LLM runner. It downloads and runs AI models directly on your machineβ€”no cloud required.


Windows Installation

  1. Download Ollama:

  2. Verify Installation:

    ollama --version
  3. Pull a Model:

    # Pull Llama 3 (8B) - Good balance of speed and quality
    ollama pull llama3
    
    # Or pull Mistral (7B) - Fast and capable
    ollama pull mistral
  4. Test the Model:

    ollama run llama3 "Hello, how are you?"

Linux Installation

# One-line install
curl -fsSL https://ollama.ai/install.sh | sh

# Verify
ollama --version

# Pull model
ollama pull llama3

# Test
ollama run llama3 "Hello!"

macOS Installation

# Download from ollama.ai or use Homebrew
brew install ollama

# Start Ollama service
ollama serve

# Pull model (new terminal)
ollama pull llama3

Recommended Models for RAG

Model Size Best For
llama3 4.7GB General purpose, good quality
mistral 4.1GB Fast, good for Q&A
phi3 2.3GB Lightweight, quick responses
llama3:70b 40GB Best quality (needs 64GB+ RAM)

Pull a model:

ollama pull llama3

Verify Ollama is Running

# Check if Ollama API is accessible
curl http://localhost:11434/api/tags

Expected: JSON response with your models listed.


πŸ“¦ 3. Install AnythingLLM

What is AnythingLLM?

AnythingLLM is an all-in-one RAG platform. It handles:

  • Document upload and processing
  • Chunking and embeddings
  • Vector storage
  • Chat interface

All in one simple application.


Windows Installation (Desktop App)

  1. Download AnythingLLM:

  2. Launch AnythingLLM:

    • Find it in Start Menu
    • Or double-click desktop shortcut

Linux Installation (Desktop App)

# Download AppImage
wget https://anythingllm.com/download/linux

# Make executable
chmod +x AnythingLLM-*.AppImage

# Run
./AnythingLLM-*.AppImage

macOS Installation

# Download from anythingllm.com
# Or use Homebrew
brew install --cask anythingllm

Docker Installation (Alternative)

# Pull and run
docker pull mintplexlabs/anythingllm

docker run -d -p 3001:3001 \
  --name anythingllm \
  -v anythingllm_storage:/app/server/storage \
  mintplexlabs/anythingllm

Access at: http://localhost:3001


First Launch Setup

When AnythingLLM opens for the first time:

  1. LLM Provider: Select "Ollama"
  2. Ollama URL: http://localhost:11434 (default)
  3. Model: Select your pulled model (e.g., llama3)
  4. Embedding Model: Select "AnythingLLM Embedder" (built-in) or "Ollama"
  5. Vector Database: Select "LanceDB" (built-in, no setup needed)

Click "Save and Continue"


πŸ“„ 4. Understanding RAG: Documents β†’ Chunks

The Concept

RAG doesn't feed your entire document to the AI. That would be:

  • Too slow
  • Too expensive (tokens)
  • Often impossible (context limits)

Instead, RAG chunks your document into smaller pieces.


How Chunking Works

Original Document (10 pages)
         ↓
    [Chunk 1] - Paragraph about topic A
    [Chunk 2] - Paragraph about topic B  
    [Chunk 3] - Paragraph about topic C
    [Chunk 4] - Table with data
    [Chunk 5] - Summary section
         ↓
Each chunk = 500-1000 characters

See It In Action

Step 1: Create a Workspace in AnythingLLM

  • Click "New Workspace"
  • Name it: test-rag

Step 2: Upload a Document

  • Click "Upload" or drag-drop a PDF/TXT file
  • Watch the processing status

Step 3: View the Chunks

  • Click on the uploaded document
  • Select "View Chunks" or check document settings
  • You'll see your document split into numbered chunks

Chunk Settings

Setting Default Description
Chunk Size 1000 Characters per chunk
Chunk Overlap 200 Overlap between chunks (context continuity)

Where to adjust:

  • Workspace Settings β†’ Document Processing
  • Or: Settings β†’ Embedding Preferences

Why Chunk Size Matters

Chunk Size Pros Cons
Small (500) More precise retrieval May lose context
Medium (1000) Balanced Good default
Large (2000) More context Less precise

πŸ”’ 5. Understanding RAG: Embeddings

The Concept

Chunks are text. But computers can't search text efficiently for meaning.

Solution: Convert text to numbers (vectors).

This is called an embedding.


How Embeddings Work

"The weather is sunny today"
         ↓
   Embedding Model
         ↓
[0.23, -0.45, 0.67, 0.12, -0.89, ...]
         ↓
   512-1536 numbers representing MEANING

Key insight: Similar text = Similar numbers

"The weather is sunny" β†’ [0.23, -0.45, 0.67, ...]
"It's a bright day"    β†’ [0.21, -0.44, 0.65, ...]  ← Very close!
"I love pizza"         β†’ [0.89, 0.12, -0.34, ...]  ← Very different

See It In Action

Step 1: Upload a document (if not already done)

Step 2: Watch the embedding process

  • AnythingLLM shows "Embedding..." status
  • Each chunk is converted to a vector
  • Progress bar shows completion

Step 3: Check embedding model

  • Settings β†’ Embedding Preferences
  • See which model is creating embeddings

Embedding Model Options in AnythingLLM

Model Speed Quality Setup
AnythingLLM Embedder Fast Good Built-in (default)
Ollama (nomic-embed-text) Medium Better Pull model
OpenAI (ada-002) Fast Excellent Needs API key

To use Ollama for embeddings:

# Pull embedding model
ollama pull nomic-embed-text

Then select "Ollama" as embedder in AnythingLLM settings.


Verify Embeddings Created

In AnythingLLM:

  1. Go to your workspace
  2. Click on uploaded document
  3. Check status: "Embedded" βœ“

πŸ—„οΈ 6. Understanding RAG: Vector Database

The Concept

Embeddings need to be stored somewhere for fast searching.

That's what a Vector Database does.


How Vector DB Works

Document Uploaded
       ↓
Chunked into pieces
       ↓
Each chunk embedded (numbers)
       ↓
Vectors stored in Vector DB
       ↓
Ready for similarity search!

What Happens During a Query

Your Question: "What's the refund policy?"
                    ↓
           Convert to embedding
                    ↓
    [0.34, -0.56, 0.78, 0.23, ...]
                    ↓
      Search Vector DB for similar vectors
                    ↓
    Found: Chunk 7, Chunk 12, Chunk 3
         (most similar to your question)
                    ↓
      Return these chunks to the LLM

Vector DB Options in AnythingLLM

Database Setup Best For
LanceDB Built-in Beginners (default)
ChromaDB Docker More control
Pinecone Cloud Production
Qdrant Docker Advanced

Recommendation: Stick with LanceDB (built-in). No setup needed.


See It In Action

Step 1: After uploading documents, vectors are automatically stored

Step 2: Check vector count

  • Workspace Settings β†’ Documents
  • Shows: "X vectors stored"

Step 3: Test similarity search

  • Ask a question in chat
  • AnythingLLM retrieves relevant chunks
  • Watch "Sources" section show which chunks were used

πŸ’¬ 7. Query β†’ Retrieve β†’ Answer

The Complete RAG Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     YOUR QUESTION                        β”‚
β”‚              "What's the return policy?"                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  EMBED THE QUESTION                      β”‚
β”‚         Convert to vector [0.34, -0.56, ...]            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                SEARCH VECTOR DATABASE                    β”‚
β”‚         Find chunks with similar embeddings              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 RETRIEVE TOP CHUNKS                      β”‚
β”‚    Chunk 7: "Returns accepted within 30 days..."        β”‚
β”‚    Chunk 12: "Refunds processed in 5-7 business..."     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   BUILD PROMPT                           β”‚
β”‚  "Based on the following context, answer the question"  β”‚
β”‚  Context: [Chunk 7] [Chunk 12]                          β”‚
β”‚  Question: "What's the return policy?"                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    LLM GENERATES                         β”‚
β”‚   "The return policy allows returns within 30 days.     β”‚
β”‚    Refunds are processed in 5-7 business days..."       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               ANSWER WITH SOURCES                        β”‚
β”‚        Answer displayed + source chunks shown            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

See It In Action

Step 1: Open your workspace with documents

Step 2: Ask a question in the chat

What does this document say about [specific topic]?

Step 3: Watch the process

  • Query is processed
  • Chunks are retrieved
  • Answer is generated

Step 4: Check the sources

  • Click "Sources" or "Citations"
  • See exactly which chunks were used
  • Verify the answer is grounded in your data

Query Tips for Better Results

Do This Not This
"What does the policy say about refunds?" "Tell me about refunds"
"Summarize section 3 of the document" "Summarize everything"
"What are the three main points about X?" "What's in the document?"
"Compare X and Y from the document" "Compare stuff"

More specific = Better retrieval = Better answers


Retrieval Settings

Setting Default Description
Top K 4 Number of chunks to retrieve
Score Threshold 0.7 Minimum similarity score

Where to adjust:

  • Workspace Settings β†’ Chat Settings
  • Increase Top K for broader context
  • Increase threshold for stricter matching

🎯 8. Real Use Cases

Use Case 1: Query Meeting Notes

Setup:

  1. Create workspace: meeting-notes
  2. Upload meeting transcripts (TXT, MD, DOCX)
  3. Start chatting

Example Queries:

What were the action items from last week's meeting?
Who is responsible for the marketing campaign?
What decisions were made about the Q4 budget?
Summarize all discussions about Project Alpha

Use Case 2: Company Policy Documents

Setup:

  1. Create workspace: company-policies
  2. Upload HR docs, policy PDFs, handbooks
  3. Start chatting

Example Queries:

What is the remote work policy?
How many vacation days do employees get?
What's the process for expense reimbursement?
What are the rules about using company equipment?

Use Case 3: Study From Textbooks

Setup:

  1. Create workspace: study-materials
  2. Upload textbook PDFs, lecture notes
  3. Start chatting

Example Queries:

Explain the concept of [topic] from chapter 5
What are the key formulas in this section?
Create a summary of the main points
Quiz me on the content from pages 50-60

Use Case 4: Technical Documentation

Setup:

  1. Create workspace: tech-docs
  2. Upload API docs, README files, wikis
  3. Start chatting

Example Queries:

How do I authenticate with the API?
What parameters does the /users endpoint accept?
Show me an example of creating a new resource
What are the rate limits?

Use Case 5: Multi-Document Research

Setup:

  1. Create workspace: research-project
  2. Upload multiple related documents
  3. Cross-reference between them

Example Queries:

Compare the findings from document A and document B
What do all three papers say about [topic]?
Find contradictions between these sources
Synthesize the main arguments across all documents

Pro Tips

Tip Why
One workspace per topic Keeps retrieval focused
Clean document names Easier to track sources
Update regularly Add new docs as they come
Test with known answers Verify RAG is working correctly

πŸ” 9. Troubleshooting

Issue: Ollama Not Detected

Symptom: AnythingLLM can't connect to Ollama

Fix:

# Check if Ollama is running
curl http://localhost:11434/api/tags

# If not, start Ollama
ollama serve

Windows: Make sure Ollama is running in system tray


Issue: No Models Available

Symptom: Model dropdown is empty

Fix:

# Pull a model
ollama pull llama3

# Verify
ollama list

Issue: Document Upload Fails

Symptom: Error when uploading PDF

Fixes:

  1. Check file size (some limits apply)
  2. Try converting PDF to TXT first
  3. Check AnythingLLM logs for specific error

Issue: Poor Answer Quality

Symptom: Answers don't match document content

Fixes:

  1. Increase Top K (retrieve more chunks)
  2. Lower threshold (match more loosely)
  3. Re-chunk with smaller chunk size
  4. Be more specific in your questions

Issue: Slow Performance

Symptom: Takes too long to respond

Fixes:

  1. Use smaller model (phi3 instead of llama3)
  2. Reduce Top K setting
  3. Use SSD for storage
  4. Close other applications

Issue: Out of Memory

Symptom: Crash or freeze during processing

Fixes:

  1. Use smaller model
  2. Process fewer documents at once
  3. Increase virtual memory (Windows)
  4. Close other applications

Check Logs

AnythingLLM Desktop:

  • Help β†’ View Logs
  • Or: %APPDATA%/AnythingLLM/logs (Windows)
  • Or: ~/.config/AnythingLLM/logs (Linux)

Docker:

docker logs anythingllm

βš™οΈ 10. Advanced Configuration

Custom System Prompt

Add context-specific instructions:

You are an expert assistant for [Company Name].
Always cite the specific document and section when answering.
If you're not sure, say "I couldn't find this in the documents."
Format answers with bullet points when listing items.

Where: Workspace Settings β†’ System Prompt


Embedding Model Tuning

Use Ollama for better embeddings:

# Pull dedicated embedding model
ollama pull nomic-embed-text

# Or mxbai for better quality
ollama pull mxbai-embed-large

Configure in AnythingLLM:

  • Settings β†’ Embedding Preferences
  • Select "Ollama"
  • Choose embedding model

Chunk Size Optimization

Document Type Recommended Chunk Size
Technical docs 500-800
Policies/Legal 800-1000
Books/Narratives 1000-1500
Meeting notes 400-600

Multiple Workspaces Strategy

workspace: company-hr
  └── policies.pdf
  └── handbook.pdf
  └── benefits.pdf

workspace: project-alpha
  └── requirements.pdf
  └── meeting-notes/
  └── tech-specs.pdf

workspace: personal-notes
  └── journal.md
  └── ideas.txt

Keep workspaces focused for better retrieval accuracy.


API Access

AnythingLLM has an API for programmatic access:

# Chat endpoint
curl -X POST http://localhost:3001/api/v1/workspace/{slug}/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "What is in my documents?"}'

Get API key: Settings β†’ API Keys


πŸ“‹ Quick Reference

Essential Commands

Task Command
Check Ollama ollama --version
List models ollama list
Pull model ollama pull llama3
Run model ollama run llama3
Start Ollama ollama serve
Pull embedding model ollama pull nomic-embed-text

AnythingLLM Shortcuts

Action Where
New Workspace + button in sidebar
Upload Document Drag-drop or Upload button
View Chunks Click document β†’ View Chunks
Adjust Settings Gear icon β†’ Workspace Settings
Check Sources After answer β†’ "Sources" link

RAG Flow Cheat Sheet

Document β†’ Chunks β†’ Embeddings β†’ Vector DB
                                     ↓
Question β†’ Embed β†’ Search β†’ Retrieve β†’ LLM β†’ Answer

πŸ”— Resources

Resource Link
Ollama ollama.ai
AnythingLLM anythingllm.com
AnythingLLM Docs docs.anythingllm.com
Ollama Models ollama.ai/library
LangChain (Advanced) langchain.com
ChromaDB (Advanced) trychroma.com

πŸ“Š RAG vs Regular Chat

Aspect Regular Chat RAG
Knowledge Training data only Your documents
Accuracy May hallucinate Grounded in sources
Up-to-date Cutoff date As current as your docs
Privacy Data sent to cloud 100% local
Customization Generic Domain-specific

Built with 🧠 for Local AI Enthusiasts
Last Updated: March 2026

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors