# How does Word2Vec CBOW softmax work with multiple context words?

I'm referring to following paper from Xin Rong - "word2vec Parameter Learning Explained", to be precise the equation (4):

$$p(w_j|w_I) = \frac{\exp(\mathbf{v’}^{T}_{w_{j}}\mathbf{v}_{w_{I}})}{\sum_{j'=1}^{V}\exp(\mathbf{ v’}^{T}_{w_{j'}} \mathbf{ v}_{w_{I}})}$$ Simply said, do I understand correctly that wj describes my target word and wi is the single context word?

Would the equation look different with multiple context words or does it remain the same because wi describes the average of all context words?

Edit: Added the equation in TeX

## 1 Answer

You’ve correctly understood $$w_j$$ and $$w_I$$: they’re the target word and input word.

Section 1.2 goes into more detail about the CBOW case; I’m filling in the pieces that weren’t explicit.

The LHS of the equation would be different: $$p(w_j \mid w_{I1}, \ldots, w_{IC})$$ to show that you’re conditioning on several input words.

The RHS is also different, because we no longer use $$\mathbf{v}_{w_I}$$ to represent the input. Instead, the numerator and denominator should both replace that term with $$\bf h$$ from equation (18):

$$\mathbf{h} = \frac{1}{C} \left(\mathbf{v}_{w_{I1}} + \mathbf{v}_{w_{I2}} + \ldots + \mathbf{v}_{w_{IC}} \right)^T$$

This term averages the representations of the $$C$$ input words.

• Thank you for your quick response. I'm at a loss here. How would the final equation look like? Do I insert $h$ into $v_{w_{I}}$ of (4)? Apr 6, 2021 at 23:33
• Yep! The results of that derivation are equations 19–21 in the paper. Another way to get the expression you’re looking for is to negate, then exponentiate, equation 19. Apr 6, 2021 at 23:39
• I know that I've already accepted your answer but I have one follow up question regarding equation 19-21. Am I understanding it correctly that $w_{o}$ is my actual target word from the vocabulary $V$ and $j*$ is the corresponding index in the output layer. Thanks again for helping me to understand it in depth, you can't imagine how grateful I am. Apr 7, 2021 at 14:18
• Yup, that’s what both are! They’re defined on page 3. Apr 7, 2021 at 14:22