# Cosine similarity

> Cosine similarity: How closely two vectors point the same way, from −1 to 1, ignoring their lengths. The usual way to compare embeddings.

Canonical: https://llmdojo.dev/glossary/cosine-similarity

How closely two vectors point the same way, from −1 to 1, ignoring their lengths. The usual way to compare embeddings.

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 Cosine similarity

- [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)
- [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)
- [What is an embedding table, and what does it mean for two embeddings to be similar?](https://llmdojo.dev/interview/q/what-is-an-embedding-table-and-what-does-it-mean-for-two)

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