EmbeddingVector.QuantizedData


@ExperimentalAppSearchApi
public final class EmbeddingVector.QuantizedData


Holds the pre-quantized embedding values along with the quantization parameters.

The original float values can be reconstructed from the quantized byte values using the formula: originalValue = (quantizedValue / scale) + minValue.

Summary

Public constructors

QuantizedData(
    float minValue,
    float scale,
    @NonNull byte[] quantizedValues
)

Creates a new QuantizedData.

Public methods

boolean
static @NonNull EmbeddingVector.QuantizedData
fromUnquantizedValues(@NonNull float[] values)

Creates a new QuantizedData by quantizing the provided float values to 8-bit integers.

float

Returns the minimum float value across all dimensions before quantization.

@NonNull byte[]

Returns the pre-quantized int8 vector data.

float

Returns the scaling factor used to quantize the vector.

int

Public constructors

QuantizedData

Added in 1.2.0-alpha02
public QuantizedData(
    float minValue,
    float scale,
    @NonNull byte[] quantizedValues
)

Creates a new QuantizedData.

The original float values can be reconstructed from the quantized byte values using the formula: originalValue = (quantizedValue / scale) + minValue.

Parameters
float minValue

The minimum float value across all dimensions before quantization.

float scale

The scaling factor used to quantize the vector.

@NonNull byte[] quantizedValues

The pre-quantized int8 vector data.

Throws
java.lang.IllegalArgumentException

if quantizedValues is empty.

Public methods

equals

public boolean equals(@Nullable Object o)

fromUnquantizedValues

Added in 1.2.0-alpha02
public static @NonNull EmbeddingVector.QuantizedData fromUnquantizedValues(@NonNull float[] values)

Creates a new QuantizedData by quantizing the provided float values to 8-bit integers.

Storing 8-bit quantized values directly helps reduce memory and disk space usage by approximately 75% compared to storing full 32-bit floats.

Parameters
@NonNull float[] values

The float values to quantize.

Returns
@NonNull EmbeddingVector.QuantizedData

The QuantizedData created by quantizing the float values.

Throws
java.lang.IllegalArgumentException

if values is empty.

getMinValue

Added in 1.2.0-alpha02
public float getMinValue()

Returns the minimum float value across all dimensions before quantization.

getQuantizedValues

Added in 1.2.0-alpha02
public @NonNull byte[] getQuantizedValues()

Returns the pre-quantized int8 vector data.

getScale

Added in 1.2.0-alpha02
public float getScale()

Returns the scaling factor used to quantize the vector.

hashCode

public int hashCode()