The retrieve-then-generate loop
You have a search engine and a model. Joining them takes about 30 lines of code, and those 30 lines decide whether users get grounded answers with sources or confident blends of half-relevant paragraphs. How many chunks, in what order, with what instructions, and how does the answer point back to where each fact came from?
In this lesson you'll learn to
- Build a RAG prompt that marks each retrieved chunk with an ID and source and tells the model to answer only from them.
- Get answers with citations that point to specific chunks, and show those sources to the user.
- Make the model say it doesn't know when the sources don't contain the answer.
- Choose how many chunks to include and in what order, using what's known about how models use long prompts.
Create a free account to open this lesson
It's free. You'll get every free lesson, quizzes that save your progress, daily flashcards and streaks.