Natural Language Processing · free preview

Word Vectors from Co-Occurrence Counts

The distributional hypothesis, word-context co-occurrence matrices, and cosine as the standard similarity measure for meaning vectors.

1. Word Vectors from Co-Occurrence Counts

Word Vectors from Co-Occurrence Counts

2. The word-context matrix

The word-context matrix

3. Counting the harbour logbook

Counting the harbour logbook

4. Cosine of two count vectors

Two words have context vectors over the same dimensions. Word A has a nonzero count (1) in a dimension where word B is zero, and word B has a nonzero count (3) in a dimension where word A is zero, and they share no dimension where both are nonzero. What is their cosine similarity? Answer as a decimal.

5. Cosine of two small vectors

Compute cos⁡(v,w)\cos(\mathbf{v}, \mathbf{w}) for v=[3,1]\mathbf{v} = [3, 1] and w=[1,2]\mathbf{w} = [1, 2] and round to three decimals.

6. Why divide by the lengths?

A raw dot product ranks ferry as more similar to a very frequent word than to tug, even though ferry and tug share most of their contexts. Why does the cosine fix this?

7. One cell of the co-occurrence matrix

In a corpus, the word "gull" occurs in 3 sentences, and in every one of those sentences "mast" appears exactly once inside the context window around "gull". What value goes in the cell for row "gull", column "mast" of the word-context matrix? Answer with the number.

8. Two words with identical rows

Two words accumulate exactly the same context counts over a corpus, every dimension matching. What is their cosine, and what does the outcome mean?

Practice this interactively

Free account · instant grading · spaced review that schedules itself.

Start this course for free