Skip to content

Commit cb7feb2

Browse files
committed
add comment
1 parent 836f7ac commit cb7feb2

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

model2vec/quantization.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def quantize_embeddings(embeddings: np.ndarray, quantize_to: DType) -> np.ndarra
2626
elif quantize_to == DType.Float64:
2727
return embeddings.astype(np.float64)
2828
elif quantize_to == DType.Int8:
29-
# Normalize to [-127, 127] range for int8
29+
# Normalize to [-128, 127] range for int8
30+
# We normalize to -127 to 127 to keep symmetry.
3031
scale = np.max(np.abs(embeddings)) / 127.0
3132
quantized = np.round(embeddings / scale).astype(np.int8)
3233
return quantized

0 commit comments

Comments
 (0)