SAG / ARCHITECTURE NOTE

Embeddings and HNSW: Core Principles of Vector Search Indexes

Explains what HNSW is and why it is needed, how it works, criteria for applying it to SAG architecture, and a practical checklist, drawing on research and official documentation.

Download Markdown

Definition in one sentence

HNSW is an approximate nearest neighbor search algorithm that connects vectors in a multilayer proximity graph to quickly search for nearby candidates.

Key answer: Comparing every document vector against a query by exhaustive search increases latency as the dataset grows. HNSW reduces search time by trading away some accuracy.

Why is this technology needed?

Comparing every document vector against a query by exhaustive search increases latency as the dataset grows. HNSW reduces search time by trading away some accuracy.

How it works

It moves broadly through the upper layers and searches for nearby neighbors more precisely in the lower layers. M, efConstruction, and efSearch affect memory, build time, and recall.

When designing a system, accuracy is not the only consideration. Latency, cost, data boundaries, update frequency, and behavior on failure must also be defined to make results reproducible in operation. It is safer not to turn values that automation cannot determine with confidence into 0 or success, but to leave them in an unmeasured or requiring-review state.

Connection to SAG technology

If a vector index is introduced into SAG, tenant boundaries, propagation of deletions, reindexing by model version, and recall validation should be included in the operational contract.

Practical checklist

  • Measure recall against exact search
  • Ensure tenant filters and deletions are not missed
  • Increment the index version when embeddings change
  • Distinguish the states for failures, empty results, and permission errors from success
  • Revalidate before and after changes under the same conditions

Research and official documentation

Reference documents provide a basis for the principles and recommendations. They do not guarantee search visibility, AI mentions, rankings, or revenue; the actual impact of implementation must be verified through observations using service data under the same conditions.

Selection criteria and concrete application examples

HNSW is an approximate nearest neighbor search method that finds candidates by traversing proximity graphs across multiple layers. Increasing the search breadth generally increases both recall and computational cost. Similarity is not a score of factuality, and when the embedding model changes, compatibility with the existing index should be checked first.

Scope of application at SAG

This article covers research principles and scaling design for search AI. Read it in connection with SAG’s page collection, evidence recording, and report validation structure, but do not interpret it to mean that all search algorithms from the paper have been incorporated into the operational pipeline. Whether they have been applied should be verified through the search module, evaluation data, and execution records.

How to continue reading about this technology

Compare RAG, GraphRAG, and Self-RAG papers and their conditions for application.

Articles