Phase 11: LLM Engineering

Embeddings & Vector Representations

Text is discrete. Math is continuous. Every time you ask an LLM to find "similar" documents, compare meanings, or search beyond keywords, you're relying on a bridge between these two worlds. That bridge is an embedding. If you don't understand embeddings, you don't understand modern AI. You just use it. Related: Phase 5 · 22 (Embedding Models Deep Dive) covers dense vs sparse vs multi-vector, Matryoshka truncation, and per-axis model selection. This lesson focuses on the production pipeline (vector DBs, HNSW, similarity math). Read Phase 5 · 22 before picking a model. Generate text embeddings using API providers and open-source models, and compute cosine similarity between them. Explain why embeddings solve the vocabulary mismatch problem that keyword search cannot handle. Build a semantic search index that retrieves documents by meaning rather than exact keyword match. Evaluate embedding quality using retrieval benchmarks (precision@k, recall) and choose the right embedding model for your task. You have 10,000 support tickets. A customer writes "my payment didn't go through." You need to find similar past tickets. Keyword search finds tickets containing "payment" and "didn't go through." It misses "transaction failed," "charge was declined," and "billing error." These tickets describe the exact same problem with completely different words. This is the vocabulary mismatch problem. Human language has dozens of ways to say the same thing.…

Embeddings & Vector Representations: Text is discrete. Math is continuous. Every time you ask an LLM to find "similar" documents, compare meanings, or search…

This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.

Browse the complete course catalog or open this lesson on GitHub.