# `Sting.Quantization`
[🔗](https://github.com/dkuku/sting/blob/v0.1.0/lib/sting/quantization.ex#L1)

Embedding quantization utilities mirroring `sentence_transformers.util.quantize_embeddings`.

Supports binary, unsigned binary bit-packing (`:ubinary`), and scalar `:int8` quantization.

# `hamming_distance`

Computes the Hamming distance between two `ubinary` or `binary` packed tensors.

# `quantize`

Quantizes embeddings to a lower precision.

## Precisions

  * `:binary` - values > 0 are packed 8-to-a-byte into signed `s8` (-128 offset, matching `sentence_transformers.util.quantize_embeddings`).
  * `:ubinary` - values > 0 are packed 8-to-a-byte into `u8` (reduces memory by 32x).
  * `:int8` - linear scalar quantization mapped to `[-128, 127]`.

## Options (for `:int8`)

  * `:ranges` - optional `{min_tensor, max_tensor}` tuple specifying dimension ranges.
  * `:calibration_embeddings` - optional tensor to compute quantization ranges from.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
