Class AdaptiveHnswQueueSaturationCollector

java.lang.Object
org.apache.lucene.search.KnnCollector.Decorator
org.apache.lucene.search.HnswQueueSaturationCollector
org.elasticsearch.search.vectors.AdaptiveHnswQueueSaturationCollector
All Implemented Interfaces:
org.apache.lucene.search.KnnCollector

public class AdaptiveHnswQueueSaturationCollector extends org.apache.lucene.search.HnswQueueSaturationCollector
A KnnCollector.Decorator extending HnswQueueSaturationCollector that adaptively early-exits HNSW search using an online-estimated discovery rate, rolling mean/variance, and adaptive patience threshold. It tracks smoothed discovery rate (how many new neighbors are collected per candidate), maintains a rolling mean and variance of the rate (using Welford's algorithm). Those are used to define an adaptive saturation threshold = mean + looseness * stddev and adaptive patience = patience-scaling / (1 + stddev). Adaptive patience scales inversely with volatility (stddev) and looseness. Patience-scaling defines patience order of magnitude. Saturation happens when the discovery rate is lower than the adaptive saturation threshold. The collector early exits once saturation persists for longer than adaptive patience.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.lucene.search.KnnCollector

    org.apache.lucene.search.KnnCollector.Decorator
  • Field Summary

    Fields inherited from class org.apache.lucene.search.KnnCollector.Decorator

    collector
  • Constructor Summary

    Constructors
    Constructor
    Description
    AdaptiveHnswQueueSaturationCollector(org.apache.lucene.search.KnnCollector delegate)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    collect(int docId, float similarity)
     
    boolean
     
    void
     

    Methods inherited from class org.apache.lucene.search.HnswQueueSaturationCollector

    getSearchStrategy, topDocs

    Methods inherited from class org.apache.lucene.search.KnnCollector.Decorator

    incVisitedCount, k, minCompetitiveSimilarity, visitedCount, visitLimit

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AdaptiveHnswQueueSaturationCollector

      public AdaptiveHnswQueueSaturationCollector(org.apache.lucene.search.KnnCollector delegate)
  • Method Details

    • earlyTerminated

      public boolean earlyTerminated()
      Specified by:
      earlyTerminated in interface org.apache.lucene.search.KnnCollector
      Overrides:
      earlyTerminated in class org.apache.lucene.search.HnswQueueSaturationCollector
    • collect

      public boolean collect(int docId, float similarity)
      Specified by:
      collect in interface org.apache.lucene.search.KnnCollector
      Overrides:
      collect in class org.apache.lucene.search.HnswQueueSaturationCollector
    • nextCandidate

      public void nextCandidate()
      Overrides:
      nextCandidate in class org.apache.lucene.search.HnswQueueSaturationCollector