LocalMind

Privacy-first Agentic RAG knowledge assistant

LocalMind answers questions over your documents and the web.
An agent chooses the right tools, hybrid retrieval finds context, and answers include sources.
Weak local matches are blocked by a retrieval score threshold so the system does not sound confident when the docs do not support the answer.

Local inference uses GGUF models via llama-cpp-python, with hardware detection and optional install of CUDA / Metal / ROCm builds from the Settings UI.


Features

FeatureDescription
Agentic routingChooses local_rag, web_search, both, or none per query
Hybrid retrievalDense embeddings + BM25, fused with tunable α
Score thresholdRejects weak local hits → web fallback or refuse
CitationsSource chips and retrieved context in the UI
Document UIUpload / delete files and Build index in the browser
Settings UIModel path, GPU backend preference, install GPU llama-cpp-python
Hardware accelerationDetects CUDA, Metal, ROCm; Auto / CPU / custom GPU layers
Local GGUFInference adapted from LocalBot
Easy startstart.bat / start.ps1 / start.sh / python run.py

Architecture

User query
    │
    ▼
┌─────────────────────┐
│  Agent (router)     │  propose tool
└──────────┬──────────┘
           │
           ▼
    Local hybrid search?
           │
     ┌─────┴─────┐
     │ score OK? │
     └─────┬─────┘
        yes│    no → web fallback or refuse
           ▼
    Context (local and/or web)
           │
           ▼
    Local GGUF LLM
           │
           ▼
    Answer + sources + route metadata

Retrieval score: after local search, if max_score < retrieval_min_score, local chunks are not used for generation.


Project structure

LocalMind/
├── start.bat / start.ps1 / start.sh / run.py   # easy launchers
├── requirements.txt
├── .env                                        # LLM_MODEL_PATH, GPU settings
├── src/
│   ├── config.py
│   ├── llm.py
│   ├── ingestion/          # load, chunk, pipeline
│   ├── retrieval/          # embeddings, Chroma, hybrid search
│   ├── inference/          # GGUF runtime, hardware, backends
│   ├── agent/              # router, tools, score gate
│   ├── services/           # ingest, config, acceleration install
│   └── ui/app.py           # Streamlit UI
├── data/
│   ├── raw/                # your documents
│   ├── processed/          # chunks.jsonl
│   └── vectorstore/        # Chroma DB
├── scripts/ingest.py       # optional CLI ingest
└── docs/                   # architecture, WBS

Quick start

Windows (easiest)

Double-click start.bat

Or in PowerShell:

cd path\to\LocalMind
.\start.ps1

macOS / Linux

chmod +x start.sh
./start.sh

Already in a venv

python run.py
# or
streamlit run src/ui/app.py

The first run of start.bat / start.sh can create .venv and install dependencies.


First-time setup in the UI

  1. Settings
    • Set GGUF model path (use forward slashes on Windows), e.g.
      C:/Users/you/AppData/Roaming/LocalBot/models/your-model.gguf
    • Save model path
  2. Hardware acceleration
    • Check CUDA / Metal / ROCm detection
    • If GPU is present but not used: open Install matching llama-cpp-python, pick the backend, Install
    • Preferred backend: Auto, GPU layers: -1, Save, Reload engine
  3. Documents
    • Upload PDF / DOCX / TXT / MD → Save uploads
    • Build index
  4. Chat
    • Ask questions
    • Sidebar: Top-K, hybrid α, min retrieval score, weak-local action (web / refuse)

Configuration

.env (project root)

LLM_MODEL_PATH=C:/path/to/model.gguf
LLM_GPU_LAYERS=-1
LLM_PREFERRED_BACKEND=auto
VariableDefaultMeaning
LLM_MODEL_PATHemptyPath to GGUF (empty = mock mode)
LLM_GPU_LAYERS-1-1 auto, 0 CPU, 1+ fixed layers
LLM_PREFERRED_BACKENDautoauto / cuda / metal / rocm / cpu
LLM_CONTEXT_SIZE4096Context window cap
LLM_TEMPERATURE0.1Generation temperature

Also configurable in src/config.py and the UI:

SettingDefaultMeaning
top_k5Chunks retrieved
hybrid_alpha0.6Dense vs BM25 weight
retrieval_min_score0.35Min score to trust local docs
weak_local_actionwebweb fallback or refuse

UI overview

TabPurpose
ChatAsk questions; see tool badge, scores, overrides, sources
DocumentsUpload / delete files; build or rebuild the vector index
SettingsModel path, hardware status, install GPU llama-cpp-python, acceleration mode

Sidebar: retrieval controls, min score, weak-local action, reload engine, clear chat.


Tech stack

LayerTechnology
LanguagePython 3.10+
UIStreamlit
Embeddingssentence-transformers
Vector DBChroma
Keyword searchrank-bm25
LLMllama-cpp-python (GGUF)
Web searchDuckDuckGo (ddgs) — no API key
Documentspypdf, python-docx
Configpydantic-settings + .env

GPU notes

  • Detection shows whether NVIDIA / Apple / AMD hardware is present.
  • Inference uses whatever backend your installed llama-cpp-python was built with.
  • Use Settings → Install matching llama-cpp-python to install CUDA / Metal / ROCm / CPU builds into the current venv.
  • After installing a GPU build: Preferred backend Auto, layers -1, Reload engine.
  • If the UI shows GPU hardware but backend stays cpu, the wheel/build likely has no GPU support — reinstall with the matching backend.

Optional CLI ingest

python scripts/ingest.py

Same pipeline as Documents → Build index (reset collection, embed, upsert).


Roadmap

ItemStatus
Ingestion + hybrid RAG + agentDone
Score threshold + web/refuseDone
UI: chat, docs, settingsDone
Hardware detect + GPU install helperDone
One-click start scriptsDone
Golden evaluation set + metricsPlanned
Streaming answersPlanned
FastAPI API layerPlanned
RerankerPlanned

Related project

LocalBot — private desktop AI assistant (local GGUF, hardware-aware loading, web search, documents).
LocalMind reuses that inference approach inside a focused Agentic RAG system.