SShortSingh.
Back to feed

How HNSW Cuts Vector Search from 1,240ms to 2ms Across Millions of Docs

0
·1 views

HNSW, or Hierarchical Navigable Small World, is a graph-based algorithm that powers vector search in tools like FAISS, pgvector, Qdrant, and Milvus. Traditional brute-force search across two million 768-dimensional document embeddings requires roughly 1.24 billion arithmetic operations, taking over a second per query and scaling linearly with data size. Unlike B-trees, which sort on a single axis and break down in high-dimensional spaces, HNSW builds a multi-layered graph where each vector node connects to its nearest neighbors, enabling a greedy traversal from sparse long-range links to dense local ones. A search query navigates this structure in approximately 15–20 hops and around 1,800 comparisons instead of two million, reducing latency to about 2 milliseconds. The trade-off is approximate rather than exact results, but in practice the algorithm reliably reaches the true nearest neighbor through the densely interconnected graph structure.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingHacker News ·

Developer Launches Hilo: A Word Game Built Around Binary Search Logic

A developer has released Hilo, a browser-based word game that applies the concept of binary search to gameplay. The game challenges players to guess a target word by narrowing down possibilities using higher/lower style feedback, mimicking how binary search algorithms work. It was shared on Hacker News as a personal project under the 'Show HN' category. The game is accessible at hilogame.cc and appears to be an independent, hobby-driven creation. The post attracted minimal early engagement, with just a few points and no comments at the time of publication.

0
ProgrammingDEV Community ·

SlaveCode Code Execution Platform Earns Spot in Official Judge0 README Showcase

SlaveCode, an online platform that compiles and executes user-submitted code in real time, has been added to the official README showcase of Judge0, a widely used open-source code execution engine. Judge0's creator, Herman Zvonimir Došilović, discovered the project and opened a GitHub issue to express his appreciation before adding it to the showcase. SlaveCode uses Judge0 as its core execution engine, running it on isolated Microsoft Azure VMs that are physically separated from the platform's main API and databases hosted on Google Cloud Platform. This architectural separation is designed to contain any potential security breach within the execution sandbox, keeping user data and core infrastructure secure. The developer credited detailed public documentation of SlaveCode's architecture on Dev.to as the likely reason the project came to Došilović's attention.

0
ProgrammingDEV Community ·

OMR Python Library Replaces Repetitive Data Audit Boilerplate with One Command

A developer has released OMR (Omni Data Refinement), an open-source Python library designed to streamline dataset quality checks that typically require dozens of lines of boilerplate code. The library generates a 0–100 health score across five dimensions — completeness, uniqueness, consistency, validity, and conformity — with a single function call. OMR also supports auto-cleaning with a transformation log, schema validation, statistical analysis, and drift detection using methods like PSI and KS Test. It requires only pandas, numpy, and rich, with no cloud dependencies or large language models involved. The library is available via pip and its source code is publicly hosted on GitHub.

0
ProgrammingDEV Community ·

Five Common Regex Mistakes and How to Catch Them Before Production

Regex patterns often contain subtle flaws that only surface with specific inputs, making debugging a common challenge for developers. Greedy quantifiers, misplaced anchors, and misconfigured flags are among the most frequent causes of unexpected matching behavior. Capture group interference and overly simplistic patterns that fail on real-world edge cases — such as complex email addresses — also trip up many implementations. Syntax errors like unbalanced brackets or invalid lookbehind expressions can cause unhandled runtime exceptions if not caught during development. Using a visual regex tester that highlights matches in real time and displays individual capture group values can significantly speed up the debugging process.