Skip to content

RAG Engineering Mastery3 / 10

Embeddings & Vector Stores 101

An embedding turns meaning into geometry. A vector store makes that geometry searchable in milliseconds. Get both right and retrieval gets easy.

Embeddings & Vector Stores 101

An embedding maps text to a point in high-dimensional space where closeness means similar meaning. Retrieval is then just "find the nearest points to this question." Everything else is plumbing.

Choosing a model

  • Quality vs. cost — bigger models embed nuance better but cost more per token and per query.
  • Dimensions — more dimensions can capture more, but cost storage and search time. Many production systems sit at 768–1536.
  • Consistency — embed your documents and your queries with the same model. Mixing models scrambles the geometry.

Where to store them

  • pgvector (Postgres) — if you already run Postgres, start here. One database, transactional, filterable by metadata with plain SQL.
  • Dedicated vector DBs — reach for them at large scale or when you need specialized index features. Don't start here for a first product.

Indexes keep it fast

Exact nearest-neighbour search is O(n) — fine at 10k vectors, painful at 10M. Approximate nearest-neighbour (ANN) indexes (HNSW, IVPFlat) trade a sliver of recall for orders-of-magnitude speed.

Vectors alone miss exact terms and rare keywords. Next: combining them with keyword search — hybrid retrieval.

Share this article

#VectorDB #RAG #AI

LinkedInX / TwitterBlueskyThreadsRedditHacker NewsWhatsAppEmail

Series — RAG Engineering Mastery

  1. Part 01Why Naive RAG Fails in ProductionThe 50-line vector-search demo that wows in a notebook falls apart the moment real users ask real questions. Here is why — and the map out.
  2. Part 02Chunking — The Decision That Sets Your CeilingYou can't retrieve what you chunked badly. Chunking is the most under-rated lever in RAG — and the cheapest to get right.
  3. Part 03Embeddings & Vector Stores 101you are hereAn embedding turns meaning into geometry. A vector store makes that geometry searchable in milliseconds. Get both right and retrieval gets easy.
  4. Part 04Hybrid Retrieval — Keyword + VectorVector search understands meaning but fumbles exact terms, IDs, and rare words. Keyword search nails those and misses paraphrase. Use both.
  5. Part 05Re-Ranking — The Cheap Quality WinRetrieval gets you 30 plausible chunks. A re-ranker reads them against the actual question and floats the truly relevant few to the top.
  6. Part 06Prompting the Generator — Grounding & CitationsGreat retrieval is wasted if the model ignores it or can't point to its sources. Grounding is a prompt-design discipline, not an afterthought.
  7. Part 07Evaluation — You Can't Improve What You Don't MeasureWithout an eval set, every RAG change is a vibe. With one, you tune chunking, retrieval and prompts with a number that tells you if you helped or hurt.
  8. Part 08Handling Hallucinations & GuardrailsWhen retrieval comes up empty, a helpful model invents. Guardrails turn 'confidently wrong' into 'honestly unsure' — the difference users actually trust.
  9. Part 09Cost & Latency DisciplineA RAG query touches embeddings, a vector DB, a re-ranker and an LLM. Each adds milliseconds and cents. At scale, discipline here is the difference between a margin and a bonfire.
  10. Part 10The Production RAG Reference ArchitectureEvery piece, assembled: ingestion, hybrid retrieval, re-ranking, grounded generation, guardrails, eval and caching — the blueprint you can ship.

Keep learning

Skill in the catalogue

database

Database development and operations workflow covering SQL, NoSQL, database design, migrations, optimization, and data engineering.

Open the skill →

Course

The Claude Mastery course

12 modules · 5 languages · certificate · 3-day free trial.

See plans →
LinkedInX / TwitterBlueskyThreads