# Dot product

> Dot product: Multiply two vectors element by element and add the results. Grows with both their alignment and their lengths.

Canonical: https://llmdojo.dev/glossary/dot-product

Also called dot products.

Multiply two vectors element by element and add the results. Grows with both their alignment and their lengths.

Learn it in the lesson: [Measuring similarity](https://llmdojo.dev/learn/model-foundations/embeddings/measuring-similarity) (Model Foundations · Embeddings: From Token IDs to Vectors).

## Interview questions about Dot product

- [In a notebook, implement embedding retrieval with cosine similarity. How does cosine relate to the dot product, and when would you choose each?](https://llmdojo.dev/interview/q/in-a-notebook-implement-embedding-retrieval-with-cosine-similarity-how-does-cosine)
- [Your vector database only supports dot-product search, but your embedding model's documentation says to compare vectors with cosine similarity. What do you do, and why does it work?](https://llmdojo.dev/interview/q/your-vector-database-only-supports-dot-product-search-but-your-embedding-model)
- [Your team switches to a newer embedding model with the same 384 dimensions and starts embedding incoming queries with it. Search quality collapses, but nothing errors. Explain what happened and how you'd run the migration.](https://llmdojo.dev/interview/q/your-team-switches-to-a-newer-embedding-model-with-the-same-384)
- [Walk me through scaled dot-product attention. What are queries, keys and values, and why divide by the square root of d?](https://llmdojo.dev/interview/q/walk-me-through-scaled-dot-product-attention-what-are-queries-keys-and)
- [Using only plain Python loops, implement a numerically stable sigmoid, a stable softmax and single-head scaled dot-product attention.](https://llmdojo.dev/interview/q/using-only-plain-python-loops-implement-a-numerically-stable-sigmoid-a-stable)
- [Explain FlashAttention, the KV cache and RoPE, and the memory and compute trade-offs each addresses.](https://llmdojo.dev/interview/q/explain-flashattention-the-kv-cache-and-rope-and-the-memory-and-compute)
- [What is attention, exactly how are the queries, keys and values computed, and how does a KV cache speed up decoding?](https://llmdojo.dev/interview/q/what-is-attention-exactly-how-are-the-queries-keys-and-values-computed)
- [Build a minimal embedding-based RAG pipeline: chunk, index, retrieve and assemble the prompt. How do you evaluate retrieval, resist injected instructions and abstain when unsure?](https://llmdojo.dev/interview/q/build-a-minimal-embedding-based-rag-pipeline-chunk-index-retrieve-and-assemble)

## Related
- [Embedding](https://llmdojo.dev/glossary/embedding)
- [Embedding table](https://llmdojo.dev/glossary/embedding-table)
- [Cosine similarity](https://llmdojo.dev/glossary/cosine-similarity)
- [Contextual embedding](https://llmdojo.dev/glossary/contextual-embedding)
- [Semantic search](https://llmdojo.dev/glossary/semantic-search)
- [Glossary of every term](https://llmdojo.dev/glossary)
