Natural Language Processing · TEE · papers

Q7b · Distributional hypothesis and cosine

2022-11-22 · final · recovered AI paper

Previous examination · complete worked answers

Question. Justify “You shall know a word by the company it keeps.” Calculate cosine similarity of w₁=[0.2,0.1,0.3,0.4] and w₂=[0.3,0,0.2,0.5]. [10 marks]

Answer

Words occurring in similar contexts often have related meanings; vectors encode their context distributions. This is a statistical tendency, not proof that every similar-context pair is synonymous—antonyms can share contexts too.

Given

u=[0.2, 0.1, 0.3, 0.4]; v=[0.3, 0, 0.2, 0.5]

To find

Cosine similarity in the given coordinate order.

Formula: which one and why

\cos(u,v)=\frac{u\cdot v}{\|u\|\|v\|}LaTeX: \cos(u,v)=\frac{u\cdot v}{\|u\|\|v\|}

Step 1. Multiply matching coordinates

0.2×0.3 + 0.1×0 + 0.3×0.2 + 0.4×0.5 = 0.32

Step 2. Calculate both squared lengths

u: 0.2² + 0.1² + 0.3² + 0.4² = 0.30000000000000004; v: 0.3² + 0² + 0.2² + 0.5² = 0.38

Step 3. Take square roots and divide

0.32 / (√0.30000000000000004 × √0.38) = 0.947758204

Final answer

Cosine=0.947758204. This measures direction, not a probability.