Featured project

๐Ÿ“š RAG pipeline + vector DB

Feed your own documents into your local LLM. Chroma vector DB + your Ollama instance from the Local AI gateway, all on your tailnet, all private.

Featured AI/ML Advanced Weekend Prereqs: Local AI gateway project

Why this project

"Chat with your docs" is one of the most useful patterns for personal LLM use โ€” research notes, journal entries, manuals, code documentation. Cloud RAG offerings exist but you have to upload everything to someone else's servers. With local Ollama + a local vector database, you get the same capability with nothing leaving your home network.

RAG (Retrieval-Augmented Generation): when the user asks a question, retrieve relevant snippets from a vector database via semantic search, then prompt the LLM with the question plus those snippets as context. The LLM answers using your snippets as ground truth.

Who this helps

What you get

USER EMBED RETRIEVE AUGMENT + GENERATE RESPONSE โ“ "what does X say?"user question ๐Ÿ”ข embed querynomic-embed-text via Ollama ๐Ÿ“š Chromavector similarity search ๐ŸŽฏ top-k snippets5 most relevant ๐Ÿค– Ollama (e.g. llama3.1:8b)prompt = question + retrieved snippets"Answer using ONLY the snippets below..." ๐Ÿ“ grounded answer

Each step lives on your tailnet. Question โ†’ embedding (Ollama) โ†’ vector search (Chroma) โ†’ top-k snippets โ†’ augmented prompt โ†’ final answer (Ollama). All inference local; nothing sent to the cloud.

Prerequisites

Steps

Spin up Chroma ~5 min

docker run -d \
  -p 8000:8000 \
  -v chroma-data:/chroma/chroma \
  --name chroma \
  --restart always \
  chromadb/chroma

Verify: curl http://localhost:8000/api/v1/heartbeat should return JSON.

Get an embedding model in Ollama ~3 min

Embeddings turn text into vectors. We need a model for that:

ollama pull nomic-embed-text

Small (~270MB) model dedicated to producing semantic embeddings.

Set up a Python project ~5 min

mkdir ~/rag && cd ~/rag
python3 -m venv .venv
source .venv/bin/activate
pip install chromadb requests

Write the ingestion script ~15 min

Save as ingest.py:

import os, sys, requests
from pathlib import Path
import chromadb

OLLAMA = "http://localhost:11434"
CHROMA = chromadb.HttpClient(host="localhost", port=8000)
COLL = CHROMA.get_or_create_collection("docs")

def embed(text):
    r = requests.post(f"{OLLAMA}/api/embeddings",
                      json={"model": "nomic-embed-text", "prompt": text})
    return r.json()["embedding"]

def chunk(text, size=500, overlap=50):
    chunks = []
    for i in range(0, len(text), size - overlap):
        chunks.append(text[i:i + size])
    return chunks

def ingest(path):
    text = Path(path).read_text()
    for i, c in enumerate(chunk(text)):
        COLL.add(
            ids=[f"{path}-{i}"],
            documents=[c],
            embeddings=[embed(c)],
            metadatas=[{"source": str(path), "chunk": i}],
        )
    print(f"Ingested {path}")

if __name__ == "__main__":
    for p in sys.argv[1:]:
        ingest(p)

Test:

python ingest.py ./notes/*.md ./book.txt

Write the query script ~15 min

Save as query.py:

import sys, requests
import chromadb

OLLAMA = "http://localhost:11434"
CHROMA = chromadb.HttpClient(host="localhost", port=8000)
COLL = CHROMA.get_collection("docs")

def embed(text):
    r = requests.post(f"{OLLAMA}/api/embeddings",
                      json={"model": "nomic-embed-text", "prompt": text})
    return r.json()["embedding"]

def ask(question, k=5):
    results = COLL.query(query_embeddings=[embed(question)], n_results=k)
    snippets = "\n\n---\n\n".join(results["documents"][0])
    prompt = f"""Answer using ONLY the snippets below. If they don't contain the answer, say so.

Snippets:
{snippets}

Question: {question}

Answer:"""
    r = requests.post(f"{OLLAMA}/api/generate",
                      json={"model": "llama3.1:8b", "prompt": prompt, "stream": False})
    return r.json()["response"]

if __name__ == "__main__":
    print(ask(" ".join(sys.argv[1:])))
python query.py "what does my book say about networks"

Expose via Tailscale Serve ~5 min

Wrap query.py in a small Flask app, then:

sudo tailscale serve --bg --set-path=/rag http://localhost:5000

From any tailnet device, you can now POST queries:

curl https://ai-rig.tail-abc.ts.net/rag \
  -d '{"q": "summarize the meeting notes"}'

Or use Open WebUI's built-in RAG ~10 min

Open WebUI (from the Local AI project) supports RAG natively. Upload docs in its UI; it handles chunking, embedding, and retrieval automatically. No script needed.

Recommendation: use Open WebUI for chat-with-docs unless you need custom logic. The scripts above are educational; the production answer is "use Open WebUI's built-in RAG."

Verify

Common issues

Variations

Caveats

Where this leads