Show how scale affects unnormalized retrieval

Read a complete operation before typing its result. · 164 words

Suppose a search engine stores each document as a two-number vector and ranks documents with a dot-product score. This is called unnormalized retrieval because it does not divide by vector lengths. A query is q=[1,1]. Three documents are d1=[8,0], d2=[5,5], and d3=[0,9]. Their scores are q dot d1=8, q dot d2=10, and q dot d3=9, so d2 ranks first. The arithmetic is simple: multiply corresponding entries and add the two products.

Now change only the scale of d3 by replacing it with 10*d3=[0,90]. Its dot-product score becomes 90, so it jumps from second place to first. The direction of d3 has not changed, but its larger coordinates produce larger products. Normalizing each vector by its Euclidean norm before taking the dot product removes this length effect. This normalized comparison is cosine similarity: it compares direction rather than magnitude. For example, normalized d2 has score 1, while original d3 has score 9/(sqrt(2)*9)=1/sqrt(2), about 0.71. The scaled d3 has the same cosine score as original d3.

Check your recall

Without normalization, which document ranks first, and what happens if d3 is scaled by 10?

Check your answer

Initially d2 ranks first with score 10. After d3 becomes [0,90], it ranks first with score 90 because unnormalized dot products are sensitive to vector magnitude.

Sources and credits

Original KeyTouch lesson. Background reading · Google · Neural networks.