📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Prompt Engineering RAG Prompting Patterns

RAG Prompting Patterns

6 min read Quiz at the end
RAG prompt templates inject retrieved context — design prompts that ground answers and cite sources clearly.

RAG Prompting Patterns

RAG injects retrieved documents into prompts — the prompt template design determines accuracy and groundedness.

# Core RAG prompt template
SYSTEM:
You are a helpful assistant. Answer questions using ONLY
the provided context. If the answer is not in the context,
say 'I do not have information about that in my knowledge base.'
Never use prior knowledge or make up information.

USER:
Context:
--- Source: docker-guide.md ---
{retrieved_chunk_1}
--- Source: k8s-tutorial.md ---
{retrieved_chunk_2}
---

Question: {user_question}

# Citation pattern
Answer the question and after each claim cite the source.
Format: claim [Source: filename, section]

# Multi-hop RAG (complex questions)
Step 1: Identify sub-questions needed to answer the main question.
Step 2: For each sub-question, find the relevant context passage.
Step 3: Synthesise a final answer combining all findings.
Step 4: Cite all sources used.
Topic Quiz · 2 questions

Test your understanding before moving on

1. What does RAG stand for?
💡 RAG stands for Retrieval-Augmented Generation — inject retrieved documents into the LLM prompt context.
2. What instruction prevents an LLM from using prior knowledge in RAG?
💡 Explicitly instructing the model to answer ONLY from context prevents hallucinations from prior training data.