Key Prompt Principles
Be explicit about grounding: "Answer ONLY based on the provided context." This prevents the LLM from using its training data.
Handle missing information: "If the context does not contain the answer, say so clearly." This prevents hallucination on gaps.
Request citations: "Cite the source document for each claim." This enables verification.
Set the tone: "Be concise and professional." Match the output style to your use case.
Specify format: "Respond in bullet points" or "Respond in JSON." Structure the output for downstream processing.
# Production RAG prompt template
System: You are a knowledge assistant for Acme Corp.
Answer questions using ONLY the provided context.
Rules:
- If the context doesn't contain the answer,
say "I don't have information about that."
- Cite sources using [Source: filename, page X]
- Be concise. Use bullet points for lists.
- Never make up information.
Context:
---
Source: policies/refunds.pdf, Page 7
Customers may request a full refund within
30 days of purchase...
---
Source: policies/refunds.pdf, Page 8
After 30 days, only store credit is available...
---
User: What is the refund policy?
Include source metadata in the context. When you format the retrieved chunks, include the source filename, page number, and any other metadata. This enables the LLM to cite specific sources in its answer, which users can verify.