EmbeddingVector.QuantizedData


@ExperimentalAppSearchApi
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(
    minValue: Float,
    scale: Float,
    quantizedValues: ByteArray<Byte>
)

Creates a new QuantizedData.

Public functions

Boolean
equals(o: Any?)
java-static EmbeddingVector.QuantizedData

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.

Array<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
QuantizedData(
    minValue: Float,
    scale: Float,
    quantizedValues: ByteArray<Byte>
)

Creates a new QuantizedData.

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

Parameters
minValue: Float

The minimum float value across all dimensions before quantization.

scale: Float

The scaling factor used to quantize the vector.

quantizedValues: ByteArray<Byte>

The pre-quantized int8 vector data.

Throws
java.lang.IllegalArgumentException

if quantizedValues is empty.

Public functions

equals

fun equals(o: Any?): Boolean

fromUnquantizedValues

Added in 1.2.0-alpha02
java-static fun fromUnquantizedValues(values: FloatArray<Float>): EmbeddingVector.QuantizedData

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
values: FloatArray<Float>

The float values to quantize.

Returns
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
fun getMinValue(): Float

Returns the minimum float value across all dimensions before quantization.

getQuantizedValues

Added in 1.2.0-alpha02
fun getQuantizedValues(): Array<Byte>

Returns the pre-quantized int8 vector data.

getScale

Added in 1.2.0-alpha02
fun getScale(): Float

Returns the scaling factor used to quantize the vector.

hashCode

fun hashCode(): Int