Skip to content
raymondlassesPublic

About

Fast, air-gapped multimodal AI desktop search engine. Combines Google SigLIP vision-language embeddings with SQLite FTS5 BM25 keyword matching via Reciprocal Rank Fusion (RRF) for local images, documents, and code.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Search2 - Offline Multimodal AI Desktop Search Engine

Search2 Logo

Fast, private, air-gapped multimodal semantic and lexical search for your local desktop files.

Python Version React 19 Tailwind CSS v4 PyTorch CUDA Google SigLIP SQLite FTS5 PyWebView Edge WebView2 MIT License


Overview

Search2 is an air-gapped, privacy-first desktop search engine that runs entirely on your local machine. It seamlessly searches across both visual media (images, diagrams, screenshots) and documents/text (PDF, DOCX, Markdown, Code, Plain Text) without transmitting a single byte over the network.

Traditional search tools rely solely on file names or brittle substring queries. Search2 pairs Google SigLIP vision-language embeddings with SQLite FTS5 full-text indexing using Reciprocal Rank Fusion (RRF)—allowing you to search for "chart showing revenue growth", "sunset over mountains", or "authentication middleware" and instantly retrieve exact matches and conceptual hits alike.

Search2 is optimized to run smoothly on modern GPUs (RTX series), budget GPUs (NVIDIA GTX 1050 with 2GB–4GB VRAM), and pure CPU environments.


Key Highlights

  • 100% Offline & Private: Zero cloud dependency, no telemetry, no subscriptions, and no external API keys required. All models and indices reside locally.
  • Google SigLIP Multimodal AI: Powered by ViT-B-16-SigLIP (768-dimensional embeddings) trained on WebLI. Uses prompt ensembling (combining photography, screenshot, and document contexts) and zero-centered calibrated similarity scoring for high-accuracy zero-shot retrieval.
  • Hybrid Search (BM25 + Dense Semantic RRF): Combines dense vector cosine similarity with SQLite FTS5 BM25 keyword matching via Reciprocal Rank Fusion ($k=60$), delivering the best of semantic understanding and exact lexical hits.
  • Universal Format Support:
    • Images: PNG, JPG, JPEG, WEBP, BMP, GIF, TIFF (with WebP thumbnail caching).
    • Documents: PDF, Word (.docx), Markdown (.md), TXT, CSV, LOG, RTF.
    • Code: Python (.py), TypeScript (.ts, .tsx), JavaScript (.js, .jsx), HTML, CSS, JSON, SQL, Rust (.rs), Go, C/C++, Java, Shell (.sh, .bash, .ps1, .bat), TOML, YAML, XML.
  • Hardware-Adaptive Auto-Scaler:
    • Tier 1 (GPU $\ge$ 4GB VRAM): Full-speed FP16 CUDA batching (16–32 files/batch).
    • Tier 2 (GPU 2GB–4GB VRAM): Throttled memory-cleared CUDA batching (8–12 files/batch) optimized for budget GPUs like the GTX 1050.
    • Tier 3 (CPU Fallback): Multi-threaded quantized execution with graceful degradation.
  • Controllable Background Indexing:
    • Dedicated background thread with threading.RLock() and threading.Event().
    • Interactive Pause / Resume button directly in the desktop interface.
    • Safe Checkpointing: Safely commits progress to SQLite; closing and relaunching resumes seamlessly without re-indexing processed files.
    • Live File Watcher: Automatically detects newly added or modified files using file hashes and timestamps (mtime).
  • Ultralight Native Desktop Shell:
    • Powered by PyWebView utilizing Windows Microsoft Edge WebView2 runtime (~30–50MB memory footprint vs. 200MB+ for Electron).
    • Custom Windows AppUserModelID (search2.local.ai.desktop) for clean taskbar grouping and branding.
    • Includes a silent launcher (run_app.vbs) that runs with pythonw.exe without an open terminal window.
    • Headless --server-only mode for web browser access or remote instances.
  • Custom Modern Adaptive UI:
    • Dark Mode: Dark Coal (#121316) background with Vivid Yellow (#F5C518) accents.
    • Light Mode: Warm White (#FAF8F5) background with Warm Brown (#8B5A2B) accents.
    • Rectangular Design System: Crisp, modern rectangular cards with subtle borders (rounded-md / rounded-lg).
    • Dynamic Density Scaling: Card dimensions smoothly adapt based on total library count vs. filtered query results.

Architecture

flowchart TD
    subgraph UI ["Desktop Shell & Frontend"]
        Shell["PyWebView (Edge WebView2 Runtime)"]
        ReactApp["React 19 + TypeScript + Tailwind CSS v4"]
        Theme["Dual Theme Engine (Coal/Yellow & Warm White/Brown)"]
        Density["Dynamic Density Grid & Filter Chips"]
        Banner["Real-time Indexer Banner + Pause/Resume"]
    end

    subgraph Backend ["FastAPI Backend (127.0.0.1)"]
        Router["FastAPI REST Endpoints"]
        HW["Hardware Scaler (CUDA Tier Profiler)"]
        Indexer["Background Indexer Worker (Threaded)"]
        Watcher["File System Watcher (mtime / Hash)"]
        
        subgraph NeuralEngine ["AI & Retrieval Engines"]
            SigLIP["Google SigLIP (ViT-B-16, 768-dim)"]
            PromptEnsemble["Prompt Ensembler (Photo / UI / Doc)"]
            FTS["SQLite FTS5 BM25 Engine"]
            RRF["Reciprocal Rank Fusion (k=60)"]
        end

        DB[("SQLite Storage (WAL Mode)\nFiles · Folders · Vector Blobs · FTS5")]
        Thumbs["WebP Thumbnail Cache"]
    end

    ReactApp <--> Shell <--> Router
    Router --> Indexer
    Indexer --> Watcher
    Indexer --> NeuralEngine
    NeuralEngine --> DB
    Indexer --> Thumbs
    Router --> RRF --> DB
Loading

Supported File Formats

Category Extensions Indexing Method
Images .png, .jpg, .jpeg, .webp, .bmp, .gif, .tiff SigLIP visual embeddings + WebP thumbnails
Documents .pdf, .docx, .txt, .md, .csv, .log, .rtf Text extraction (pypdf, python-docx), FTS5 BM25 + SigLIP text embeddings
Code .py, .ts, .tsx, .js, .jsx, .html, .css, .json, .sql, .rs, .go, .c, .cpp, .h, .java, .sh, .ps1, .bat, .toml, .yaml, .xml Source extraction, symbol and keyword FTS5 BM25 + SigLIP dense embeddings

Hardware Tiers & Performance

Search2 dynamically inspects your system hardware upon startup and selects the optimal execution profile:

Tier Hardware Profile Precision Batch Size Strategy
Tier 1 (gpu_high) NVIDIA RTX / GTX $\ge$ 4GB VRAM FP16 Half 16–32 High-throughput CUDA batching
Tier 2 (gpu_low) NVIDIA GTX 1050 (2GB–4GB VRAM) FP16 Half 8–12 Throttled batching with periodic VRAM garbage collection
Tier 3 (cpu) CPU Only / Non-CUDA systems FP32 2–4 Multi-threaded quantized PyTorch/ONNX execution

Quick Start

Option 1: One-Click Launch (Windows)

Simply double-click run.bat or execute in PowerShell:

.\run.bat

Tip for Silent Launch: Double-click run_app.vbs to start Search2 silently in the background without keeping a command prompt window open.


Option 2: Manual Setup

1. Clone the Repository

git clone https://github.com/<your-username>/search2.git
cd search2

2. Create and Activate Virtual Environment

python -m venv .venv
.\.venv\Scripts\activate

3. Install Dependencies

# For CUDA 12.x GPU acceleration (Recommended):
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt

# Or for standard CPU installation:
pip install -r requirements.txt

4. Run Search2

# Desktop App (Native WebView2 window)
python main.py

# Headless / Server Mode (Open in your browser at http://127.0.0.1:8765)
python main.py --server-only

Frontend Development (Optional)

The pre-compiled production UI bundle is already included in frontend/dist/, so you do not need Node.js installed to run Search2.

If you wish to modify or customize the React UI:

cd frontend
npm install

# Start Vite hot-reload development server
npm run dev

# Compile production bundle into frontend/dist/
npm run build

Running the Automated Test Suite

Search2 comes with a comprehensive test suite testing database transactions, FTS5 full-text queries, vector storage, indexing pause/resume threading events, file classifiers, and end-to-end hybrid semantic ranking:

.\.venv\Scripts\python.exe -m pytest tests -v

All 9 integration and unit tests pass with 100% test coverage for the core pipeline.


Project Structure

search2/
├── assets/
│   ├── icon.ico              # Windows taskbar & titlebar icon
│   └── icon.png              # High-resolution application logo
├── backend/
│   ├── database.py           # SQLite WAL connection, FTS5 schema & vector blob storage
│   ├── embedder.py           # Google SigLIP neural engine, prompt ensembling & RRF search
│   ├── hardware.py           # GPU/CPU hardware profiler & adaptive tier scaler
│   ├── indexer.py            # Threaded scanner, pause/resume signaling & WebP thumbnailer
│   └── server.py             # FastAPI REST service & static asset mounting
├── frontend/
│   ├── src/
│   │   ├── components/       # Sidebar, SearchBar, FileGrid, IndexerBanner, AddFolderModal
│   │   ├── types.ts          # TypeScript domain interfaces
│   │   ├── App.tsx           # State orchestrator, dual-theme switcher & density engine
│   │   └── index.css         # Custom Coal/Yellow & Warm White/Brown color tokens
│   ├── dist/                 # Production pre-built UI bundle (runs without Node.js)
│   ├── package.json          # React 19, Tailwind CSS v4, Lucide React dependencies
│   └── vite.config.ts        # Vite build configuration
├── tests/
│   ├── test_backend.py       # Unit tests for database, FTS, vectors, and indexer controls
│   ├── test_e2e.py           # Full end-to-end pipeline test with synthetic data
│   └── test_semantic_clip.py # Semantic visual ranking differentiation tests
├── main.py                   # PyWebView Edge WebView2 shell & FastAPI bootstrap
├── requirements.txt          # Python dependencies
├── run.bat                   # One-click Windows desktop launcher
└── run_app.vbs               # Silent launcher (no console window)

REST API Reference

The local FastAPI server exposes the following endpoints (available at http://127.0.0.1:8765/docs when running):

Method Endpoint Description
GET /api/hardware Returns detected GPU tier, VRAM, and execution parameters
GET /api/folders Lists all monitored folders with file counts and status
POST /api/folders Tracks a new folder path with custom color and icon
DELETE /api/folders/{id} Removes a tracked folder and cascades file cleanup
POST /api/search Executes hybrid RRF search (query, folder_id, limit)
GET /api/indexer/status Returns indexing progress (processed, total, is_paused)
POST /api/indexer/pause Pauses background file indexing worker thread
POST /api/indexer/resume Resumes background file indexing worker thread
POST /api/open-file Opens file using Windows default shell application
POST /api/open-folder Reveals file or directory in Windows File Explorer
GET /api/browse-folder Fast directory browser for modal folder selector

Security & Privacy Guarantee

  • Air-Gapped Operation: No outbound internet requests are made during indexing or search.
  • Local Storage: All file hashes, text extracts, and vector embeddings are stored inside a local SQLite database file (search2.db) in the application folder.
  • Zero Third-Party Telemetry: No trackers, analytics, or remote logging.

License

This project is licensed under the MIT License.

About

Fast, air-gapped multimodal AI desktop search engine. Combines Google SigLIP vision-language embeddings with SQLite FTS5 BM25 keyword matching via Reciprocal Rank Fusion (RRF) for local images, documents, and code.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages