Enum Class PoolingMode
- All Implemented Interfaces:
Serializable, Comparable<PoolingMode>, Constable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic PoolingModeReturns the enum constant of this class with the specified name.static PoolingMode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
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
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
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
-