Class HnswGraphBuilder<T>

java.lang.Object
org.apache.lucene.util.hnsw.HnswGraphBuilder<T>
Type Parameters:
T - the type of vector

public final class HnswGraphBuilder<T> extends Object
Builder for HNSW graph. See HnswGraph for a gloss on the algorithm and the meaning of the hyperparameters.
  • Field Details

  • Constructor Details

    • HnswGraphBuilder

      private HnswGraphBuilder(RandomAccessVectorValues<T> vectors, VectorEncoding vectorEncoding, VectorSimilarityFunction similarityFunction, int M, int beamWidth, long seed) throws IOException
      Reads all the vectors from vector values, builds a graph connecting them by their dense ordinals, using the given hyperparameter settings, and returns the resulting graph.
      Parameters:
      vectors - the vectors whose relations are represented by the graph - must provide a different view over those vectors than the one used to add via addGraphNode.
      M - – graph fanout parameter used to calculate the maximum number of connections a node can have – M on upper layers, and M * 2 on the lowest level.
      beamWidth - the size of the beam search to use when finding nearest neighbors.
      seed - the seed for a random number generator used during graph construction. Provide this to ensure repeatable construction.
      Throws:
      IOException
  • Method Details