Local AI search engine for folders with a web interface
Project description
LocalSearch
LocalSearch is a lightweight, privacy-first local semantic search engine powered by embeddings and LLMs.
It lets you index your local files (like .txt, .pdf, .html) and query them using natural language - without sending your data anywhere.
Features
- 🔍 Semantic Search - uses vector embeddings for meaning-based file retrieval
- 🧩 Modular Components - plug in your own LLM, embedder, vector store, or metadata backend
- ⚙️ Auto Re-Embedding - detects modified files and re-embeds when needed
- 💬 Context-Aware Q&A - LLM answers your questions using only local context
- 🌐 FastAPI Web Interface - browse and query files via a simple local web app
- ✅ Tested & Typed - full unit tests and type hints included
Installation
You can install from PyPI:
pip install localsearch
Or, if you’re developing locally:
git clone https://github.com/yourusername/LocalSearch.git
cd LocalSearch
pip install -e .
Quick Start
from LocalSearch.backend.engine import SearchEngine
from your_llm import MyLocalLLM # implement BaseLLM
# Initialize with your local directory and models
engine = SearchEngine(
directory_path="/path/to/your/files",
llm=MyLocalLLM(),
reembed_policy="modified_only", # or 'force', 'never'
)
# Run a semantic query
answer = engine.search("What does this project do?")
print(answer)
To serve the web interface:
engine.web(host="127.0.0.1", port=8000)
Then open your browser at http://127.0.0.1:8000.
How It Works
-
Embedding Generation
_generate_embeddingsscans files, extracts text, chunks them, and encodes using your chosen embedder.
-
Metadata & Vector Storage
- Uses
JsonMetadataStoreandFaissVectorStoreby default (both replaceable).
- Uses
-
Querying
- Queries are embedded, compared against the local FAISS index, and context is fed into the LLM.
-
Answering
- LLM answers using only retrieved context chunks.
Configuration
| Parameter | Description | Default |
|---|---|---|
directory_path |
Path to your data folder | required |
embedding_model |
Any model implementing BaseEmbedder |
SentenceTransformerEmbedder() |
metadata_store |
Metadata persistence | JsonMetadataStore |
vector_store |
Vector storage | FaissVectorStore |
extractor |
Text extraction logic | DefaultTextExtractor |
reembed_policy |
'force', 'modified_only', or 'never' |
'modified_only' |
recursive |
Scan subfolders | True |
verbose |
Print logs | True |
Architecture Overview
LocalSearch/
├── backend/
│ ├── engine.py # Main SearchEngine class
│ ├── _doc_loader/
│ │ ├── _embedding_processor.py # Handles embedding and file updates
│ │ └── _scan.py # Directory scanning utilities
│ ├── embeddings/ # BaseEmbedder + implementations
│ ├── llms/ # BaseLLM and custom LLMs
│ ├── metadata_store/ # JsonMetadataStore + Base class
│ └── vector_store/ # FaissVectorStore + Base class
└── frontend/ # For web based interface
Extending LocalSearch
You can plug in your own components simply by subclassing the base interfaces:
- Custom Embedder → subclass
BaseEmbedder - Custom LLM → subclass
BaseLLM - Custom Vector Store → subclass
BaseVectorStore - Custom Metadata Store → subclass
BaseMetadataStore
Then pass them to the SearchEngine constructor.
Documentation
Docs are hosted on Read the Docs: 👉 https://localsearchpy.readthedocs.io
To build docs locally:
cd docs
pip install -r requirements.txt
make html
Example Use Cases
- Personal knowledge base search
- Local document assistant for PDFs and notes
- Offline AI-powered research tool
- Privacy-friendly enterprise document retrieval
License
MIT License © 2025 [Rick Sanchez]
Contributing
Contributions are welcome! Please open a pull request or file an issue if you’d like to add features, improve performance, or fix bugs.
A Final Note
“LocalSearch keeps your data yours. You can use the power of semantic search and LLMs - completely offline.”
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file localsearch-0.0.1.tar.gz.
File metadata
- Download URL: localsearch-0.0.1.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42833bf84bad0b2944885e3ba3a9f149243cf172a7ca997545911fdf3ba952f3
|
|
| MD5 |
37c44b66f9f8a77afdaad6ec97b76c4b
|
|
| BLAKE2b-256 |
b3c3fbc3b3cd9ac9c150e783e56a8ea44ea51693496b8182079426c5fd46c604
|
File details
Details for the file localsearch-0.0.1-py3-none-any.whl.
File metadata
- Download URL: localsearch-0.0.1-py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce389dd208f46a2879147af8ed27a82e0215a660c1e8522e76dc8cbd8da69c77
|
|
| MD5 |
b0f047471e8d3c3442a556e7a25683d2
|
|
| BLAKE2b-256 |
2d93c80e91db907ca0949a11a2e4d80ab615101530c72e0cda57fbaed10fce47
|