13. Embeddings, Vector Search and RAG
Connect NLP representation learning to enterprise LLM systems.
01 Learning objectives
By the end of this module, you should be able to explain the concept in plain language, connect it to a use case, and recognize when it is — and is not — appropriate.
-
Objective 1
Understand chunking, embedding, indexing and retrieval.
-
Objective 2
Understand how retrieved evidence enters an LLM prompt.
-
Objective 3
Recognize RAG failure modes.
02 RAG pipeline
documents → parse → chunk → embed → vector index
At inference:
question → embed → retrieve top-k chunks → construct prompt → LLM → answer
03 Why RAG?
RAG lets an LLM answer using organization-specific or frequently changing knowledge without putting every fact into model weights.
04 Minimal pseudocode
query_vec = embed(question)
chunks = vector_store.similarity_search(query_vec, k=5)
prompt = build_prompt(
question=question,
context=chunks
)
answer = llm.generate(prompt)
05 Pitfalls and nuances
These are the mistakes most likely to create a wrong mental model or a weak implementation.
-
Pitfall 1
Bad chunking causing relevant facts to be split apart.
-
Pitfall 2
Retrieving semantically similar but policy-incorrect content.
-
Pitfall 3
No metadata filtering for business line, date, jurisdiction or document version.
-
Pitfall 4
Treating citations as proof when retrieval itself was wrong.
06 Checkpoint questions
Try answering these without looking back at the module. If the explanation is clear in your own words, you are ready to continue.
-
Check 1
Why is retrieval quality as important as generation quality?
-
Check 2
When would metadata filters be essential?