AI Hints
Home›Generative AI Tutorial›Search by Meaning and RAG
Generative AI · Lesson 37 of 77

Making RAG Work

Common problems and fixes.

⏱ 2 min read▶ Video at 1:25:43🎓 Free
Watch this lesson in the Generative AI courseWatch on YouTube ↗Full Generative AI course

A first R A G system is easy to build, and easy to get wrong. Sometimes it finds the wrong chunks. Sometimes it ignores the right ones. In this lesson, you will learn the most common problems, and the practical fixes professionals use.

Making RAG Work
From the video: Making RAG Work
  • Easy to build, easy to get wrong
  • Common failures
  • Practical fixes

Common problems and fixes

Here are the classic problems. If the right chunk is never found, improve the chunking, or try a better embedding model. If too many irrelevant chunks arrive, retrieve fewer, or add a re ranking step, that sorts them again. If the model ignores the sources, make the instruction firmer, answer only from the context. And if the answer is not in the documents, tell the model to say, I could not find that.

ProblemTypical fix
Right chunk not foundbetter chunking or embeddings
Too many irrelevant chunksretrieve fewer, add re-ranking
Model ignores the sourcesfirmer instruction in the prompt
Answer not in the documentsallow: I could not find that

Better retrieval tricks

Several tricks improve retrieval. Hybrid search, combines keyword matching, with semantic search, so exact names and codes are not missed. Re ranking, uses a second model, to sort the top results. Query rewriting, asks the model to clarify a vague question first. And metadata filters, narrow the search, for example, only documents from this year.

Hybrid searchkeywords plus meaning
Re-rankinga second model sorts the top results
Query rewritingclarify vague questions
Metadata filtersnarrow by date, type or author

Measuring a RAG system

As always, measure. Check retrieval, did the right chunk appear in the top results? Check faithfulness, is the answer supported by those chunks? And check usefulness, does it really answer the question? Build a test set of real questions, run it after every change, and watch the scores. That is how a prototype becomes a trustworthy product.

Retrieval qualitywas the right chunk found?
Faithfulnessis the answer supported by the sources?
Usefulnessdoes it really answer the question?
A test setrerun after every change

Summary

Well done. You know the common R A G problems, and the fixes, better chunks, re ranking, hybrid search, query rewriting, and firm instructions. And you know to measure retrieval, faithfulness, and usefulness. Next, we give models the power to act, with tools, and agents.

Key takeaways
  • Fix retrieval first: chunks, hybrid, re-rank
  • Firm instructions, allow 'not found'
  • Measure retrieval, faithfulness, usefulness
Next up: Tool Use — letting the model take action