Cosine Similarity Calculator

Compare vectors and text, inspect every calculation step, rank nearest matches, build similarity matrices, and export clear machine learning results instantly for practical analysis.

Calculator settings


Vector inputs

Text inputs

Batch comparison inputs

Use one vector per line. Add an optional label before |.

Similarity matrix inputs

The matrix compares every vector against every other vector.

Advanced machine learning options

Leave blank for equal weighting. Negative weights are rejected.

Interpretation thresholds

Examples and presets

Formula used

cosine similarity = (A · B) / (||A|| × ||B||)
A · B = Σ(Aᵢ × Bᵢ)
weighted cosine = Σ(wᵢAᵢBᵢ) / √Σ(wᵢAᵢ²)√Σ(wᵢBᵢ²)

How to use

  1. Select vector, text, batch, or matrix mode.
  2. Enter dense values or sparse feature pairs.
  3. Choose weighting and preprocessing options.
  4. Set precision, thresholds, and ranking limits.
  5. Calculate, inspect steps, then export results.

Example data

CaseVector AVector BExpected meaning
Identical1, 2, 31, 2, 3Similarity equals 1.
Scaled1, 2, 32, 4, 6Direction remains identical.
Orthogonal1, 00, 1Similarity equals 0.
Opposite1, 2-1, -2Similarity equals -1.

Machine learning applications

Semantic search
Compare query embeddings with indexed document embeddings.
Recommendation systems
Rank users, products, or content by directional similarity.
Natural language processing
Compare TF-IDF vectors or learned text representations.
Image retrieval
Match visual embeddings produced by neural networks.

Frequently asked questions

What does cosine similarity measure?

It measures directional agreement between two numeric vectors.

What range can the score use?

Scores range from negative one through positive one.

Why can scaled vectors score one?

Scaling changes magnitude but preserves the vector direction.

What happens with a zero vector?

Its direction is undefined, so similarity cannot calculate.

How does cosine distance work?

This calculator uses one minus the displayed similarity.

When should TF-IDF be selected?

Use TF-IDF when uncommon terms should receive more importance.

What is weighted cosine similarity?

It assigns different importance to individual vector features.

Does L2 normalisation change cosine similarity?

Usually no, but it exposes comparable normalised vector values.

How is cosine different from correlation?

Correlation centres values, while standard cosine does not.

Related Calculators

K-Means Clustering CalculatorEuclidean Distance CalculatorManhattan Distance CalculatorSilhouette Score CalculatorDavies-Bouldin Index CalculatorCalinski-Harabasz Score CalculatorCluster Centroid CalculatorWithin-Cluster Sum of Squares CalculatorElbow Method CalculatorDBSCAN Neighbourhood Calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.