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.