EmbeddingPoolingStrategy

Enums · AiDotNet.Enums

How a text embedding model collapses a sequence of token representations into a single vector for the whole piece of text.

For Beginners

An embedding model produces one vector per token — one per word-piece of your sentence. To compare two sentences you need a single vector for each, so the token vectors are combined (“pooled”). This chooses how.

How It Works

This was previously nested inside TransformerEmbeddingNetwork<T>. A type nested in a generic class is a distinct type for every type argument, so TransformerEmbeddingNetwork<float>.PoolingStrategy and the double one were unrelated types, and neither could be named from a non-generic options class. Promoting it here makes it usable as configuration, which is what it always described.

Not to be confused with AiDotNet.VisionLanguage.Encoders.PoolingStrategy, which pools image patches and offers a different set of choices.

Fields

Field Summary
EmbeddingPoolingStrategy ClsToken Uses the representation of the first token, typically the [CLS] token.
EmbeddingPoolingStrategy Max Takes the maximum value across all sequence positions for each dimension.
EmbeddingPoolingStrategy Mean Averages all token representations across the sequence.
int value__