Embedding

A list of numbers that encodes what text means, so similar meanings land close together and you can search by sense instead of spelling.

turning text into numbersthe meaning fingerprintembedingtext to vectorhow does it search by meaningvector representation of textembeddings modelcoordinates for meaning

See it

Live demo coming soon

What it is

An embedding model turns a piece of text (or an image, or audio) into a fixed-length list of floats, typically 384 to 3072 of them. The individual numbers mean nothing; distance is the whole point. 'Cancel my subscription' and 'how do I stop being billed' land next to each other with no words in common, which is what powers semantic search, clustering, deduplication, recommendations and classification.

The loop is: embed each chunk once at index time, store the vector beside the original text, then embed the incoming query with the same model and rank by cosine similarity. It is cheap. Embedding models are far smaller than chat models, so a whole knowledge base costs pocket change to encode.

Gotcha: vectors from different models, or different versions of one model, are not comparable. Swap the embedding model and you must re-embed everything, so store the model name and dimension next to the vectors. Second gotcha: similar is not relevant. Two chunks can sit close together because both are legal boilerplate, which is why serious retrieval bolts on keyword search and a reranker.

Ask AI for it

Build semantic search over my markdown docs. Chunk each file to about 500 tokens with 50 tokens of overlap on heading boundaries, embed every chunk with one named embedding model, and store the vector plus source path, heading path and raw text. At query time, embed the query with the same model, retrieve the top 20 by cosine similarity, and return the top 5 with their source paths. Persist the model name and dimension count alongside the vectors so changing models forces a full re-embed.

You might have meant

vector databasesemantic searchchunkingcosine similarityreranking

Go deeper