You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The syntax for KNN/range vector queries remains consistent whether you're dealing with image vectors or text vectors.
683
683
:::
684
684
685
-
## How to calculate vector similarity?
685
+
## Understanding the math behind vector similarity searches
686
+
687
+
### How to calculate vector similarity?
686
688
687
689
Several techniques are available to assess vector similarity, with some of the most prevalent ones being:
688
690
689
-
### Euclidean Distance (L2 norm)
691
+
#### Euclidean Distance (L2 norm)
690
692
691
693
**Euclidean Distance (L2 norm)** calculates the linear distance between two points within a multi-dimensional space. Lower values indicate closer proximity, and hence higher similarity.
692
694
@@ -710,7 +712,7 @@ As an example, we will use a 2D chart made with [chart.js](https://www.chartjs.o
710
712
711
713

712
714
713
-
### Cosine Similarity
715
+
#### Cosine Similarity
714
716
715
717
**Cosine Similarity** measures the cosine of the angle between two vectors. The cosine similarity value ranges between -1 and 1. A value closer to 1 implies a smaller angle and higher similarity, while a value closer to -1 implies a larger angle and lower similarity. Cosine similarity is particularly popular in NLP when dealing with text vectors.
716
718
@@ -733,7 +735,7 @@ Using [chart.js](https://www.chartjs.org/), we've crafted a 2D chart of `Price v
733
735
734
736

735
737
736
-
### Inner Product
738
+
#### Inner Product
737
739
738
740
**Inner Product (dot product)** The inner product (or dot product) isn't a distance metric in the traditional sense but can be used to calculate similarity, especially when vectors are normalized (have a magnitude of 1). It's the sum of the products of the corresponding entries of the two sequences of numbers.
739
741
@@ -758,3 +760,7 @@ Considering our `product 1` and `product 2`, let's compute the `Inner Product` a
758
760
:::tip
759
761
Vectors can also be stored in databases in **binary formats** to save space. In practical applications, it's crucial to strike a balance between the dimensionality of the vectors (which impacts storage and computational costs) and the quality or granularity of the information they capture.
760
762
:::
763
+
764
+
## Further reading
765
+
766
+
- [Vector search in Redis 7.2](https://redis.com/blog/introducing-redis-7-2/)
0 commit comments