Class EmbeddingFunctions

java.lang.Object
com.tnsai.memory.advanced.EmbeddingFunctions

public final class EmbeddingFunctions extends Object
Decorators for composing EmbeddingFunction instances.
Since:
0.14.0
  • Method Details

    • matryoshka

      public static EmbeddingFunction matryoshka(EmbeddingFunction delegate, int dimensions)
      Reduces a Matryoshka-compatible embedding to a normalized prefix.

      Each call returns a new array containing the first dimensions values of the delegate output, normalized to unit L2 length. A zero prefix remains a zero vector. The delegate-owned array is never modified or exposed.

      Parameters:
      delegate - embedding function that returns the full vector
      dimensions - number of prefix dimensions to retain
      Returns:
      immutable decorator configuration producing reduced embeddings
      Throws:
      IllegalArgumentException - if dimensions is not positive or a retained value is not finite
      EmbeddingDimensionMismatchException - if a delegate result is shorter than dimensions