I'm taking Andrew Ng's course on Sequence Models on Coursera, and he has a pretty fascinating discussion of how to "debias" word embeddings by removing the learned gender component (or race component, etc) of various words. I have some questions about the intuition behind the algorithm, and I've posted a screenshot below that provides an overview of that algorithm. (This question was inspired by our homework, but won't directly help me with a homework question.)

(NOTE: While writing this question I found some of the answers myself, which I've posted as an answer. But I'm still interested in additional feedback.)

What's not on the slide is that first he gets a bias vector $g$ by calculating $$g = e_{woman} - e_{man}$$ where $e_{x}$ is the embedding for the word $x$.

I think because $e_{woman}$ comes first in the equation, $g$ will be positively correlated with femininity and negatively correlated with masculinity. I think that $g$ is basically an abstract "axis" of gender - I say abstract because most components in $g$ will be nonzero, so it isn't an axis along a single embedding dimension.

Using $g$, he demonstrates that learned word embeddings can pick up a gender component. For example the cosine similarity of $g$ with some names is:

marie 0.315597935396
sophie 0.318687898594
ronaldo -0.312447968503

Getting similar cosine similarities between $g$ and other words shows why we would want to eliminate the gender component of these words (which would cause these cosine similarities to drop to 0, I think):

technology -0.131937324476
fashion 0.0356389462577
teacher 0.179209234318
engineer -0.0803928049452

To perform the debiasing, we calculate $e^{bias\_component}$ for each embedding and just subtract it from the embedding. To calculate this, we get the vector projection of the word we want to debias ($e$) onto $g$. I'm not good at linear algebra, and while I think I understand the equations for vector projection, I don't fully understand the intuition of what the resulting vector represents.

My best intuition is that $e^{bias\_component}$ is the amount that, if we subtract it from $e$, will make $e$ orthogonal to our abstract gender axis. However, while I don't doubt that embeddings can pick up gender bias in general, it isn't clear to me what proof we have that a specific word did so, or to what extent. The existence of $e^{bias\_component}$ doesn't seem like such a proof - we have chosen to project $e$ onto $g$ to obtain $e^{bias\_component}$, but we will do that for every word. Basically, it seems that we are just assuming that gender bias is uniformly distributed among our words.

My other question concerns the value of $g$. Since it is equal to $e_{woman} - e_{man}$, if we want to eliminate the gender component of a word, shouldn't we be setting $g$ to $1/2 * (e_{woman} - e_{man})$ to get the midway point between the two vectors?

course description of arithmetic for debiasing word embeddings


1 Answer 1


I was able to mostly answer my own questions (I think):

We aren't actually assuming that every word is equally biased. Some word $e1$ may be nearly orthogonal to our abstract axis $g$. If that is the case, the magnitude of the projected vector will be very low, and little correction will be done to $e1$. Another word $e2$ might have a direction that is very close to the abstract axis, so the magnitude of the projected vector will be nearly as large as the original vector $e2$. In that case $e2$ will be nearly zeroed out by the projections.

I do think that we're assuming that gender is expressed only in proportion to this axis. $g$ could be imprecise or inaccurate, in which case our calculations would be correspondingly wrong. I'm much less sure about the following, but perhaps the embeddings could also have learned to express gender along multiple axes, which we also wouldn't adequately correct for.

As for the second question about $1/2 * (e_{woman} - e_{man})$, this is wrong because we're treating $g$ as an axis, not an amount by which to correct. A simple example demonstrates this: If $e3$ is some "masculine" word, its projection onto $g$ will be of negative length. We will then subtract that negative projection, i.e. we will add it, correcting the masculine word by making it more feminine.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.