Glossary · Phase 5 · Transformers
Mean pooling
Turning a text's token vectors into one vector for the whole text by averaging them.
An encoder gives back one vector per token. A sentence of 12 tokens gives 12 vectors. Search needs one vector per text, so the model squashes the token vectors into one. This step is called pooling. The most common way is mean pooling: take the average. Add up the vectors number by number, then divide by how many there are.
Try it now
The difference comes down to who can see what.
Learn it properly
Encoders and embedding models · BERT-style models and where they fit. About 30 minutes.
Other terms from the same lesson
- BERT: Google's 2018 encoder model, trained by hiding words and guessing them from both sides. Its descendants still power much search and classification.
- bidirectional: Reading in both directions: each token can look at the words before and after it, as encoders like BERT do.
- contrastive learning: Training that pulls the embeddings of matching pairs (like a question and its answer) together and pushes mismatched pairs apart.
- cross-attention: Attention where one sequence looks at another, such as a translation model's decoder reading the encoder's output.
- cross-encoder: A model that reads a query and a document together and gives one relevance score. More accurate than comparing embeddings but slower, so it reranks a short list.
- encoder: A transformer that reads the whole text at once to understand it, used for embeddings and classification.
- masked language modeling: Training by hiding some tokens and asking the model to guess them from the words on both sides. It's how BERT learned.
Never trained an AI?
Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.