We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 836f7ac commit cb7feb2Copy full SHA for cb7feb2
1 file changed
model2vec/quantization.py
@@ -26,7 +26,8 @@ def quantize_embeddings(embeddings: np.ndarray, quantize_to: DType) -> np.ndarra
26
elif quantize_to == DType.Float64:
27
return embeddings.astype(np.float64)
28
elif quantize_to == DType.Int8:
29
- # Normalize to [-127, 127] range for int8
+ # Normalize to [-128, 127] range for int8
30
+ # We normalize to -127 to 127 to keep symmetry.
31
scale = np.max(np.abs(embeddings)) / 127.0
32
quantized = np.round(embeddings / scale).astype(np.int8)
33
return quantized
0 commit comments