@@ -385,11 +385,19 @@ Only available on `@VectorField`.
385
385
|===============
386
386
|Value|Definition
387
387
|`VectorSimilarity.L2`|An L2 (Euclidean) norm, that is a sensible default for most scenarios.
388
- Distance between vectors `x` and `y` is calculated as latexmath:[d(x,y) = \sqrt{\sum_{i=1}^{n} (x_i - y_i)^2 } ]
389
- and the score function is latexmath:[s = \frac{1}{1+d*d}]
388
+ Distance between vectors `x` and `y` is calculated as
389
+ ifdef::backend-html5[stem:[d(x,y) = \sqrt{\sum_{i=1}^{n} (x_i - y_i)^2 } ]]
390
+ ifdef::backend-pdf[`d(x,y) = sqrt(sum[i=1; i<n+1]( (x(i) - y(i))*(x(i) - y(i)) )`]
391
+ and the score function is
392
+ ifdef::backend-html5[stem:[s = \frac{1}{1+d^2}]]
393
+ ifdef::backend-pdf[`s = 1/(1+d*d)`]
390
394
|`VectorSimilarity.DOT_PRODUCT`|Inner product (dot product in particular).
391
- Distance between vectors `x` and `y` is calculated as latexmath:[d(x,y) = \sum_{i=1}^{n} x_i \cdot y_i ]
392
- and the score function is latexmath:[s = \frac{1}{1+d}]
395
+ Distance between vectors `x` and `y` is calculated as
396
+ ifdef::backend-html5[stem:[d(x,y) = \sum_{i=1}^{n} x_i \cdot y_i ]]
397
+ ifdef::backend-pdf[`d(x,y) = sum[i=1; i< n+1] ( x(i)*y(i) ) `]
398
+ and the score function is
399
+ ifdef::backend-html5[stem:[s = \frac{1}{1+d}]]
400
+ ifdef::backend-pdf[`s = 1/(1+d)`]
393
401
394
402
[WARNING]
395
403
====
@@ -400,14 +408,24 @@ while byte vectors should simply all have the same norm.
400
408
====
401
409
402
410
|`VectorSimilarity.COSINE`|Cosine similarity.
403
- Distance between vectors `x` and `y` is calculated as latexmath:[d(x,y) = \frac{1 - \sum_{i=1} ^{n} x_i \cdot y_i }{ \sqrt{ \sum_{i=1} ^{n} x_i^2 } \sqrt{ \sum_{i=1} ^{n} y_i^2 }} ]
404
- and the score function is latexmath:[s = \frac{1}{1+d}]
411
+ Distance between vectors `x` and `y` is calculated as
412
+ ifdef::backend-html5[stem:[d(x,y) = \frac{1 - \sum_{i=1} ^{n} x_i \cdot y_i }{ \sqrt{ \sum_{i=1} ^{n} x_i^2 } \sqrt{ \sum_{i=1} ^{n} y_i^2 }} ]]
413
+ ifdef::backend-pdf[`d(x,y) = (1 - sum[i=1; i<n+1] ( x(i)*y(i) )/( sqrt( sum[i=1; i<n+1] x(i)*x(i) ) sqrt( sum[i=1; i<n+1] y(i)*y(i) ) ) )`]
414
+ and the score function is
415
+ ifdef::backend-html5[stem:[s = \frac{1}{1+d}]]
416
+ ifdef::backend-pdf[`s = 1/(1+d)`]
405
417
|`VectorSimilarity.MAX_INNER_PRODUCT`|Similar to a dot product similarity, but does not require vector normalization.
406
- Distance between vectors `x` and `y` is calculated as latexmath:[d(x,y) = \sum_{i=1}^{n} x_i \cdot y_i ]
407
- and the score function is latexmath:[s = \begin{cases}
418
+ Distance between vectors `x` and `y` is calculated as
419
+ ifdef::backend-html5[stem:[d(x,y) = \sum_{i=1}^{n} x_i \cdot y_i ]]
420
+ ifdef::backend-pdf[`d(x,y) = sum[i=1; i<n+1] ( x(i)*y(i) )`]
421
+ and the score function is
422
+ ifdef::backend-html5[]
423
+ stem:[s = \begin{cases}
408
424
\frac{1}{1-d} & \text{if d < 0}\\
409
425
d+1 & \text{otherwise}
410
426
\end{cases} ]
427
+ endif::[]
428
+ ifdef::backend-pdf[`d<0 ? 1/(1-d) : d+1`]
411
429
|`VectorSimilarity.DEFAULT`|Use the backend-specific default. For the <<backend-lucene, Lucene backend>> an `L2` similarity is used.
412
430
|===============
413
431
+
0 commit comments