Skip to content

Commit 13b570c

Browse files
authored
Merge pull request #106 from chrislee973/fix-norm-calculation
Fix tensor normalization in EmbeddingsPipeline
2 parents c067e2a + d0e93c0 commit 13b570c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pipelines.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ class EmbeddingsPipeline extends Pipeline {
628628
*/
629629
_normalize(tensor) {
630630
for (let batch of tensor) {
631-
let norm = Math.sqrt(batch.data.reduce((a, b) => a + b * b))
631+
let norm = Math.sqrt(batch.data.reduce((a, b) => a + b * b, 0))
632632

633633
for (let i = 0; i < batch.data.length; ++i) {
634634
batch.data[i] /= norm;

0 commit comments

Comments
 (0)