Pool three token vectors by averaging
Read a complete operation before typing its result. · 138 words
An embedding maps each token to a fixed-length list of numbers called a vector. Mean pooling combines token vectors by adding them component by component and dividing by the token count. For a three-token museum review, suppose 'small' is [1,0,0], 'bright' is [0,1,0], and 'useful' is [0,0,1] in a toy space. Their average is ([1,0,0]+[0,1,0]+[0,0,1])/3 = [1/3,1/3,1/3]. This pooled vector can represent the whole review for a classifier.
Now consider a bookstore query. A toy embedding gives 'waterproof' [1,0], 'hiking' [0,1], and 'boots' [1,1]. Averaging produces [(1+0+1)/3,(0+1+1)/3] = [2/3,2/3]. The same vector results if the words are reordered, useful for a quick passage summary but blind to word order. Compare it with a catalog vector [1,1] using dot product, the sum of matching coordinate products: (2/3)(1)+(2/3)(1)=4/3. A larger dot product means a stronger match in this toy setup.
Check your recall
For the bookstore query with token vectors [1,0], [0,1], and [1,1], what is the mean-pooled vector?
Check your answer
The mean-pooled vector is [2/3,2/3]. Add the coordinates to get [2,2], then divide each component by 3.
Sources and credits
Original KeyTouch lesson. Background reading · Google · Neural networks.