LLM Learning Hub

workspace/llm-course/home

Dot Product

The dot product of two vectors is the sum of element-wise products; when vectors are L2-normalised it equals cosine similarity, and it is the fastest similarity metric for inner-product indexes.

What is Dot Product?

The dot product of two vectors is the sum of element-wise products; when vectors are L2-normalised it equals cosine similarity, and it is the fastest similarity metric for inner-product indexes.

The dot product of two vectors is the sum of element-wise products; when vectors are L2-normalised it equals cosine similarity, and it is the fastest similarity metric for inner-product indexes.

Where is it used?

FAISS `IndexFlatIP` and Qdrant `Distance.DOT` are used with normalised embeddings from OpenAI and BGE models to accelerate search via batched matrix multiplication.

How to build it

Normalise embeddings with `F.normalize(vectors, dim=-1)`, build `faiss.IndexFlatIP(d)`, add vectors, and call `.search(query, k)` — results are equivalent to cosine but faster.