Cover of Embeddings and Vector Search
From Keyword to Code

Embeddings and Vector Search

How Machines Find Meaning — From First Embedding to Working Semantic Search

Discover how embeddings represent meaning and make semantic search possible. Follow the path from a first embedding to a working search system, connecting the underlying ideas with practical development.

View on Amazon ↗

Opens Amazon in a new tab. Check the listing for formats and availability.

A closer look

About this book.

Everyone building with AI eventually hits the same wall: keyword search doesn't understand what your users mean, and "just use embeddings" is not actually an instruction. This book is the instruction.

Embeddings and Vector Search takes you from "what is a vector, actually" to a working, measured, hybrid search system over your own documents — built chunk by chunk, chapter by chapter, with real Python you run yourself, not slides.

You'll learn what an embedding actually represents geometrically, why cosine similarity is the default distance metric (and when it isn't), and how chunking strategy quietly decides whether your search works at all. Then you'll build: an indexing pipeline, a query path, a from-scratch BM25 keyword index, and a reciprocal-rank-fusion hybrid search that beats either method alone — all compared honestly against plain keyword search, with real numbers, not marketing claims.

Because a demo that works once isn't the same as a system you can trust, this book also teaches you to measure precision and recall properly, debug bad retrieval systematically instead of guessing, and understand exactly what embeddings cost in dollars, storage, and latency as your corpus grows. By the end, you'll wrap your search system in a real FastAPI service — with caching, a health check, and honest limitations named out loud — and you'll be able to explain every decision you made in an interview, because you'll actually understand why you made it.

No invented benchmark numbers. No hand-waving past the parts that are hard. Every claim in this book is either measured live or clearly labeled as general guidance — and where the book doesn't know something, it says so and shows you how to find out yourself.

Written for developers who can already code but have never built on embeddings before. Python 3.11, OpenAI's embedding API (with a fully offline local-model alternative), and NumPy — no vector database required, because you don't need one yet.

Book 3 in the From Keyword to Code series — the AI engineering books that show their work.

Beyond the book

Reader resources.

Download chapter code (ZIP)

Includes a README with setup notes and a chapter-by-chapter file index.

Official documentation and guides for topics covered in this book.

← Back to the books