

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Augmented Generation
incomplete
2: LLM Summarization
incomplete
3: Conflict Resolution in Summaries
incomplete
4: Adding Citations
incomplete
5: Question Answering
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
So far, we've been solely focused on retrieving information. Now we'll explore generating results based on the retrieved information.
Retrieval-Augmented Generation (RAG) combines search with LLM generation. Instead of asking an LLM to generate answers from its training data alone, we:
This gives us (in principle) the best of both worlds:
Implement a RAG pipeline that combines search results with LLM output to produce context-aware answers.
import argparse
def main() -> None:
parser = argparse.ArgumentParser(description="Retrieval Augmented Generation CLI")
subparsers = parser.add_subparsers(dest="command", help="Available commands")
rag_parser = subparsers.add_parser(
"rag", help="Perform RAG (search + generate answer)"
)
rag_parser.add_argument("query", type=str, help="Search query for RAG")
args = parser.parse_args()
match args.command:
case "rag":
query = args.query
# do RAG stuff here
case _:
parser.print_help()
if __name__ == "__main__":
main()
prompt = f"""You are a RAG agent for Webflyx, a movie streaming service.
Your task is to provide a natural-language answer to the user's query based on documents retrieved during search.
Provide a comprehensive answer that addresses the user's query.
Query: {query}
Documents:
{docs}
Answer:"""
Search Results:
- We're Back! A Dinosaur's Story
- Jurassic Park
- The Lost World
- Carnosaur
- A Sound of Thunder
RAG Response:
<RESPONSE HERE>
If everything seems to be working, submit the CLI tests.