diff --git a/src/utils/tensor.js b/src/utils/tensor.js index 87461f45c..469054cac 100644 --- a/src/utils/tensor.js +++ b/src/utils/tensor.js @@ -1210,13 +1210,13 @@ export function quantize_embeddings(tensor, precision) { if (!['binary', 'ubinary'].includes(precision)) { throw new Error("The precision must be either 'binary' or 'ubinary'"); } - const inputData = tensor.data; const signed = precision === 'binary'; const dtype = signed ? 'int8' : 'uint8'; - const cls = signed ? Int8Array : Uint8Array; // Create a typed array to store the packed bits + const cls = signed ? Int8Array : Uint8Array; + const inputData = tensor.data; const outputData = new cls(inputData.length / 8); // Iterate over each number in the array