Package dev.langchain4j.data.embedding
Class Embedding
java.lang.Object
dev.langchain4j.data.embedding.Embedding
Represents a dense vector embedding of a text.
This class encapsulates a float array that captures the "meaning" or semantic information of the text.
Texts with similar meanings will have their vectors located close to each other in the embedding space.
The embeddings are typically created by embedding models.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the dimension of the vector.boolean
static Embedding
from
(float[] vector) Creates a new Embedding from the given vector.static Embedding
Creates a new Embedding from the given vector.int
hashCode()
void
Normalize vectortoString()
float[]
vector()
Returns the vector.Returns a copy of the vector as a list.
-
Constructor Details
-
Embedding
public Embedding(float[] vector) Creates a new Embedding.- Parameters:
vector
- the vector, takes ownership of the array.
-
-
Method Details
-
vector
public float[] vector()Returns the vector.- Returns:
- the vector.
-
vectorAsList
Returns a copy of the vector as a list.- Returns:
- the vector as a list.
-
normalize
public void normalize()Normalize vector -
dimension
public int dimension()Returns the dimension of the vector.- Returns:
- the dimension of the vector.
-
equals
-
hashCode
public int hashCode() -
toString
-
from
Creates a new Embedding from the given vector.- Parameters:
vector
- the vector, takes ownership of the array.- Returns:
- the new Embedding.
-
from
Creates a new Embedding from the given vector.- Parameters:
vector
- the vector.- Returns:
- the new Embedding.
-