AWS Security ChangesHomeSearch

AWS neptune-analytics documentation change

Service: neptune-analytics · 2025-06-19 · Documentation low

File: neptune-analytics/latest/userguide/vectors-distance-embedding.md

Summary

Added configurable distance metrics to vector comparison algorithm

Security assessment

Functional enhancement adding algorithm configuration options. No security implications or security documentation additions detected in the change.

Diff

diff --git a/neptune-analytics/latest/userguide/vectors-distance-embedding.md b/neptune-analytics/latest/userguide/vectors-distance-embedding.md
index 8e6f30d9d..b869cf866 100644
--- a//neptune-analytics/latest/userguide/vectors-distance-embedding.md
+++ b//neptune-analytics/latest/userguide/vectors-distance-embedding.md
@@ -9 +9 @@ SyntaxInputsOutputsQuery examplesSample output
-The `.vectors.distanceByEmbedding` algorithm computes the distance between an embedding vector and the embedding of an input node. The distance is the squared L2 norm of the input (source) embedding vector and the embedding vector of the (target) input node. 
+The `.vectors.distanceByEmbedding` algorithm computes the distance between an embedding vector and the embedding of an input node. The default distance is the squared L2 norm of the input (source) embedding vector and the embedding vector of the (target) input node. 
@@ -16 +16,5 @@ The `.vectors.distanceByEmbedding` algorithm computes the distance between an em
-    CALL neptune.algo.vectors.distanceByEmbedding(embedding, n)
+    CALL neptune.algo.vectors.distanceByEmbedding(embedding, n,
+       {
+           metric: The distance computation metric (optional)
+       }
+    )
@@ -29,0 +34,44 @@ The result of a `MATCH` statement from which you want to source distance computa
+  * **metric** _(optional)_ – _type:_ `string` _default: L2Squared_. 
+
+The distance metric to use for distance computation. 
+
+    * Must be one of [L2Squared, L2, CosineSimilarity, CosineDistance, DotProduct]. 
+
+    * Case-insensitive. 
+
+    * The descriptions for the metrics, where x and y are vectors, x_i and y_i are the components of x and y vectors, θ is the angle between the x and y vectors, ||x|| denotes the magnitude (length, l2-norm, norm2) of vector x, ∑ denotes summation: 
+
+      * L2-Squared: Squared Euclidean distance between two vectors: 
+
+![L2-Squared: Squared Euclidean distance between two vectors.](/images/neptune-analytics/latest/userguide/images/vectors-distance/L2Squared.png)
+
+For more information on L2-Squared, see [ https://en.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance](https://en.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance). 
+
+      * L2: Euclidean distance (L2 norm) between two vectors: 
+
+![L2: Euclidean distance \(L2 norm\) between two vectors.](/images/neptune-analytics/latest/userguide/images/vectors-distance/L2.png)
+
+For more information on L2, see [ https://en.wikipedia.org/wiki/Euclidean_distance](https://en.wikipedia.org/wiki/Euclidean_distance). 
+
+      * Dot Product: Inner dot product of two vectors: 
+
+![Dot Product: Inner dot product of two vectors.](/images/neptune-analytics/latest/userguide/images/vectors-distance/dot1.png)
+
+For more information on Dot Product, see [ https://en.wikipedia.org/wiki/Dot_product](https://en.wikipedia.org/wiki/Dot_product). 
+
+      * Cosine Similarity: Measures the cosine of the angle between two vectors (higher value means more similar): 
+
+![Cosine Similarity: Measures the cosine of the angle between two vectors \(higher value means more similar\).](/images/neptune-analytics/latest/userguide/images/vectors-distance/cossimi4.png)
+
+Range: [-1, 1] 
+
+For more information on Cosine Similarity, see [ https://en.wikipedia.org/wiki/Cosine_similarity](https://en.wikipedia.org/wiki/Cosine_similarity). 
+
+      * Cosine Distance: Opposite of cosine similarity (lower value means more similar): 
+
+![Cosine Distance: Opposite of cosine similarity \(lower value means more similar\).](/images/neptune-analytics/latest/userguide/images/vectors-distance/cosdist1.png)
+
+Range: [0, 2] 
+
+For more information on Cosine Distance, see [ https://en.wikipedia.org/wiki/Cosine_similarity#Cosine_distance](https://en.wikipedia.org/wiki/Cosine_similarity#Cosine_distance). 
+
@@ -56,0 +105,8 @@ For every pair of source node and target node:
+    WITH [1.1, 1.2, 1.3, 1.4] as embedding 
+    MATCH (n)
+    WHERE id(n)="v1"
+    CALL neptune.algo.vectors.distanceByEmbedding(embedding, n, {metric: "CosineSimilarity" })
+    YIELD distance
+    return embedding, n, distance
+    
+