Enum Class EmbeddingInputType

java.lang.Object
java.lang.Enum<EmbeddingInputType>
dev.langchain4j.model.embedding.request.EmbeddingInputType
All Implemented Interfaces:
Serializable, Comparable<EmbeddingInputType>, Constable

@Experimental public enum EmbeddingInputType extends Enum<EmbeddingInputType>
The role a piece of text plays in a retrieval task, allowing a provider to encode it differently.

Embedding the same text as a QUERY versus a DOCUMENT can significantly improve retrieval quality on providers that support the distinction (the canonical RAG "query vs passage" asymmetry). This enum captures only the distinction that is universally supported across providers that expose the concept (Cohere, Voyage, Nomic, Google Vertex/Gemini, NVIDIA, ...). Richer, provider-specific task types (e.g. Google's SEMANTIC_SIMILARITY or CODE_RETRIEVAL_QUERY) are exposed via provider-specific parameters rather than this common enum.

Since:
1.18.0
  • Enum Constant Details

    • QUERY

      public static final EmbeddingInputType QUERY
      The text is a search query (the canonical "query" side of a retrieval pair).
    • DOCUMENT

      public static final EmbeddingInputType DOCUMENT
      The text is a document/passage to be indexed and later retrieved (the "passage" side).
  • Method Details

    • values

      public static EmbeddingInputType[] 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

      public static EmbeddingInputType valueOf(String name)
      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 name
      NullPointerException - if the argument is null