Vector Similarity Calculator
Compute cosine similarity, Euclidean distance and dot product between two vectors, or rank a batch of candidate vectors against a query vector to simulate retrieval - useful for debugging embedding and RAG results.
FreeOnline Tool
Loading…
How to Use
- Switch between the "Compare two vectors" and "Batch retrieval simulation" tabs.
- In two-vector mode, paste a JSON array vector into each box (for example [0.12, -0.34, 0.56]) and press "Calculate" to see cosine similarity, Euclidean distance and dot product.
- In batch mode, paste the query vector first, then put one candidate vector per line in the candidates box (use "label: [array]" to name a candidate, or omit the label to have them numbered automatically) and press "Calculate and rank" to sort by cosine similarity from high to low.
- Press "Load sample vectors" or "Load sample data" for a quick trial.
- If the two vectors have different dimensions the tool warns you and only computes what it can - the dot product is truncated to the shorter length, while cosine similarity and Euclidean distance are left blank.
Features
- Accepts vectors of any dimension in JSON array form, mirroring embedding model output.
- Computes cosine similarity, Euclidean distance and dot product together in one pass.
- Batch retrieval simulation: one query vector against many candidates, ranked by descending similarity, showing the retrieval/RAG recall order at a glance.
- Mismatched dimensions and other malformed input are detected and clearly reported rather than failing silently.
- Everything is computed locally; no data is uploaded.
Use Cases
Debugging RAG retrieval
Paste a query vector and several document vectors to see whether the recall ranking matches expectations when tracking down retrieval quality issues.
Comparing embedding models
Embed the same pair of texts with different models and compare the cosine similarities to decide which model suits your use case.
Vector database sanity checks
With no live vector database at hand, verify that your similarity logic and ranking behave as expected.
Teaching vector metrics
Help newcomers see concretely how cosine similarity, Euclidean distance and dot product differ.
FAQ
How many dimensions can a vector have?
There is no built-in limit as long as the input is a valid JSON array of numbers. In practice you are bound by browser performance, and anything up to a few thousand dimensions calculates smoothly.
What if the two vectors have different dimensions?
The tool detects the mismatch and tells you. Cosine similarity and Euclidean distance cannot be computed and are left blank, while the dot product is calculated over the shorter vector's length and should be treated as indicative only.
What format do candidate vectors use in batch mode?
One candidate per line. You can write "label: [0.1, 0.2, ...]" and the text before the colon becomes the display ID, or simply write "[0.1, 0.2, ...]" and the tool numbers them candidate 1, candidate 2 and so on.
Is my data uploaded to a server?
No. All vector maths runs locally in your browser and no vector data is uploaded or stored.