Class ES91Int4VectorsScorer

java.lang.Object
org.elasticsearch.simdvec.ES91Int4VectorsScorer

public class ES91Int4VectorsScorer extends Object
Scorer for quantized vectors stored as an IndexInput.

Similar to VectorUtil.int4DotProduct(byte[], byte[]) but one value is read directly from an IndexInput.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final float[]
     
    static final int
     
    protected final int
     
    protected static final float
     
    protected final org.apache.lucene.store.IndexInput
    The wrapper IndexInput.
    protected final float[]
     
    protected byte[]
     
    protected final int[]
     
    protected final float[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ES91Int4VectorsScorer(org.apache.lucene.store.IndexInput in, int dimensions)
    Sole constructor, called by sub-classes.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    applyCorrections(float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp, float lowerInterval, float upperInterval, int targetComponentSum, float additionalCorrection, float qcDist)
    Computes the score by applying the necessary corrections to the provided quantized distance.
    long
    int4DotProduct(byte[] b)
    compute the quantize distance between the provided quantized query and the quantized vector that is read from the wrapped IndexInput.
    void
    int4DotProductBulk(byte[] b, int count, float[] scores)
    compute the quantize distance between the provided quantized query and the quantized vectors that are read from the wrapped IndexInput.
    float
    score(byte[] q, float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp)
    Computes the score by applying the necessary corrections to the provided quantized distance.
    void
    scoreBulk(byte[] q, float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp, float[] scores)
    compute the distance between the provided quantized query and the quantized vectors that are read from the wrapped IndexInput.

    Methods inherited from class java.lang.Object

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

    • BULK_SIZE

      public static final int BULK_SIZE
      See Also:
    • FOUR_BIT_SCALE

      protected static final float FOUR_BIT_SCALE
      See Also:
    • in

      protected final org.apache.lucene.store.IndexInput in
      The wrapper IndexInput.
    • dimensions

      protected final int dimensions
    • scratch

      protected byte[] scratch
    • lowerIntervals

      protected final float[] lowerIntervals
    • upperIntervals

      protected final float[] upperIntervals
    • targetComponentSums

      protected final int[] targetComponentSums
    • additionalCorrections

      protected final float[] additionalCorrections
  • Constructor Details

    • ES91Int4VectorsScorer

      public ES91Int4VectorsScorer(org.apache.lucene.store.IndexInput in, int dimensions)
      Sole constructor, called by sub-classes.
  • Method Details

    • int4DotProduct

      public long int4DotProduct(byte[] b) throws IOException
      compute the quantize distance between the provided quantized query and the quantized vector that is read from the wrapped IndexInput.
      Throws:
      IOException
    • int4DotProductBulk

      public void int4DotProductBulk(byte[] b, int count, float[] scores) throws IOException
      compute the quantize distance between the provided quantized query and the quantized vectors that are read from the wrapped IndexInput. The number of quantized vectors to read is determined by {code count} and the results are stored in the provided scores array.
      Throws:
      IOException
    • score

      public float score(byte[] q, float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp) throws IOException
      Computes the score by applying the necessary corrections to the provided quantized distance.
      Throws:
      IOException
    • scoreBulk

      public void scoreBulk(byte[] q, float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp, float[] scores) throws IOException
      compute the distance between the provided quantized query and the quantized vectors that are read from the wrapped IndexInput.

      The number of vectors to score is defined by BULK_SIZE. The expected format of the input is as follows: First the quantized vectors are read from the input,then all the lower intervals as floats, then all the upper intervals as floats, then all the target component sums as shorts, and finally all the additional corrections as floats.

      The results are stored in the provided scores array.

      Throws:
      IOException
    • applyCorrections

      public float applyCorrections(float queryLowerInterval, float queryUpperInterval, int queryComponentSum, float queryAdditionalCorrection, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, float centroidDp, float lowerInterval, float upperInterval, int targetComponentSum, float additionalCorrection, float qcDist)
      Computes the score by applying the necessary corrections to the provided quantized distance.