Embedding kNN Search
Rank a pasted vector corpus against a query by cosine, dot product or Euclidean distance — with tie and distribution diagnostics.
Corpus and query
3 vector(s) · 2 dims · 1 line · 95 charsNearest neighbors
3 scanned · top 31 of 3 vectors deviate from unit norm by more than 0.01 (max 0.414).
| Rank | ID | Cosine | Dot | Euclidean | Norm |
|---|---|---|---|---|---|
| 1 | a | 1.0000 | 1.0000 | 0.0000 | 1.0000 |
| 2 | c | 0.7071 | 1.0000 | 1.0000 | 1.4142 |
| 3 | b | 0.0000 | 0.0000 | 1.4142 | 1.0000 |
Score distribution (cosine)
min 0.0000 · mean 0.5690 · std 0.4198 · max 1.0000 across 3 scores.
Exact brute-force search over Float32 data. Nothing is uploaded or stored.
Examples
Find the closest chunk
{"id":"a","vector":[1,0]}
{"id":"b","vector":[0,1]}
{"id":"c","vector":[1,1]}
Query: [1,0]Cosine ranks a first (1.0), then c (0.7071), then b (0). All three scores appear side by side.
Check normalization
Vectors with norms 1.0, 1.4 and 0.99The diagnostics chip reports how many corpus vectors deviate from unit norm by more than 0.01.
Duplicate detection
[1,0]
[1,0]
[0,1]Near-identical scores are grouped into tie clusters so you can spot duplicates before indexing.
About this tool
When a RAG pipeline returns the wrong chunk, the fastest fix is usually to inspect the vectors. This tool parses a pasted corpus of embeddings — JSON objects with ids, arrays, CSV or one vector per line — and scores every row against your query using exact brute-force search. Cosine, dot product and Euclidean distance are all computed in one scan, so switching the primary metric re-ranks instantly. A top-k table shows the winner's id and all three scores; diagnostics flag duplicate or near-duplicate vectors, off-unit norms, dimension mismatches and zero queries, and a 20-bin histogram shows the score distribution across the corpus. A seeded cluster fixture is one click away for demos. Everything runs locally in Float32 typed arrays: no vector database, no upload, no persistence.
What this tool does not do
- Processes only the inputs provided in this session without connecting to external accounts or background servers.
- Runs entirely in the current browser tab; nothing is synced across devices or backed up to a server.
How to use this tool
Paste corpus vectors and query
Supply embeddings as JSON, JSONL, or CSV along with your query vector.
Pick similarity metric and k
Rank by cosine similarity, dot product, or Euclidean distance.
Inspect top-k scores and norms
Review ranked neighbors, score histogram, and normalization warnings.
Use cases
Find the closest chunk
Cosine ranks a first (1.0), then c (0.7071), then b (0). All three scores appear side by side.
Check normalization
The diagnostics chip reports how many corpus vectors deviate from unit norm by more than 0.01.
Duplicate detection
Near-identical scores are grouped into tie clusters so you can spot duplicates before indexing.
Common mistakes
Mistake:Does Euclidean distance rank the same neighbors as cosine similarity?
Fix:On unit-normalized vectors, squared Euclidean distance is strictly monotonic with cosine similarity (d² = 2 − 2·cos θ), yielding identical neighbor order; on unnormalized vectors they can diverge.
Mistake:What retrieval problems can the diagnostics panel catch?
Fix:It flags dimension mismatches between query and corpus rows, zero-norm vectors, unnormalized embeddings, duplicate tie clusters, and narrow score distributions.
Frequently asked questions
When do cosine similarity and dot-product rankings differ?
When every vector has unit L2 norm (length 1.0), cosine similarity and dot product produce identical rankings; when vector magnitudes vary, dot product favors longer vectors alongside directional alignment.
Does Euclidean distance rank the same neighbors as cosine similarity?
On unit-normalized vectors, squared Euclidean distance is strictly monotonic with cosine similarity (d² = 2 − 2·cos θ), yielding identical neighbor order; on unnormalized vectors they can diverge.
What retrieval problems can the diagnostics panel catch?
It flags dimension mismatches between query and corpus rows, zero-norm vectors, unnormalized embeddings, duplicate tie clusters, and narrow score distributions.
Are proprietary embeddings uploaded anywhere?
No. Exact Float32Array brute-force scoring runs locally in your browser tab with zero network calls.
Related tools
Agent Tool Flowchart Builder
Design agentic tool-call DAGs with decision branches and bounded loops. Validates reachability, cycle handling, and emits clean Mermaid flowcharts — fully in your browser.
AI Agent Memory & Buffer Simulator
Compare sliding window, summary buffer, and vector memory strategies
AI API Client SDK Generator
Generate typed API client SDK files from OpenAPI specifications or cURL requests
AI Code Explainer
Explain code snippets with grounded cloud AI
AI Code Security Auditor
Scan source code for high-confidence OWASP Top 10 vulnerabilities
AI Code Translator
Translate code into idiomatic implementations in another language