Lesson 1 · Day 8 · Embeddings

What is an embedding?

One idea, one win: text becomes a point you can measure distance on.

The idea

An embedding is a function that turns any piece of text into a fixed-length list of numbers — a coordinate in a high-dimensional space.

embed("renew your passport")  →  [0.12, -0.43, 0.88, …]   (384 numbers)
embed("documents for going abroad") →  [0.10, -0.40, 0.85, …]

The lists look random, but texts with similar meaning end up with similar coordinates. "Nearby in space" becomes "similar in meaning." That is the whole foundation of semantic search and RAG.

You do not read the individual numbers. Their meaning lives in the geometry — distances and angles between vectors, not the values themselves.

Why this matters for the mission

The ai-smart-gmail library retrieves emails by meaning. That retrieval is embedding the query, then ranking emails by how close their embeddings are. No embeddings → no semantic search → no RAG.

Check your understanding

Two texts have very similar embeddings. What does that mean?
A "lexical" embedder matches on shared words; a "semantic" embedder matches on…?

Try it

Run the Day 8 demo and watch the ranking:

cd day8
bun install
bun start

Find a query with zero word overlap with its top result. That gap is the proof embeddings capture meaning, not keywords.


Primary source: read the OpenAI Embeddings guide (10 min) — clearest intro to what embeddings are and how to search with them.

See also the embeddings reference and Sentence Transformers docs.

Stuck or curious? Ask your agent-teacher a follow-up question — about dimensions, models, or how this powers the email library. That is what it is here for.