

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
The most common use case for RAG is question answering, which is only slightly different from summarization.
Users ask questions, and we generate direct answers from the retrieved documents. Remember, traditional search returns documents. Users are then expected to poke through those documents to find answers on their own.
Question answering simplifies the whole process by just returning the answer.
User query: "What year was The Revenant released?"
Different questions need different approaches:
As such, you should write your system prompt so that the LLM has a sense of how to answer each type of question.
prompt = f"""Answer the following question based on the provided documents.
Question: {query}
Documents:
{context}
General instructions:
- Answer directly and concisely
- Use only information from the documents
- If the answer isn't in the documents, say "I don't have enough information"
- Cite sources when possible
Guidance on types of questions:
- Factual questions: Provide a direct answer
- Analytical questions: Compare and contrast information from the documents
- Opinion-based questions: Acknowledge subjectivity and provide a balanced view
Answer:"""
You could even include examples of good responses to the different types of questions.
Add a conversational question-answering command for direct responses.
prompt = f"""Answer the user's question based on the provided movies that are available on Webflyx, a streaming service.
Question: {question}
Documents:
{context}
Instructions:
- Answer questions directly and concisely
- Be casual and conversational
- Don't be cringe or hype-y
- Talk like a normal person would in a chat conversation
Answer:"""
Search Results:
- Jurassic Park
- Mike and Dave Need Wedding Dates
- House II: The Second Story
- The Last of the Finest
- Tokyo Babiron
Answer:
<ANSWER HERE>
If question-answering seems to be working properly, submit the CLI tests.