Skip to content

Commit 514caf9

Browse files
Merge pull request redis-developer#611 from wjohnsto/master
Adding more context around vector math
2 parents c4470dc + 829755b commit 514caf9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

docs/howtos/solutions/vector/getting-started-vector/index-getting-started-vector.mdx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,11 +682,13 @@ console.log(JSON.stringify(result2, null, 4));
682682
The syntax for KNN/range vector queries remains consistent whether you're dealing with image vectors or text vectors.
683683
:::
684684
685-
## How to calculate vector similarity?
685+
## Understanding the math behind vector similarity searches
686+
687+
### How to calculate vector similarity?
686688
687689
Several techniques are available to assess vector similarity, with some of the most prevalent ones being:
688690
689-
### Euclidean Distance (L2 norm)
691+
#### Euclidean Distance (L2 norm)
690692
691693
**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.
692694
@@ -710,7 +712,7 @@ As an example, we will use a 2D chart made with [chart.js](https://www.chartjs.o
710712
711713
![chart](./images/euclidean-distance-chart.png)
712714
713-
### Cosine Similarity
715+
#### Cosine Similarity
714716
715717
**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.
716718
@@ -733,7 +735,7 @@ Using [chart.js](https://www.chartjs.org/), we've crafted a 2D chart of `Price v
733735
734736
![chart](./images/cosine-chart.png)
735737
736-
### Inner Product
738+
#### Inner Product
737739
738740
**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.
739741
@@ -758,3 +760,7 @@ Considering our `product 1` and `product 2`, let's compute the `Inner Product` a
758760
:::tip
759761
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.
760762
:::
763+
764+
## Further reading
765+
766+
- [Vector search in Redis 7.2](https://redis.com/blog/introducing-redis-7-2/)

0 commit comments

Comments
 (0)