Why Brute Force Beats HNSW on Small Datasets
💡A practical benchmark shows when vectorized exact search beats HNSW—and why ANN may be premature.
⚡ 30-Second TL;DR
What Changed
FAISS exact search beat FAISS HNSW on SciFact, with median latency of 0.237 ms versus 0.323 ms.
Why It Matters
The benchmark challenges the assumption that approximate nearest-neighbor indexes are always faster. For small corpora, a vectorized exact scan can be simpler, cheaper, and faster, especially when embedding generation dominates end-to-end latency.
What To Do Next
Benchmark FAISS IndexFlatIP against FAISS IndexHNSWFlat on your actual corpus size before introducing an ANN index.
Key Points
- •FAISS exact search beat FAISS HNSW on SciFact, with median latency of 0.237 ms versus 0.323 ms.
- •The hand-rolled Python HNSW was 10.9x slower than its own brute-force search on NFCorpus and 18.3x slower on SciFact.
- •All four retrieval systems produced effectively identical ranking quality, reaching nDCG@10 of about 0.316 on NFCorpus and 0.645 on SciFact.
- •HNSW construction took 0.93 seconds versus 0.0017 seconds for the flat index, while embedding generation took 25.8 ms per query.
🧠 Deep Insight
Background and context from public sources — not the original article. 10 sources cited.
🔑 Enhanced Key Takeaways
- •Modern CPUs utilize SIMD (Single Instruction, Multiple Data) instructions to perform linear distance calculations significantly faster than the pointer-chasing operations required for graph traversal in HNSW.
- •HNSW exhibits non-deterministic latency due to variable path lengths through its multi-layered graph, whereas brute-force search provides consistent, predictable response times.
- •The memory footprint of HNSW is significantly higher than flat indices because it must store both the raw vectors and the complex graph connectivity metadata.
- •Lucene-based search engines, including Elasticsearch, explicitly recommend flat indexing for smaller vector corpora to minimize operational complexity and overhead.
- •Brute-force search guarantees 100% recall, eliminating the trade-off between speed and accuracy that is inherent to approximate nearest neighbor (ANN) algorithms like HNSW.
📊 Competitor Analysis▸ Show
| Feature | Brute-Force (Flat) | HNSW (Graph-based) |
|---|---|---|
| Recall | 100% (Exact) | Approximate (Tunable) |
| Latency (Small Data) | Lower | Higher (Overhead) |
| Memory Usage | Minimal | High (Graph metadata) |
| Index Build Time | Near-instant | Significant |
| Best Use Case | Small datasets / High accuracy | Large-scale / High throughput |
🛠️ Technical Deep Dive
- Brute-force search leverages cache-friendly memory access patterns, minimizing cache misses compared to the random memory access patterns required for traversing HNSW graph nodes.
- Flat indexing avoids the computational cost of building and maintaining multi-layered graph structures, which requires expensive neighbor selection and link pruning during insertion.
- SIMD acceleration allows modern processors to compute multiple vector distances in a single clock cycle, effectively parallelizing the linear scan.
- HNSW performance is sensitive to the 'efConstruction' and 'M' parameters, which require empirical tuning that is unnecessary for flat indices.
🔮 Future ImplicationsAI analysis grounded in cited sources
⏳ Timeline
📎 Sources (10)
Factual claims are grounded in the sources below. Forward-looking analysis is AI-generated interpretation.
Weekly AI Recap
Read this week's curated digest of top AI events →
👉Related Updates
AI-curated news aggregator. All content rights belong to original publishers.
Original source: Reddit r/MachineLearning ↗
This is a summary, not the original. Read the source, or get the weekly briefing.
Weekly AI briefing
One email a week. Unsubscribe anytime.

