Package dev.langchain4j.data.embedding
Class Embedding
-
- All Implemented Interfaces:
public class 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.
-
-
Method Summary
Modifier and Type Method Description Array<float>
vector()
Returns the vector. List<Float>
vectorAsList()
Returns a copy of the vector as a list. void
normalize()
Normalize vector int
dimension()
Returns the dimension of the vector. boolean
equals(Object o)
int
hashCode()
String
toString()
static Embedding
from(Array<float> vector)
Creates a new Embedding from the given vector. static Embedding
from(List<Float> vector)
Creates a new Embedding from the given vector. -
-
Constructor Detail
-
Embedding
Embedding(Array<float> vector)
Creates a new Embedding.- Parameters:
vector
- the vector, takes ownership of the array.
-
-
Method Detail
-
vectorAsList
List<Float> vectorAsList()
Returns a copy of the vector as a list.
- Returns:
the vector as a list.
-
normalize
void normalize()
Normalize vector
-
dimension
int dimension()
Returns the dimension of the vector.
- Returns:
the dimension of the vector.
-
hashCode
int hashCode()
-
from
static Embedding from(Array<float> vector)
Creates a new Embedding from the given vector.
- Parameters:
vector
- the vector, takes ownership of the array.- Returns:
the new Embedding.
-
-
-
-