Skip to content

Make HNSW search beam width configurable#644

Open
fh-ms wants to merge 4 commits intomainfrom
jvector-search-rerank-update
Open

Make HNSW search beam width configurable#644
fh-ms wants to merge 4 commits intomainfrom
jvector-search-rerank-update

Conversation

@fh-ms
Copy link
Copy Markdown
Contributor

@fh-ms fh-ms commented Apr 24, 2026

Summary

The HNSW search path enforces a minimum beam width (HNSW efSearch) so that the top-k stays stable across different requested k values — without it, search(q, 5) can return a different top-5 than the first five entries of search(q, 50).

This PR turns the floor into two knobs:

  1. VectorIndexConfiguration.minSearchBeamWidth() — index-level floor (default 100, preserves current behavior). Set to 1 to disable the floor entirely.
  2. VectorIndex.search(float[] query, int k, int searchBeamWidth) (plus the matching search(E entity, int k, int searchBeamWidth) default) — per-query override. The effective beam width becomes max(k, searchBeamWidth) for that call, bypassing the config floor.

Search-time beam width (HNSW efSearch) is conceptually distinct from the existing beamWidth() (HNSW efConstruction, construction only), so it's a separate property rather than a reinterpretation of the existing one.

Changes

  • VectorIndexConfiguration: new minSearchBeamWidth() getter + builder method, default 100.
  • VectorIndex.Default: computeRerankK now reads from the configuration. Search dispatch refactored so rerankK flows as a parameter into searchInMemoryIndex / searchDiskIndex / searchIncremental — the floor logic lives in one place.
  • New public search(..., int searchBeamWidth) overloads on VectorIndex.
  • AsciiDoc updates in configuration.adoc, index.adoc, advanced.adoc — new parameter, clarified construction-vs-search wording, and the PQ two-phase reranking section now shows max(2 * k, minSearchBeamWidth) instead of just 2 * k.

Compatibility

  • Old persisted VectorIndexConfiguration.Default instances deserialize with minSearchBeamWidth = 0, which collapses to rerankK = k — safe, no migration required.

@fh-ms fh-ms requested a review from zdenek-jonas April 24, 2026 10:38
@fh-ms fh-ms added the GigaMap label Apr 24, 2026
@fh-ms fh-ms added this to the 4.1.0 milestone Apr 24, 2026
@fh-ms fh-ms requested a review from Copilot April 24, 2026 10:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a minimum search “beam width” (candidate exploration) to decouple HNSW search effort from the requested k, aiming to make top-k results stable when callers vary k.

Changes:

  • Introduces a minimum rerankK for HNSW search to ensure sufficient exploration for small k.
  • Updates in-memory, disk, incremental, and PQ-rerank search paths to use rerankK.
  • Adds a regression test asserting top-5 stability between k=5 and k=50.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/VectorIndex.java Computes and applies a minimum rerankK; updates search paths and incremental merging behavior.
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/PQCompressionManager.java Threads rerankK into PQ rerank flow; ensures candidate count meets the minimum exploration level.
gigamap/jvector/src/test/java/org/eclipse/store/gigamap/jvector/VectorIndexTest.java Adds a test to verify top-5 consistency across different requested k values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/VectorIndex.java Outdated
Comment thread gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/VectorIndex.java Outdated
@fh-ms fh-ms changed the title Ensure consistent top-k results in HNSW search Make HNSW search beam width configurable (replaces hardcoded floor) Apr 24, 2026
@fh-ms fh-ms changed the title Make HNSW search beam width configurable (replaces hardcoded floor) Make HNSW search beam width configurable Apr 24, 2026
@fh-ms fh-ms requested a review from Copilot April 24, 2026 12:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants