Duration: 45 minutes
Introduction
Question-answering is one of the most practical applications of LLMs—from customer support chatbots to educational tutors. But getting accurate, reliable answers requires more than just asking questions. In this lesson, you’ll learn patterns that ensure your QA systems provide well-reasoned, verifiable answers.The QA Challenge
The solution? Structured reasoning patterns that make the thinking process explicit.Basic QA Patterns
Open-Domain QA
Answer questions without provided context.Best for: Factual questions with well-established answers. Use with caution for questions requiring current information or specialized knowledge.
QA with Context
Provide relevant context to ground the answer.QA with Source Citation
Request answers with references to the source material.Multiple-Choice Questions
Basic Multiple Choice
Multiple Choice with Reasoning
Request explanation along with the answer.Math Word Problems
Structured Math Problem Solving
Use the GSM8K annotation style for clarity.GSM8K Format:
- Use «calculation» for intermediate steps
- Show #### before the final numerical answer
- This format helps track reasoning and catch errors
Multi-Step Math Problems
Break complex problems into clear steps.Complex QA with Sub-Questions
Decomposition Strategy
Break complex questions into manageable parts.Comparative Questions
Answer questions requiring comparison or analysis.Handling Uncertainty
Admitting Unknown Information
Best Practice: Always admit when information isn’t available rather than guessing or hallucinating.
Qualified Answers
Provide answers with appropriate caveats.Structured Reasoning Format
Chain of Reasoning
Make the thinking process explicit.Verification Step
Include a verification or sanity check.Best Practices
Provide Context
Always include relevant context when available
Show Reasoning
Make the thinking process explicit and verifiable
Admit Uncertainty
Acknowledge when information is insufficient
Verify Answers
Include sanity checks for numerical or logical answers
Practice Exercises
Exercise 1: Context-Based QA
Create a QA system that answers questions based only on provided context.Sample Solution
Sample Solution
Exercise 2: Math Problem Solver
Design a prompt for solving word problems with clear reasoning.Sample Solution
Sample Solution
Exercise 3: Multi-Part Question Handler
Create a system for handling complex questions with multiple components.Sample Solution
Sample Solution
Real-World Application: Customer Support QA System
Build a comprehensive customer support QA system:Key Takeaways
Always provide context when available to ground answers
Use structured reasoning formats for complex questions
Show step-by-step calculations for math problems
Admit when information is insufficient or uncertain
Include verification steps for numerical answers
Break complex questions into manageable sub-questions
Module 2 Complete!
Congratulations! You’ve mastered task-specific prompting patterns for classification, extraction, generation, transformation, and question-answering. You’re now ready to tackle the Module 2 assessment.Next: Module 2 Assessment
Test your skills with the Content Moderation System capstone project