What is cosine similarity?
The dot product of two vectors divided by both their lengths. It measures direction only, from (opposite) to (the same).
Where it is taught
The dot product. One number that says how much two vectors point the same way. It is the most used calculation in all of AI.
What the lesson leaves you with
- multiplies matching entries and adds them up, giving one number.
- It is positive for similar directions, zero for perpendicular, negative for opposite.
- Cosine similarity divides out the lengths so that only direction counts.
Questions
- What is cosine similarity?
- The dot product of two vectors divided by both their lengths. It measures direction only, from -1 (opposite) to 1 (the same).
- Where is cosine similarity used in AI?
- One number that says how much two vectors point the same way. It is the most used calculation in all of AI.
- What is the key idea to remember about cosine similarity?
- <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">a</mi><mo>⋅</mo><mi mathvariant="bold">b</mi></mrow><annotation encoding="application/x-tex">mathbf{a} cdot mathbf{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="katex-base"><span class="katex-strut" style="height:0.4445em;"></span><span class="mord mathbf">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="katex-base"><span class="katex-strut" style="height:0.6944em;"></span><span class="mord mathbf">b</span></span></span></span> multiplies matching entries and adds them up, giving one number.
- Where can I learn cosine similarity step by step?
- In the lesson “The dot product” in Gradient’s course on the maths behind AI, with interactive diagrams and questions.