Sitemap
Suvasis M

Suvasis M

Owner of dronomy.io. and https://multirotors.store and working on financial microstructures for stocks/crypto https://vectorblock.io and https://volstrat.io

Member-only story

Pooling in Embedding

2 min readSep 27, 2024

Pooling is typically used in natural language processing (NLP) to reduce the dimensionality of feature representations, making them more compact while retaining the most relevant information. In this context, it can be used to transform variable-length input sequences into fixed-size representations.

sample code

Press enter or click to view image in full size

CLS Pooling

Extracts the first token (or embedding) from each sequence, which is often used in models like BERT where the first token summarizes the entire input. It’s useful when the first token has special meaning (e.g., classification in transformer models).

Press enter or click to view image in full size
Press enter or click to view image in full size

Mean pooling

Computes the average of all tokens in the sequence, summarizing the sequence by averaging all embeddings. Mean pooling treats all elements equally, giving a balanced summary of the sequence. It works well when all parts of the sequence are important.

Fixed-size output: No matter the length of the input sequence (whether it’s 5 words or 100 words), mean pooling will…

--

--

Suvasis M
Suvasis M

Written by Suvasis M

Owner of dronomy.io. and https://multirotors.store and working on financial microstructures for stocks/crypto https://vectorblock.io and https://volstrat.io