Retrieval-Augmented Generation (RAG) and Vector Databases

Study Retrieval-Augmented Generation (RAG) and Vector Databases with full lessons, revision notes and quick reference, across 43 lessons.

15 modules. 43 lessons. Self-paced.

Roles this course prepares you for

Course curriculum

No exam weights apply. Lessons follow practical prerequisites: vectors and exact search, approximate indexes, two vector databases, documents and chunks, measuring and improving retrieval, grounded generation and its evaluation, then security, operations and a final challenge.

Free to read: 5 lessons, no account needed

Start Here (3 lessons)
  1. Find your way around the course (read now)

    • Describe what the course builds, from embeddings to a secured RAG assistant, and how the modules depend on each other.
    • Check your starting abilities with the readiness tasks and know where each bridge topic is taught.
  2. Set up the course environment and services (read now)

    • Create ~/rag-practice with the course environment, model cache and pinned libraries, and confirm them with a check script.
    • Install Ollama with cloud features off, start Qdrant and PostgreSQL with pgvector on 127.0.0.1, and confirm each service.
    • Diagnose a wrong interpreter, a stalled download, a port already in use and a full container disk.
  3. See RAG answer a question (read now)

    • Run a complete small RAG pipeline that retrieves from the course knowledge base and answers with citations.
    • Point to the retrieval, prompt and generation stages in its printed trace, and say which later module teaches each.
How RAG Works (2 lessons)
  1. How RAG works (read now)

    • Explain the indexing and query pipelines and what each component contributes.
    • Explain why grounding reduces but does not remove wrong answers, naming the failure point at each stage.
  2. Choose when RAG is the right tool (read now)

    • Choose between RAG, plain search, a database query, a longer prompt and fine-tuning for described scenarios, with reasons.
    • Show with a run why an aggregate question needs a query rather than retrieval.

With course access: 38 lessons

Embeddings (3 lessons)
  1. Turn text into vectors

    • Compute vector length, dot product and cosine similarity by hand and with NumPy.
    • Embed sentences with a local model and inspect the dimension, data type and length of each vector.
  2. Compare similarity measures

    • Show that cosine similarity, dot product and Euclidean distance rank unit vectors identically and explain when they disagree.
    • Rank course documents for a query and explain the scores.
  3. Choose and use embedding models

    • Count tokens with a model's tokenizer and detect when an input is truncated.
    • Pass a model's query instruction correctly and compare three models by licence, dimension, input limit, speed and results.
    • Diagnose an index built with one model and queried with another.
Exact Vector Search (2 lessons)
  1. Write exact vector search

    • Embed the Python documentation once, save the vectors and their texts, and explain why embedding and indexing run in separate scripts.
    • Implement top-k search with a matrix product and argpartition, returning IDs and scores in order, and check it against a full sort.
  2. Measure the cost of exact search

    • Measure single-query and batched search time as the collection grows and report medians and 95th percentiles.
    • Explain why exact search time grows linearly and decide when exact search is good enough.
Approximate Nearest-Neighbour Search (3 lessons)
  1. Build an HNSW index

    • Explain how HNSW's layered graph finds neighbours and what M, efConstruction and efSearch control.
    • Build an inner-product HNSW index in FAISS on the D03 vectors and measure recall@10 and latency as efSearch changes.
  2. Partition and compress with IVF and PQ

    • Train IVF and IVF-PQ indexes and explain nlist, nprobe, codebooks and compression.
    • Recover recall by re-ranking candidates with the full vectors, and avoid the common construction errors.
  3. Benchmark and choose an index

    • Benchmark exact and approximate indexes on the same data: recall, single-query latency, build time and memory.
    • Choose an index and its parameters for a stated requirement, and say when exact search is good enough.
Vector Databases with Qdrant (7 lessons)
  1. Store and query vectors in Qdrant

    • Create a collection with a vector size and distance, upsert course documents with stable UUIDs and payloads, and query, scroll and count them.
    • Explain what a vector database adds to an index library.
  2. Filter with payload indexes

    • Filter queries on keyword, numeric and date payload fields with must, should and must_not.
    • Create payload indexes and check that filtered results match exact filtered search.
  3. Update, delete and persist

    • Update payloads, delete points by ID and by filter, and check the results by count and query.
    • Show that the collection survives a container restart and explain what the named volume stores.
  4. Tune HNSW and quantisation

    • Load the D03 vectors into Qdrant, wait for indexing, and measure recall and latency for different hnsw_ef values against exact search.
    • Apply scalar quantisation, compare recall with and without rescoring, and compare memory.
  5. Snapshots, restores and aliases

    • Create, list and download a collection snapshot and restore it into a new collection, checking counts and results.
    • Switch an alias between two collections atomically while queries continue.
  6. Design for multiple tenants

    • Compare one collection partitioned by a tenant field with separate collections per tenant.
    • Implement the shared-collection design with an is_tenant index and test that tenants never see each other's points.
  7. Secure the Qdrant server

    • Run a second Qdrant container with admin and read-only API keys from environment variables and show rejected requests.
    • Explain what local binding, keys, TLS and network placement each protect against.
Vector Search in PostgreSQL (2 lessons)
  1. Search vectors in PostgreSQL

    • Store the D03 vectors in a vector column, query with the distance operators and build an HNSW index that EXPLAIN shows in use.
    • Combine vector search with SQL filters, see a filtered query return too few rows, and fix it with iterative index scans.
    • Use a transaction and show a rolled-back insert is never visible.
  2. Choose a vector database

    • Compare a dedicated vector database, PostgreSQL with pgvector, an embedded library and a managed service on the properties that matter.
    • Choose for described scenarios with stated reasons and the evidence that would change the choice.
From Documents to Chunks (3 lessons)
  1. Load and clean documents

    • Load the course's Markdown, HTML and plain-text documents into records with text, headings and metadata.
    • Remove navigation and markup without losing headings, and check every record.
  2. Split documents into chunks

    • Split records by fixed token size with overlap, by sentence and paragraph boundaries, and by heading structure.
    • Keep every chunk under the embedding model's limit and traceable to its document and position.
  3. Keep IDs stable and re-index

    • Derive chunk IDs from document IDs and positions and detect changed documents with SHA-256 hashes.
    • Re-index added, changed and deleted documents without duplicates or stale chunks, checked by counts and queries.
Measuring Retrieval (3 lessons)
  1. Build a retrieval test set

    • Read and correct labelled questions with graded relevance, including unanswerable, negative, multi-document and version-sensitive questions.
    • Keep development and test questions separate and explain why.
  2. Measure retrieval quality

    • Compute recall@k, mean reciprocal rank and nDCG and check them against hand calculations.
    • Compare configurations on the development questions and explain individual failures from the retrieved chunks.
  3. Compare chunking strategies

    • Compare chunking strategies and sizes on the development questions with the course metrics.
    • Choose one from the evidence and its cost, then confirm it once on the test questions.
Better Retrieval (3 lessons)
  1. Add keyword search with BM25

    • Implement BM25 for the course chunks and check one query's scores by hand.
    • Use Qdrant's server-side BM25 and compare keyword and dense retrieval on identifiers and paraphrases.
  2. Fuse results and filter

    • Fuse dense and keyword results with reciprocal rank fusion, by hand and with Qdrant's prefetch and rrf.
    • Add access, site and recency filters and measure the effect.
  3. Rerank with a cross-encoder

    • Rerank the top candidates with a cross-encoder and measure the change in quality and the added latency.
    • Choose how many candidates to rerank and check scores for NaN before trusting them.
Grounded Generation (3 lessons)
  1. Call a local model through Ollama

    • Send chat requests with explicit options and read the counts, timings and done_reason in the reply.
    • Stream a reply, handle errors and timeouts, and check the model's context length.
  2. Write grounded prompts with citations

    • Build a prompt that separates instructions from sources, labels each source with its ID and asks for citations and an exact refusal sentence.
    • Check citations in code and compare prompt variants on the development questions, including the over-refusal of 'no' answers.
  3. Fit the context budget

    • Estimate and measure prompt tokens, set num_ctx deliberately and choose how many chunks to include and in what order.
    • Detect silent truncation from prompt_eval_count.
Evaluating Answers (3 lessons)
  1. Check answers and citations

    • Score answers with code for citation validity, relevant citations, abstention, required facts and citations of outdated documents.
    • Separate retrieval failures from generation failures in a report.
  2. Grade answers with a model

    • Ask the course model to judge whether a source supports a claim, with a JSON schema in Ollama's format field.
    • Label the same cases yourself and measure agreement before relying on the grader.
  3. Build a regression suite

    • Turn retrieval and answer checks into a pytest suite with parametrised cases and thresholds.
    • Show the suite failing for a deliberately broken change and passing after the fix.
Security and Privacy (3 lessons)
  1. Enforce document permissions

    • Derive the retrieval filter from the caller's identity so restricted documents never reach the model.
    • Test permissions for every role and question, and find a leak in a supplied pipeline.
  2. Defend against prompt injection

    • Recognise instructions planted in retrieved documents and test the course model against them.
    • Apply and measure mitigations, and state the remaining risk.
  3. Protect and delete data

    • Check documents for secrets and personal data before indexing.
    • Delete a document completely from the collection, snapshots, caches and logs, and verify each store.
Operating a RAG System (2 lessons)
  1. Measure, trace and cache

    • Measure latency per stage and log a trace of each request's retrieved IDs, scores and prompt size.
    • Cache embeddings and answers safely and use a trace to explain a wrong answer.
  2. Change the embedding model without downtime

    • Re-index into a new collection with a new embedding model and compare it on the test questions.
    • Switch an alias while queries continue, and roll back.
Final Challenge (1 lessons)
  1. Final challenge: a secured RAG assistant

    • Build a RAG assistant for a supplied document set that meets stated retrieval, grounding, abstention, permission, injection and update checks.
    • Justify the design in a short report with evidence from your own runs.

Study views

  • Full Course
  • Revision
  • Quick Reference

Unlock all 43 lessons

Course access opens every lesson and adds revision notes, the Quick Reference, saved progress, bookmarks and your own notes.

INR 199 plus 18% GST. 90 days of online access. No auto-renewal.

Know what is included

Independent learning material from Vectametric. Not affiliated with or endorsed by the organisations behind the tools it teaches. Practice exams and projects are separate. Completing a course is not a professional certification.

Questions about courses

Are these video courses or reading courses?

The current courses use written lessons, examples and diagrams. Full Course, Revision and Cheat Sheet or Quick Reference views cover the same learning sequence at different levels of detail.

Which course should I start with?

Choose a Certification Course for a named exam, a Career Path Course for a role-led sequence, or a Skill Course for a focused subject. Read its level, prerequisites and curriculum before enrolling.

Do revision notes replace the full lessons?

No. Start with the full explanations, then use revision notes to refresh your understanding. Cheat sheets are concise study references, not a substitute for learning or permission to use notes during an official exam.

Are practice exams and projects included?

No. Course access, practice-exam bundles and project access are separate. An official certification, exam booking or voucher is not included.

How long do I have access?

The course page and checkout show the current online access period and price, including free enrollment where offered. Access starts when enrollment is confirmed and does not auto-renew.

Can I read lessons before enrolling?

Yes. Each course opens its first lessons to read without an account, and some courses are open in full. The course curriculum marks the lessons you can read now. Course access adds the remaining lessons, the Revision and Cheat Sheet or Quick Reference views, saved progress, bookmarks and personal notes.

Review the Terms and No-Refund Policy before confirming access. All sales are final; Vectametric does not offer refunds.

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy