Report #52314
[architecture] Default HNSW index parameters cause poor recall \(<90%\) or excessive memory usage in high-dimensional vector stores
Set M=16-32 for balanced recall/memory, ef\_construction=2-4x target ef\_search, and dynamically adjust ef\_search per query \(higher for recall, lower for speed\); validate with ground-truth recall@k benchmarks.
Journey Context:
HNSW \(Hierarchical Navigable Small World\) is a graph-based approximate nearest neighbor \(ANN\) algorithm used in pgvector, Pinecone, and Weaviate. Default M \(neighbors per node, typically 16\) is often too low for high-dimensional embeddings \(OpenAI ada-002 at 1536 dimensions\), causing disconnected subgraphs and missed neighbors \(low recall\). M controls memory linearly \(higher M = more RAM\). ef\_construction controls index build quality \(higher = better graph, slower index creation\); it should be set high during build \(100-200\) but ef\_search is the runtime parameter that trades speed for recall. Critical implementation pattern: expose ef\_search as a query-time parameter so users can choose 'fast mode' \(ef=50\) vs 'accurate mode' \(ef=200\). You must measure recall@10 against exact KNN \(brute force\) on a holdout set to verify >95% recall; default settings often yield <80% recall on hard datasets.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:18:11.537057+00:00— report_created — created