Listen: Cosine Similarity or Dot Product?

An examination of the Chrome codebase reveals that the history_embeddings component uses the dot product of normalized vectors to perform similarity searches.

Listen

Transcript

If you want to understand how Google engineers approach machine learning, looking at the open source Chrome codebase is a great place to start. A close look at Chrome's browser history search tool reveals a clever, highly efficient approach to vector similarity.

To find similar history items, Chrome compares vector embeddings. Instead of using a standard cosine similarity formula, the code normalizes all vectors to a unit length of one. Then, it calculates the dot product between them.

Mathematically, when your vectors are already normalized to a magnitude of one, the dot product and cosine similarity are exactly the same. The standard cosine formula requires dividing the dot product by the magnitudes of the vectors. By ensuring every vector is already normalized, Google eliminates that division step entirely.

This approach gives you the exact same mathematical result as cosine similarity, but with much less computational overhead. It is a simple, elegant optimization that makes semantic search in the browser incredibly fast and efficient. It is a classic example of how Google designs for performance at scale.