Package com.tnsai.memory.advanced
Class EmbeddingFunctions
java.lang.Object
com.tnsai.memory.advanced.EmbeddingFunctions
Decorators for composing
EmbeddingFunction instances.- Since:
- 0.14.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic EmbeddingFunctionmatryoshka(EmbeddingFunction delegate, int dimensions) Reduces a Matryoshka-compatible embedding to a normalized prefix.
-
Method Details
-
matryoshka
Reduces a Matryoshka-compatible embedding to a normalized prefix.Each call returns a new array containing the first
dimensionsvalues 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 vectordimensions- number of prefix dimensions to retain- Returns:
- immutable decorator configuration producing reduced embeddings
- Throws:
IllegalArgumentException- ifdimensionsis not positive or a retained value is not finiteEmbeddingDimensionMismatchException- if a delegate result is shorter thandimensions
-