Class Embedding
- java.lang.Object
-
- com.microsoft.semantickernel.ai.embeddings.Embedding
-
public class Embedding extends Object
Represents a strongly typed vector of numeric data.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description floatcosineSimilarity(Embedding other)Calculates the cosine similarity of this vector with another.Embeddingdivide(float divisor)Divide theEmbeddingvector by a divisor.floatdot(Embedding other)Calculates the dot product of thisEmbeddingwith another.static Embeddingempty()floateuclideanLength()Calculates the Euclidean length of this vector.List<Float>getVector()Return the embedding vector as a read-only list.Embeddingmultiply(float multiplier)Multiply theEmbeddingvector by a multiplier.Embeddingnormalize()Normalizes the underlying vector, such that the Euclidean length is 1.
-
-
-
Method Detail
-
empty
public static Embedding empty()
-
getVector
public List<Float> getVector()
Return the embedding vector as a read-only list.- Returns:
- The embedding vector as a read-only list.
-
dot
public float dot(@Nonnull Embedding other)
Calculates the dot product of thisEmbeddingwith another.- Parameters:
other- The otherEmbeddingto compute the dot product with- Returns:
- The dot product between the
Embeddingvectors
-
euclideanLength
public float euclideanLength()
Calculates the Euclidean length of this vector.- Returns:
- Euclidean length
-
cosineSimilarity
public float cosineSimilarity(@Nonnull Embedding other)
Calculates the cosine similarity of this vector with another.- Parameters:
other- The other vector to compute cosine similarity with.- Returns:
- Cosine similarity between vectors
-
multiply
public Embedding multiply(float multiplier)
Multiply theEmbeddingvector by a multiplier.- Parameters:
multiplier- The multiplier to multiply theEmbeddingvector by- Returns:
- A new
Embeddingwith the vector multiplied by the multiplier
-
divide
public Embedding divide(float divisor)
Divide theEmbeddingvector by a divisor.- Parameters:
divisor- The divisor to divide theEmbeddingvector by- Returns:
- A new
Embeddingwith the vector divided by the divisor
-
normalize
public Embedding normalize()
Normalizes the underlying vector, such that the Euclidean length is 1.- Returns:
- A new
Embeddingwith the normalized vector
-
-