Chat with your entire AI history.
Index conversations from Pi, Claude Code, Codex, DROID/Factory, Qwen Code, Hermes, OpenClaw, Gemini & more — then query them with a local LLM. Zero cloud. All yours.
Quick Start · Sources · Models · Architecture · Extract Data
LocalBrain is a privacy-first local AI assistant that indexes all your AI conversations — from coding sessions (Pi, Claude, Codex, Hermes, OpenClaw, Factory/DROID, Qwen Code), chat takeouts (Gemini), and notes — then lets you chat with your entire history using GPU-accelerated local inference.
Think of it as a personal second brain that actually remembers everything.
| Feature | Details |
|---|---|
| 10+ sources | Pi, Claude, Codex, OpenCode, Cursor, Factory, Hermes, OpenClaw, Qwen Code, Gemini |
| Hybrid retrieval | BM25 keyword search + cross-encoder reranking (ms-marco-MiniLM-L-6-v2) |
| Local LLM | Qwen 3.5, Gemma 4, Llama 3.3, Mistral — any GGUF via llama.cpp |
| Web UI | Clean chat interface with source citations |
| Personal profile | Edit runtime/personal.json for contextual answers about you |
| 100% private | No cloud APIs, no data leaves your machine, no vector DB, MIT licensed |
# 1. Install dependencies
pip install -r requirements.txt
# 2. Initialize database
python scripts/ops/init_db.py
# 3. Place your data exports in exports/
# (see Data Extraction section below)
# 4. Run full ingestion pipeline
python scripts/ingest/discover.py
python scripts/ingest/classify.py
python scripts/ingest/extract.py
python scripts/ingest/chunk.py
# 5. Start llama-server with a GGUF model
llama-server -m models/qwen3.5-4b.gguf --port 8080 -ngl 99 -c 8192
# 6. Start web UI -> open http://localhost:8096
python scripts/web_server.py
# Or query from CLI
python scripts/query.py "What have I worked on?" --db data/state.db| Source | Extraction | Status |
|---|---|---|
| Pi | pi-brain export pi |
✅ |
| Claude Code | pi-brain export claude |
✅ |
| Codex | pi-brain export codex |
✅ |
| OpenCode | Auto-discovered | ✅ |
| Cursor | Pre-extracted JSONL | ✅ |
| Factory / DROID | Auto-discovered | ✅ |
| Hermes | pi-brain export hermes |
✅ |
| OpenClaw | pi-brain export openclaw |
✅ |
| Qwen Code | Auto-discovered | ✅ |
| Google Gemini | Takeout HTML parser | ✅ |
| Model | Size (Q4_K_M) | Min VRAM | Best For |
|---|---|---|---|
| Gemma 4 12B | ~8 GB | 10 GB | ⭐ Best overall |
| Qwen 3.5 4B | ~3 GB | 4 GB | 🚀 Lightest / testing |
| Qwen 3.5 9B | ~6 GB | 8 GB | 🎯 Sweet spot |
| Qwen 3.5 27B | ~17 GB | 20 GB | 🧠 Best quality |
| Qwen 3.5 60B | ~36 GB | 40 GB | 🔬 Maximum reasoning |
| Gemma 4 48B | ~30 GB | 36 GB | ✍️ Creative writing |
| Llama 3.3 8B | ~5 GB | 6 GB | 🌐 General purpose |
| Mistral Small 3.1 | ~14 GB | 16 GB | 💻 Coding |
Quick pick:
Qwen 3.5 4Bfor testing,Gemma 4 12Bfor daily use,Qwen 3.5 27Bfor best quality. Download GGUF quants from Hugging Face.
No GPU? llama-server runs on CPU too — set gpu_layers: 0 in config/models.yaml. Expect ~10-20 tok/s on a modern CPU with 8B models.
On Mac with M-series chips, llama.cpp auto-detects Metal GPU. Set gpu_layers: 99 for full offload.
+--------------------------------------------------------------+
| LOCALBRAIN |
+--------------------------------------------------------------+
| DATA SOURCES |
| Pi . Claude . Codex . OpenCode . Cursor . Factory |
| Hermes . OpenClaw . Qwen Code . Gemini Takeout |
+---------------------------+----------------------------------+
| v |
| INGESTION PIPELINE |
| discover -> classify -> extract -> chunk -> index |
+---------------------------+----------------------------------+
| v |
| SQLite (content_chunks) + BM25 in-memory index |
+---------------+-------------------+--------------------------+
| v v |
| +-----------+-----+ +--------+-----------+ |
| | Web UI (:8096) | | CLI Query | |
| +-----------+-----+ +--------+-----------+ |
| | | |
| +--------+----------+ |
| v |
| +----------------------------------------------------+ |
| | HYBRID RETRIEVAL | |
| | 1. BM25 -> top 50 candidates (keyword match) | |
| | 2. Cross-encoder -> rerank (semantic scoring) | |
| | 3. Return top 10 | |
| +----------------------------------------------------+ |
| v |
| +----------------------------------------------------+ |
| | llama-server (:8080) | |
| | Qwen 3.5 / Gemma 4 / Llama 3.3 / Any GGUF | |
| | Full GPU offload . Apple Silicon . CPU fallback | |
| +----------------------------------------------------+ |
+--------------------------------------------------------------+
| Approach | Storage | Speed | Accuracy | Complexity |
|---|---|---|---|---|
| BM25 only | None | Fastest | Good | Simple |
| Hybrid (BM25 + reranker) | None | Fast | Best | Moderate |
| Vector embeddings | 622K x 768d (~2GB) | Medium | Good | Complex |
Hybrid retrieval is what production RAG systems actually use. The cross-encoder sees the query and document together (not as independent embeddings), giving much more accurate relevance scores.
npm install -g @0xsero/pi-brain
pi-brain export pi --output exports/pi_sessions.jsonl
pi-brain export claude --output exports/claude_sessions.jsonl
pi-brain export codex --output exports/codex_sessions.jsonl
pi-brain export hermes --output exports/hermes_sessions.jsonlEnhanced pi-brain fork with Factory/DROID, Gemini Takeout & Qwen Code plugins: github.com/0xSero/pi-brain
Auto-discovered from ~/.factory/sessions/:
python scripts/ingest/factory_extractor.pyAuto-discovered from ~/.qwen/projects/*/chats/:
python scripts/ingest/qwen_extractor.py- Download from Google Takeout -> select "Gemini"
- Place ZIP(s) in
exports/ - Extract and normalize:
python parse_gemini_html.py # Streaming parser for 60MB+ HTML files
python normalize_gemini.py # Converts to ingestable JSONLEdit runtime/personal.json so the AI knows about you:
{
"name": "Your Name",
"location": "Your Location",
"hardware": { "gpu": "Your GPU", "ram_system": "Your RAM" },
"tools_used": ["Pi", "Claude Code", "Codex", "Gemini"],
"projects": ["Project 1", "Project 2"],
"interests": ["AI", "coding"]
}Edit config/models.yaml for model paths, GPU layers, and context size.
python benchmark.pyRuns 20 diverse questions scoring retrieval accuracy + LLM answer quality. Typical score: 94% (75/80).
localbrain/
├── config/ # YAML configs (models, sources)
├── data/ # SQLite database
├── exports/ # Raw data sources (takeout ZIPs, JSONL)
├── runtime/ # Web UI (index.html, app.js, style.css)
├── scripts/
│ ├── core/ # Hybrid search (BM25 + cross-encoder), LLM client
│ ├── ingest/ # Pipeline (discover->classify->extract->chunk)
│ └── ops/ # Database operations
├── models/ # GGUF model files (download separately)
├── parse_gemini_html.py # Google Takeout HTML parser
└── benchmark.py # Quality test suite
- 100% local — no data ever leaves your machine
- No cloud APIs — inference runs via llama.cpp on your hardware
- No vector database — BM25 + cross-encoder, zero storage overhead
- SQLite only — no external databases or services
- Open source — audit everything, MIT licensed
| Project | Description |
|---|---|
| pi-brain | Original session extractor — Pi, Claude, Codex exports |
| SergiioB/pi-brain | Enhanced fork with Factory/DROID, Hermes, OpenClaw, Gemini Takeout & Qwen Code plugins |
MIT — do whatever you want with it.