Compare and Rank Numeric Vectors

Paste a query vector and candidate vectors to compare their numerical similarity or distance. Choose a metric to rank the candidates; mismatched dimensions are flagged, and no embeddings are generated.

Runs locally in your browser
All vector parsing and arithmetic happen locally. The tool does not create embeddings or send vectors to an external service.
Query vector
Candidate vectors

Compare vectors without exposing embeddings

Cosine compares direction, dot product also reflects magnitude, and distance metrics rank smaller values first. Normalize vectors consistently with the embedding workflow you use in production.

How to rank vectors by cosine, distance or dot product

Paste one query vector and a set of labelled candidates and the page returns them ordered by the selected metric. Cosine similarity, dot product, Euclidean distance and Manhattan distance are computed in the tab with the values exactly as entered: nothing is normalised, no embedding model is called and no vector leaves the browser.

A ranking is only as good as the vectors themselves. Vectors produced by different models, or by the same model with different preprocessing, live in different spaces, so compare scores only when the vectors come from one consistent pipeline.

  1. Paste the query vector: numbers separated by commas, spaces or semicolons, or a JSON array such as [0.82, 0.15, -0.31, 0.44].
  2. Add the candidates, one per line: a label, then a tab (or a colon or a space) and the vector in brackets, for example “chunk A<TAB>[0.79, 0.18, -0.28, 0.48]”. A JSON array of arrays or of {label, vector} objects works as well.
  3. Pick the metric: cosine similarity and dot product rank the largest value first, Euclidean and Manhattan distance rank the shortest distance first.
  4. Press Calculate & rank. A candidate whose length differs from the query, or whose line cannot be read, is listed with the reason and left out of the ranking instead of failing the whole run.
  5. Press Clear to empty the form; the metric returns to cosine similarity.

Input forms, metric formulas and error handling

Input forms the parser accepts

A vector is a list of finite numbers. In the query box they may be separated by commas, spaces or semicolons, or written as a JSON array; decimals, signs and scientific notation (1e-3, 2E-3) are accepted, and numbers may also arrive quoted, as spreadsheet and CSV exports usually write them. null, true, false, empty entries and any other text are rejected: the page names the offending value rather than coercing it to 0 or 1.

Candidate lines are read as a label plus a vector. The separator may be a tab, a colon or a space; the vector itself is a bracketed list or, on a line without a label, a bare list of numbers. Lines without a label are numbered “Vector 1”, “Vector 2” and so on. A JSON candidate list may be an array of arrays, an array of {label, vector} objects, or a single flat array that is read as one candidate.

What each metric returns

Cosine similarity divides the dot product by both magnitudes, so it compares direction alone and ignores length: the value runs from −1 (opposite) through 0 (unrelated) to 1 (same direction). It is the usual choice for text and image embeddings. A zero vector has no direction, so its cosine is undefined and the row is shown as unavailable rather than as 0.

The dot product multiplies matching components and adds them up, so it grows both with agreement in direction and with the length of the vectors; the largest value ranks first and a negative result ranks below any positive one. Euclidean distance is the straight-line distance between the two points and Manhattan distance adds the absolute component differences — both rank the shortest distance first and both are sensitive to the scale of the numbers.

Cosine is computed on rescaled copies of the two vectors so that very large components (1e200) cannot overflow the intermediate products, and Euclidean distance is accumulated with Math.hypot so that squaring does not overflow either. A dot product that genuinely exceeds the range of a JavaScript number is reported as unavailable, with the reason on the status line, instead of being printed as Infinity.

What the page does not do

It does not create embeddings, fetch vectors from an API or search a corpus: the numbers you paste are the numbers it ranks. It also does not normalise the vectors, drop duplicate labels or reorder ties — two candidates with the same score keep their input order.

The bar on each row is scaled between the best and worst score of the current run, so it shows relative position inside one ranking and is not comparable across runs or metrics. The score column is rounded for display — extreme magnitudes switch to exponential notation — so use a numeric library in your own pipeline when you need exact arithmetic on large batches.

Recent tools: