« Back

Embeddings and semantic search

brain/notes/embeddings-and-semantic-search.md - updated 2026-11-18
Tags: concept, embeddings, semantic-search, vectors - Similar notes

An embedding turns text into a list of numbers so a computer can find passages with similar meaning, not just matching words.

  • Hugging Face defines an embedding as "a numerical representation of a piece of information, for example, text, documents, images, audio, etc."
  • A sentence can become a vector of, for example, 384 numbers. all-MiniLM-L6-v2 produces 384-dimension vectors.
  • Semantic search: embed every document once, embed the query, score the query against each document, and return the closest.
  • The Hugging Face guide uses cosine similarity by default; dot product is another option. With normalized vectors the two rank results the same way.
  • Transformers.js can compute embeddings in the browser, as FetchMoji does.
  • Embeddings can miss exact terms such as names or codes, which is why many systems add BM25 keyword ranking and use hybrid search.

Sources