Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

personal-brain

A local RAG (Retrieval-Augmented Generation) system over your own notes, PDFs, and web pages. Ask natural-language questions and get answers grounded in your own documents — with all inference running locally via Ollama. No API keys. No data leaves your machine.


How it works

  1. Ingest — documents are split into overlapping chunks and embedded using nomic-embed-text
  2. Store — embeddings are persisted in a local Chroma vector database
  3. Query — your question is embedded, the closest chunks are retrieved, and llama3.2 synthesizes an answer

Prerequisites

  • Python 3.10+
  • Ollama — local model runtime

Install Ollama

# macOS
brew install ollama

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

# Windows — download from https://ollama.com/download

Pull the required models (one-time)

ollama pull llama3.2          # LLM for answering questions (~2 GB)
ollama pull nomic-embed-text  # embedding model (~274 MB)

Smaller/faster alternatives: ollama pull llama3.2:1b (1 GB) or ollama pull phi3 (2.3 GB). Set LLM_MODEL=phi3 in your .env to switch.


Setup

git clone https://github.com/loudowl/personal-brain.git
cd personal-brain

python3 -m venv .venv
source .venv/bin/activate      # macOS / Linux
# .venv\Scripts\activate       # Windows

pip install -r requirements.txt
cp .env.example .env           # optional — defaults work out of the box

Quick start

# Make sure Ollama is running
ollama serve &   # or start the Ollama desktop app

# Ingest the example document to verify your setup
python brain.py ingest examples/

# Ask a question
python brain.py query "How does retrieval work?"

# Show which documents were used
python brain.py query "What input types are supported?" --sources

Usage

Ingest

# A directory of notes (markdown, PDF, txt — recursive)
python brain.py ingest ~/notes/

# A single file
python brain.py ingest ~/Documents/paper.pdf
python brain.py ingest ~/notes/meeting_2026-05.md

# A web page
python brain.py ingest --url https://example.com/article

# Re-ingest after editing a document
python brain.py ingest ~/notes/ --force

Supported file types: .md, .txt, .pdf, .docx, .html, and more via LlamaIndex readers.

Query

# Ask a question
python brain.py query "What are my key projects this quarter?"

# Show source documents alongside the answer
python brain.py query "Summarize my notes on machine learning" --sources

# Retrieve more context for complex or broad questions
python brain.py query "What decisions did we make in Q1?" --top-k 10

Manage

python brain.py status    # show model config, chunk count, and all ingested sources
python brain.py clear     # wipe the index and start fresh (asks for confirmation)
python brain.py clear --yes   # skip confirmation

Configuration

All settings can be overridden in .env:

Variable Default Description
LLM_MODEL llama3.2 Ollama model used for answering
EMBED_MODEL nomic-embed-text Ollama model used for embeddings
OLLAMA_BASE_URL http://localhost:11434 Ollama server address
CHUNK_SIZE 512 Token chunk size for splitting docs
CHUNK_OVERLAP 64 Overlap between chunks
TOP_K 5 Chunks retrieved per query

Troubleshooting

Ollama is not running Start it with ollama serve, or launch the Ollama desktop app.

Slow first query The first query loads the model into memory — subsequent queries are much faster.

Answer seems incomplete or off-topic Try --top-k 10 to retrieve more context. Also check python brain.py status to confirm the relevant source was ingested.

Re-ingesting after edits Documents are skipped if their path is already in the index. Use --force to re-embed updated files.

PDF not loading Make sure pypdf is installed: pip install pypdf.


Stack

  • Ollama — local LLM and embedding inference
  • LlamaIndex — document loading, chunking, and RAG pipeline
  • Chroma — local persistent vector database
  • nomic-embed-text — open-source embedding model
  • llama3.2 — default local LLM

Ideas for extending this

  • Web UI (Gradio or Streamlit) for a chat-like interface
  • Watch mode — auto-re-ingest when files in data/ change
  • Multi-collection support (separate indexes for work vs. personal notes)
  • Hybrid search (vector + keyword BM25) for better recall
  • Export answers to markdown with source citations

License

MIT

About

Local RAG over personal notes, PDFs, and web pages — powered by Ollama, LlamaIndex, and Chroma. No API keys.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages