Joel Stevick

Episode 5 of 8 · 15:07

Embeddings and cosine similarity

What this episode covers

An embedding model turns a text into a vector, and cosine similarity compares two of them by meaning. Inside the extractor: how the tokenizer splits text into tokens, why Firefly 220R is one token away from Firefly 220, and how a vector per token is pooled into one. The math is shown on real vectors: the angle, the projection, the dot product, and a 3D view of the corpus. The vectors go in a SQLite table, searched with a loop, with no commercial vector database, so you see what one does for you.

At the end: a search by meaning over 414 paragraphs, on your own machine, with no API key, and the two places it fails: two products one letter apart, and headings lost in the split.