Package com.tnsai.llm.cache
Enum Class EmbeddingTask
- All Implemented Interfaces:
Serializable,Comparable<EmbeddingTask>,Constable
The task an embedding is generated for.
Instruction-tuned embedding models (e.g. nomic-embed-text) are
contrastively trained with a per-task instruction prefix and condition the
vector on it — the same text embedded for two different tasks yields
two different vectors. Picking the right task is what pulls related text apart
from unrelated text; embedding such a model with no task at all collapses every
vector into one degenerate sub-space.
Symmetric vs asymmetric
CLUSTERINGandCLASSIFICATIONare symmetric: like is compared with like (prompt↔prompt similarity, dedup, semantic textual similarity, the semantic cache). Both sides of a comparison must use the same task or the vectors are not comparable.QUERYandDOCUMENTare the asymmetric retrieval pair: a short query is embedded asQUERYand matched against corpus text embedded asDOCUMENT(the RAG / vector-store path).
Providers whose model has no task convention (e.g. HashEmbeddingProvider,
OpenAI text-embedding-3) ignore this and return the same vector regardless
— see the task-free defaults on EmbeddingProvider.
- Since:
- 0.13.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic EmbeddingTaskReturns the enum constant of this class with the specified name.static EmbeddingTask[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
QUERY
Asymmetric retrieval: a search query, matched againstDOCUMENTvectors. -
DOCUMENT
Asymmetric retrieval: corpus text to be retrieved by aQUERY. Also the neutral default for embedding a single standalone piece of text. -
CLUSTERING
Symmetric similarity: clustering, deduplication, semantic textual similarity, semantic cache. -
CLASSIFICATION
Symmetric classification / label assignment.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-