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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Embedding(Array<float> vector) Creates a new Embedding.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Embedding

        Embedding(Array<float> vector)
        Creates a new Embedding.
        Parameters:
        vector - the vector, takes ownership of the array.
    • Method Detail

      • vector

         Array<float> vector()

        Returns the vector.

        Returns:

        the vector.

      • 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.

      • 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.

      • from

         static Embedding from(List<Float> vector)

        Creates a new Embedding from the given vector.

        Parameters:
        vector - the vector.
        Returns:

        the new Embedding.