Record Class PoolingConfig
java.lang.Object
java.lang.Record
com.oracle.coherence.rag.model.PoolingConfig
- Record Components:
dimension- the dimensionality of the word embeddingsclsToken- whether CLS token pooling is enabledmean- whether mean token pooling is enabled
Configuration record for pooling settings in transformer-based embedding models.
This record encapsulates the pooling configuration parameters that determine how token embeddings are aggregated into a single sentence or document embedding. It supports the common pooling strategies used in BERT-style transformer models.
The configuration is designed to be serialized from/to JSON configuration files that typically accompany pre-trained embedding models, using JSON-B annotations to map to the standard configuration format used by sentence-transformers and similar libraries.
Supported pooling modes:
- CLS token pooling: Uses the [CLS] token embedding as the sentence representation
- Mean token pooling: Averages all token embeddings to create the sentence representation
- Since:
- 25.09
- Author:
- Aleks Seovic 2025.07.04
-
Constructor Summary
ConstructorsConstructorDescriptionPoolingConfig(int dimension, boolean clsToken, boolean mean) Creates an instance of aPoolingConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanclsToken()Returns the value of theclsTokenrecord component.intReturns the value of thedimensionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanmean()Returns the value of themeanrecord component.mode()Determines the pooling mode based on the configuration flags.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
PoolingConfig
-
-
Method Details
-
mode
Determines the pooling mode based on the configuration flags.This method validates that exactly one pooling mode is enabled and returns the corresponding
PoolingModeenum value. The configuration must specify either CLS token pooling or mean pooling, but not both.- Returns:
- the pooling mode to use for sentence embedding
- Throws:
IllegalStateException- if both or neither pooling modes are enabled
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
dimension
-
clsToken
-
mean
-