lance_index::vector::graph

Function beam_search

Source
pub fn beam_search(
    graph: &dyn Graph,
    ep: &OrderedNode,
    k: usize,
    dist_calc: &impl DistCalculator,
    bitset: Option<&Visited<'_>>,
    prefetch_distance: Option<usize>,
    visited: &mut Visited<'_>,
) -> Vec<OrderedNode>
Expand description

Beam search over a graph

This is the same as search-layer in HNSW.

§Parameters

graph : Graph The graph to search. start : &OrderedNode The starting point. query : &f32 The query vector. k : usize The number of results to return. bitset : Option<&RoaringBitmap> The bitset of node IDs to filter the results, bit 1 for the node to keep, and bit 0 for the node to discard.

§Returns

A descending sorted list of (dist, node_id) pairs.

WARNING: Internal API, API stability is not guaranteed

TODO: This isn’t actually beam search, function should probably be renamed