DevTools Logo

On-Device Embedding Playground

On-Device Embedding Playground

Turn text into deterministic local vectors, then inspect similarity, clusters, query ranking and exports.

Runs in your browser

This tool uses a deterministic lexical feature-hashing embedder in your browser. It is not MiniLM or an OpenAI model: nothing is downloaded, nothing is uploaded, and vectors are reproducible on the same input.

Try an example

Texts to embed

6 lines · 236 chars
6 texts · 128 dims

Vector views

Generate vectors to begin

Paste texts and click Generate vectors — there is no model download.

Paste texts one per line or as a JSON array and generate L2-normalised vectors entirely in your browser tab. This playground uses a deterministic lexical feature-hashing embedder combining word and character-trigram features — not a transformer — so it downloads no model, needs no API key and produces byte-identical vectors for identical input. Explore an N×N cosine matrix with a threshold pair list, k-means++ clusters with a deterministic seed, a 2D projection table and a live query ranking. Export the vectors as JSON or CSV, re-import your own JSON export, and download the similarity matrix as Markdown. Empty or non-string entries are filtered; input is capped at 256 texts. No text is uploaded or persisted.

  • Topic clusters: The cosine matrix shows the animal sentences grouping together and the finance sentences grouping separately.
  • JSON array input: Paste a JSON array to import a list of texts in one shot; non-string entries are ignored with a notice.
  • Query ranking: The query is embedded with the same deterministic function and ranked by cosine against every text.

Examples

Topic separation

Input
cats chase mice / dogs chase cats / invoice payment overdue
Output
Animal sentences score higher with each other than with the invoice sentence

Shared words and trigrams dominate the cosine scores, which is exactly the lexical behaviour of this embedder.

Duplicate detection

Input
same sentence pasted twice
Output
cosine = 1.00 for the pair

Identical texts map to identical vectors — a useful sanity check before a larger run.

Round trip

Input
Download embeddings.json → paste into Import
Output
The vectors reload without re-embedding

Useful for offline demos where the original texts are no longer at hand.

About this tool

The On-Device Embedding Playground turns pasted text into vectors without an API, an account or a model download. Its deterministic lexical feature-hashing embedder combines word and character-trigram evidence into an L2-normalised vector, so identical input produces identical vectors on every run.

Once vectors exist you can inspect them four ways: an N×N cosine heatmap table with a threshold pair list, k-means++ clusters with a seeded initialisation and empty-cluster reseeding, a 2D projection table, and a live query ranking. Each view has a text table alternative rather than relying on color or canvas pixels.

This is deliberately not a neural MiniLM or OpenAI embedding: there is no model asset, no WASM runtime and no network request. The trade-off is honest — lexical similarity follows shared vocabulary and character patterns, not deep semantics. Your texts stay in the tab; exports are user-initiated.

What this tool does not do

  • No transformer model, no semantic embeddings and no multilingual guarantee.
  • Similarity reflects shared lexical features, not learned meaning.
  • The projection uses two fixed hash axes rather than PCA eigenvectors.
  • Long texts are embedded in full; there is no 512-token truncation model behind it.

How to use this tool

  1. Add texts

    Paste one text per line or a JSON array of strings; blank and non-string entries are filtered and the list is capped at 256.

  2. Choose dimensions

    Pick 64, 128 or 256 buckets, then click Generate vectors. More buckets reduce collisions at a small memory cost.

  3. Explore

    Switch between Similarity, Clusters, Query and Export; adjust the threshold or cluster count without re-embedding.

  4. Export

    Download vectors as JSON or CSV, the matrix as Markdown, or re-import your own JSON export to skip recomputation.

Use cases

Semantic-search prototyping

Build a tiny corpus and check whether ranking surfaces the expected text before wiring an API.

Teaching embeddings

Show how vector direction, normalisation and clustering behave with no opaque model in the loop.

Privacy-sensitive evaluation

Experiment with text that must never leave the browser tab.

What the views show

ViewMeaning
SimilarityCosine dot product of two unit vectors; 1 means identical direction
Threshold pairsAll pairs with cosine ≥ the chosen threshold, highest first
Clustersk-means++ with deterministic seed and empty-cluster reseeding
ProjectionTwo fixed hash axes, shown as numbers alongside each text
QueryA new text embedded with the same function, ranked by cosine

Vectors are lexical feature hashes, comparable within one dimension setting — not across embeddings from different models.

Common mistakes

Mistake:Expecting OpenAI or MiniLM quality.

Fix:This is a lexical hash embedder; paraphrases with no shared words will not be close.

Mistake:Comparing cosine scores across dimensions.

Fix:Keep dimension fixed within a comparison; re-embed everything after changing it.

Mistake:Reading the 2D projection as PCA.

Fix:It is a deterministic two-axis view of the hash vector, meant for quick orientation only.

Mistake:Pasting more than 256 texts.

Fix:The tool caps the list with a notice; split the corpus into runs.

Frequently asked questions

Does this download a model?

No. The playground uses a deterministic lexical feature-hashing embedder implemented in plain JavaScript, so there is no model file, no ONNX runtime and no CDN fetch. The vectors are reproducible for the same text and dimension setting. The trade-off is that similarity is lexical — paraphrases with completely different words will not score as close as they would with a transformer.

How are the vectors built?

Each text is lowercased, split into words, and reduced to word features plus character trigrams. Each feature is hashed into one of 64, 128 or 256 buckets with a deterministic sign, then the vector is L2-normalised. Because vectors have unit length, cosine similarity is simply their dot product.

Can I use my own embeddings?

Yes. Download embeddings.json from the Export view, and paste that JSON back into the import box to restore the exact texts and vectors. Imported vectors skip re-embedding; the similarity, cluster and pair views all work on them. The schema is {model, dim, texts, embeddings}.

How does clustering work?

k-means++ seeding picks initial centroids using squared-distance weighting from a fixed seed ("local"), then Lloyd iterations assign points and recompute centres. Empty clusters are reseeded to a random point. Because the RNG is seeded, the same vectors and k always give the same assignments.

Are my texts uploaded or saved?

No. Texts are processed in the browser tab and are not sent to a server or persisted. Downloading a JSON or CSV file is the only way data leaves the page, and it requires an explicit click. Imported exports are likewise held in memory only.

What happens with duplicate or empty lines?

Empty lines and non-string JSON entries are filtered with a count chip. Duplicate texts are allowed and score 1.0 against each other — a useful teaching example. Lists over 256 texts are truncated with a notice so the matrix stays manageable.

References & standards