Interface Quantizer

All Known Implementing Classes:
RaBitQuantizer

public interface Quantizer
Defines the contract for a quantizer, a component responsible for encoding data vectors into a different, ideally a more compact, representation.

Quantizers are typically used in machine learning and information retrieval to transform raw data into a format that is more suitable for processing, such as a compressed representation.

  • Method Details

    • estimator

      @Nonnull Estimator estimator()
      Returns the Estimator instance associated with this object.

      The estimator is responsible for performing the primary distance estimation or calculation logic. This method provides access to that underlying component.

      Returns:
      the Estimator instance, which is guaranteed to be non-null.
    • encode

      @Nonnull default Transformed<RealVector> encode(@Nonnull Transformed<RealVector> vector)
    • encode

      @Nonnull RealVector encode(@Nonnull RealVector vector)
      Encodes the given data vector into another vector representation.

      This method transforms the raw input data into a different, quantized format, which is often a vector more suitable for processing/storing the data. The specifics of the encoding depend on the implementation of the class.

      Parameters:
      vector - the input RealVector to be encoded. Must not be null and is assumed to have been preprocessed, such as by rotation and/or translation. The preprocessing has to align with the requirements of the specific quantizer.
      Returns:
      the encoded vector representation of the input data, guaranteed to be non-null.
    • noOpQuantizer

      @Nonnull static Quantizer noOpQuantizer(@Nonnull Metric metric)
      Creates a no-op Quantizer that does not perform any data transformation.

      The returned quantizer's encode(RealVector) method acts as an identity function, returning the input vector without modification. The estimator() is created directly from the distance function of the provided Metric. This can be useful for baseline comparisons or for algorithms that require a Quantizer but where no quantization is desired.

      Parameters:
      metric - the Metric used to build the distance estimator for the quantizer.
      Returns:
      a new Quantizer instance that performs no operation.