Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Summary¶
Embedding generators and vector search engines solve different layers. Tools such as
fastembed,model2vec,sentence-transformers, andollamaconvert text into dense vectors. FAISS does not generate embeddings — it only indexes and searches vectors that have already been computed.For small-to-medium local corpora (~1k–50k documents), FAISS is usually overkill. For example, ~2,200 documents with 384-dimensional
float32embeddings occupy only ~3.4 MB in RAM. Exact cosine similarity vianumpy(E @ q) runs in <2 ms with zero extra dependencies and avoids synchronizing a separate FAISS index file with a SQLite metadata store on edits or deletes.Recommended default for local document indexing (e.g., tag/cross-reference suggestions): Use fastembed (
BAAI/bge-small-en-v1.5via ONNX Runtime) or model2vec (fastest CPU builds, smallest footprint) paired with a standalone SQLitecontent_sha256cache and in-memorynumpycosine similarity.When to reach for FAISS: Scale reaches 100k–1B+ vectors (e.g., chunk-level search across large PDF/code archives), memory compression via approximate nearest neighbor (ANN) indexes (IVF-PQ, HNSW) is required, or GPU-accelerated batch search (
faiss-gpu) is needed.
The Three Layers of a Local Semantic Search Stack¶
When comparing tools for local semantic search, tag suggestion, or cross-reference retrieval, it helps to separate them into three distinct layers:
Embedding generation (text → vector):
fastembed,model2vec,sentence-transformers,ollama,scikit-learn(TF-IDF). FAISS cannot replace this layer; you still need one of these tools to produce vectors.Vector indexing & similarity search (vector → top-K neighbors):
FAISS,sqlite-vec, plainnumpy. This is the layer where FAISS competes.All-in-one pipelines (embed + index + query):
txtai(which wraps FAISS as its default ANN backend) andllm(llm embed/similar).
Embedding Generation Tools¶
Table 1:Local Text Embedding Tools Comparison
Embedding Tool | Status | Semantic? | Runtime & Footprint Notes | Language | License | Popularity |
|---|---|---|---|---|---|---|
Active | Y | ONNX Runtime; no PyTorch; ~15–45s CPU for ~2.2k posts | Python | Apache-2.0 | ~3.3k ★ | |
Active | Y[1] | Distilled static embeddings + NumPy; ~1–3s CPU for ~2.2k posts | Python | MIT | ~2.3k ★ | |
Active | Y | Full PyTorch dependency (~2+ GB); broad model ecosystem | Python | Apache-2.0 | ~19.3k ★ | |
Active | Y | Local daemon (e.g., | Go | MIT | ~188.0k ★ | |
scikit-learn (TF-IDF) | Active | N[2] | Zero neural models; <1s CPU; strong lexical baseline | Python | BSD-3-Clause | ~68.3k ★ |
Vector Search & All-in-One Tools (FAISS vs. Alternatives)¶
Table 2:Vector Search and All-in-One Tools Comparison
Vector Search Tool | Status | Generates Embeddings? | Stores Metadata? | Search Type | Best Scale | Language | License | Popularity |
|---|---|---|---|---|---|---|---|---|
SQLite + NumPy (baseline) | N/A | N | Y[3] | Exact | <50k vectors | Python | N/A | N/A |
Active | N | Y[4] | Exact / KNN | <500k vectors | C | MIT / Apache-2.0 | ~8.3k ★ | |
Active | N | N[5] | Exact & ANN[6] | 100k–1B+ vectors | C++ | MIT | ~41.9k ★ | |
Active | Y | Y | Exact & ANN[7] | 1k–10M+ vectors | Python | Apache-2.0 | ~13.7k ★ | |
Active | Y[8] | Y | Exact | <50k vectors | Python | Apache-2.0 | ~12.8k ★ |
How FAISS Compares in Practice¶
No built-in text encoding: FAISS operates purely on dense numeric arrays (
float32/ quantized vectors). To search text documents, you still need an embedding model such asfastembedormodel2vec.Memory & latency math at small scale: For ~2,200 documents with 384-dim
float32vectors, the entire embedding matrix is only ~3.4 MB. A single normalized matrix-vector product (E @ q) innumpyreturns exact cosine similarities in under 2 ms, leaving no practical speedup for FAISS to provide.Metadata & incremental update overhead: FAISS stores vectors and integer IDs only. In a workflow where documents are frequently added, edited, or deleted, you still need a database like SQLite to store document paths, tags, and
content_sha256hashes, plus extra logic to keep FAISS integer IDs synchronized with SQLite rows.When FAISS shines: Once a corpus grows to 100k–1M+ vectors (e.g., paragraph-level chunks across large PDF, note, or codebase archives), brute-force scanning becomes slow and memory-heavy. FAISS excels there with inverted file indexes (IVF), product quantization (PQ), HNSW graphs, and GPU acceleration (
faiss-gpu).
Hybrid Local + Low-Tier LLM Pattern¶
For repeated workflows like auto-suggesting tags and cross-references across a personal knowledge base or blog, combining local embeddings with an optional low-tier LLM avoids both high token costs and context-window limits:
Incremental SQLite cache (
content_sha256): Store(doc_path, content_sha256, embedding BLOB)in a standalone SQLite database so only new or modified documents are re-embedded.Stage 1 — Local retrieval ($0 tokens): Compute nearest neighbors locally with
numpy(orsqlite-vec/FAISSat larger scale) to surface candidate cross-references and weighted kNN tag votes.Stage 2 — Optional low-tier LLM reranking (gradual batches): Pass only the target document plus its top-K local neighbors (~1k tokens/document) to a fast, low-cost model when higher-precision curation is desired.
References¶
Distilled static embeddings are ultra-fast on CPU with minimal footprint, with slightly lower semantic nuance than full transformer models like BGE.
Lexical TF-IDF + cosine similarity; fast and zero-ML, but misses synonyms and conceptual matches (e.g., Podman vs. Docker).
Metadata,
content_sha256hashes, andfloat32vector BLOBs live in one SQLite DB; cosine similarity runs in RAM vianumpy.Runs as a SQLite extension inside the same DB file as document metadata and hashes.
Stores vectors and integer IDs only; requires a separate metadata store (e.g., SQLite) and ID-sync logic on updates/deletes.
Supports IVF, PQ, HNSW, and optional GPU acceleration (
faiss-gpu).Uses FAISS as its default ANN backend while bundling embedding models and metadata storage.
Supports local embedding plugins via
llm embedand similarity lookup viallm similar.