Vectors copy their data, skews included
Why it matters Embeddings learn whatever patterns the text contains, including ones nobody wants. Word vectors trained on real news put some jobs closer to "she" and others closer to "he". You can measure it, and you should.
Make a gender direction from pairs that differ only in gender: queen minus king, woman minus man, princess minus prince, girl minus boy, added up and scaled to length 1. A word's position along it is its (unit) vector dotted with the direction: positive leans "she", negative leans "he".
The toy world can add a skew: with skew 0.4, nurse sentences say "she" 90% of the time and engineer sentences say "he" 90% of the time. Doctors and teachers stay 50:50. Nothing else changes.
Removing it, and the catch
You can subtract each job's component along the direction, which sets its position to exactly 0. In this toy world that works almost completely: measured after removal, nurse and engineer sit about equally close to "she" and "he" (cosines 0.114 and 0.118 either way). That is because here the skew lives in one word, the pronoun. On word vectors trained on real text, researchers found the opposite: the skew is spread across thousands of words that one direction cannot capture, so after removal a job's neighbours still give it away. So a clean ruler reading is not proof the skew is gone, and the honest fix starts with the data.
Words and symbols in this lesson
- embedding
- the row of learned numbers that stands for one symbol
- window
- how many words either side count as a word's company
- PPMI
- how much more often two words meet than chance would give, with negatives set to 0
- toy world
- a made-up text with planted structure, so the right answers are known
- skew
- a lopsided pattern in the data that the vectors copy
Write gender_direction(X) and position(X, word, g). Both work on unit vectors: divide each word's vector by its length first, then take the four differences (queen minus king, woman minus man, princess minus prince, girl minus boy), add them and scale the sum to length 1. A position is the word's unit vector dotted with g. Fill pos: skew (0.0 and 0.4) to a dict of the four jobs' positions, using count vectors with the whole sentence as the window. Then write remove(x, g) that takes out the component along g.
Spotted a problem in this lesson? Report it · Ask about this lesson
This exercise opens soon
Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.
This browser is blocking cookies for learn.floati.life, so lessons you finished here cannot open in order. Allow cookies for this site and reload.