Enum Class PoolingMode

java.lang.Object
java.lang.Enum<PoolingMode>
com.oracle.coherence.rag.model.PoolingMode
All Implemented Interfaces:
Serializable, Comparable<PoolingMode>, Constable

public enum PoolingMode extends Enum<PoolingMode>
Enumeration of pooling modes for text embedding models.

This enum defines the different strategies for pooling token embeddings to create a single vector representation of a text sequence. The pooling mode determines how the individual token embeddings from a transformer model are combined into a final document or sentence embedding.

Different pooling modes can affect the quality and characteristics of the resulting embeddings, with some being more suitable for certain types of text or downstream tasks.

Since:
25.09
Author:
Aleks Seovic 2025.07.04
  • Enum Constant Details

    • CLS

      public static final PoolingMode CLS
      Use the [CLS] token embedding as the final representation.

      This mode uses the special classification token embedding that is typically placed at the beginning of the input sequence in BERT-style models. The [CLS] token is specifically trained to aggregate information from the entire sequence during pre-training.

      This is commonly used with BERT and similar transformer models where the [CLS] token serves as a sentence-level representation.

    • MEAN

      public static final PoolingMode MEAN
      Use the mean (average) of all token embeddings as the final representation.

      This mode computes the element-wise average of all token embeddings in the sequence, excluding special tokens like [PAD]. Mean pooling captures information from all tokens equally and often produces robust sentence embeddings.

      This approach is particularly effective for sentence similarity tasks and is commonly used with models like Sentence-BERT.

  • Method Details

    • values

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