Cosine Similarity Calculator
Compare vectors or embeddings: cosine similarity, angle, dot product and distance.
Questions
What does cosine similarity measure?
The angle between two vectors, ignoring their length. 1 means they point the same way, 0 means they are unrelated (at right angles), and -1 means opposite.
Why is it used for embeddings?
An embedding model turns text into a vector, and similar meanings point in similar directions. Cosine similarity compares direction only, so a long text and a short one on the same topic still score high.
What input formats work?
One vector per line, with numbers separated by commas or spaces. Brackets from JSON are fine, and so is a label before a colon, like "cat: 0.1, 0.2". A whole JSON array of arrays on one line also works.
Cosine similarity or Euclidean distance?
For normalised embeddings (length 1), they rank results the same way. For other vectors, Euclidean distance also counts length, so use cosine when only direction should matter.
Can it make embeddings from text?
No. There is no model on this page. Paste vectors you already have, from any embedding model.
Related tools
- Softmax & Cross-Entropy CalculatorTurn scores into probabilities, and see the loss and perplexity for the right answer.
- Positional Encoding VisualizerThe sine and cosine pattern a transformer adds to each position, as numbers and a heatmap.
- Attention CalculatorScaled dot-product attention step by step: scores, softmax weights and output.
- Token CounterCount tokens and see how text is split, with the real GPT-4o and GPT-4 tokenizers.