Lesson 6: The Augmentation Step
Where Retrieval Meets Prompting
You’ve retrieved relevant chunks from your knowledge base. Now comes a step that’s easy to overlook but crucial to get right: augmentation. Augmentation is where retrieval meets prompting. You’re taking the user’s question, adding the retrieved context, and crafting a prompt that helps the AI generate a useful, grounded response. If you’ve worked through the prompt engineering curriculum, you already know that how you phrase things matters enormously. The augmentation step is where those skills become essential for RAG.Core Concepts
The Anatomy of an Augmented Prompt
A basic augmented prompt has three components: 1. Instructions: Tell the AI how to behave and use the provided context. 2. Retrieved Context: The chunks retrieved from your knowledge base. 3. User Question: What the user actually asked. Here’s what a simple template might look like:Instruction Design: Setting the Rules
The instruction section is where you establish how the AI should handle the task. Common elements include: Role setting: “You are a customer support agent for Acme Corp.” Context usage guidance: “Base your answer on the provided context. Do not use information from outside the context.” Handling uncertainty: “If the context doesn’t contain enough information, say ‘I don’t have enough information to answer that fully.’” Tone and format: “Answer in a friendly, professional tone. Use bullet points for lists.” Constraints: “Do not make up information. Do not speculate beyond what the context supports.” These instructions shape everything that follows. Without them, the AI might hallucinate, ignore the context, or respond in ways that don’t fit your use case.Presenting Retrieved Context
How you present the retrieved chunks affects how well the AI uses them. Several approaches work: Simple concatenation: Just join all chunks with line breaks. Simple but can be messy.Managing Context Length
Here’s a practical constraint: AI models have limited context windows. Every token in your prompt (instructions, context, question, AND the response) counts against that limit. This creates trade-offs: More context = More information for the AI to work with, but:- Higher cost (most APIs charge by token)
- Risk of hitting context limits
- Possible dilution of focus (too much noise)
- Might miss relevant information
- Less comprehensive answers
Instructing the AI on Context Usage
A critical aspect of augmentation is telling the AI how to use (and not misuse) the context. Without clear instructions, you might encounter: Ignoring context: The AI answers from general knowledge instead of the provided information. Overclaiming: The AI states things definitively that the context only implies or doesn’t support. Mixing context with hallucination: The AI starts with real information but adds fabricated details. Effective instructions address these risks:Handling Multiple Chunks
When you retrieve multiple chunks, they might: Overlap: Say the same thing in different words Complement: Each provides different pieces of the answer Conflict: Provide contradictory information Your prompt template should help the AI navigate these situations:Question Reformulation
Sometimes the user’s question could be improved before being sent to the AI. Common enhancements: Adding specificity: If the user asks “What’s the policy?”, but you know from context they’re looking at the refund page, you might expand to “What’s the refund policy?” Removing ambiguity: Clarifying pronouns or vague references based on conversation history. Decomposing complex questions: Breaking “What’s the price and how do I sign up?” into sub-questions that can be addressed separately. This is more advanced, but it can significantly improve response quality.Try It Yourself
Exercise 1: Write a Prompt Template
Design a prompt template for a RAG system that answers questions about a company’s product documentation. Include:- A role/persona for the AI
- Clear instructions on how to use the context
- Guidance on what to do when information is missing
- Placeholders for retrieved context and user question
Exercise 2: Compare Template Approaches
Here are two different instruction sets. For each, consider what kind of responses they would produce: Template A:Exercise 3: Handle Conflicting Context
Imagine you retrieve these two chunks: Chunk 1 (from 2022 policy): “Refunds are available within 14 days of purchase.” Chunk 2 (from 2024 policy update): “Refunds are available within 30 days of purchase.” How would you structure your prompt to help the AI handle this conflict? Write out the specific instructions you would include.Common Pitfalls
Pitfall 1: No Instructions at All
Just throwing context and a question at the AI without any guidance leads to inconsistent, unpredictable responses. The fix: Always include clear instructions. Even a few sentences make a difference.Pitfall 2: Instructions Too Vague
“Answer based on the context” is a start, but doesn’t address edge cases. What if the context is insufficient? What if it conflicts? The fix: Think through edge cases and address them explicitly in your instructions.Pitfall 3: Overloading Context
Stuffing every retrieved chunk into the prompt, regardless of relevance or length, leads to bloated prompts that dilute focus and inflate costs. The fix: Be selective. Prioritize quality over quantity in what you include.Pitfall 4: Ignoring Source Attribution
If the AI responds without indicating where information came from, users can’t verify the answer and trust erodes. The fix: Include instructions for the AI to reference sources. Use labeled chunks so the AI can cite them.Level Up
Here’s a design challenge: Scenario: You’re building a RAG system for a medical information service. Users ask health questions, and the system retrieves from peer-reviewed medical literature. Constraints:- Responses must not be interpreted as personal medical advice
- Sources must be clearly cited
- Uncertainty must be acknowledged
- Information should be accessible to non-medical users
- An appropriate role/persona
- Detailed instructions on context usage and limitations
- Specific guidance on disclaimers and uncertainty
- A format for presenting retrieved context
- Instructions for generating the response

