When to use it
Use this template when you build a chatbot or internal tool that answers questions from your own documents: an HR or IT help desk, product documentation search, a policy assistant or a knowledge base for support agents. It assumes your application retrieves relevant passages (with ids) and inserts them into the prompt, which is the standard retrieval-augmented generation pattern.
How to customize it
- [ASSISTANT NAME], [ORGANIZATION] and [AUDIENCE] set the identity and the level of the answers.
- [DOCUMENT COLLECTION] tells the model, and users, what it knows about.
- [FALLBACK] is where people should go when the assistant cannot help: an email, a ticket form or a team channel.
- [N] is the word limit for answers.
- [TOPICS] lists out-of-scope subjects where the assistant should decline even if documents mention them.
- {{retrieved_passages}} is filled in by your code, in double curly braces because it is a template variable rather than something you write by hand. Give each passage a stable id and, ideally, a title and date.
Why it works
The prompt follows the structure we recommend in our guide on writing a system prompt: role, task rules, style, then safety and scope, with clear headings. Restricting answers to the supplied passages and requiring a citation per factual sentence makes every answer verifiable and reduces hallucination.
The exact “I don’t know” sentence is deliberate. A fixed phrase is easy for users to recognise and easy for your logs to count, which tells you where your documents have gaps. Handling partial answers and conflicts explicitly covers the cases where simple RAG systems fail. Tags around the documents, plus the rule to treat their content as data, make prompt injection harder, though not impossible.
Tips and variations
- Test with an evaluation set of real questions, including ones the documents cannot answer; see our guide on building an evaluation set.
- Check in code that every cited id exists in the retrieved passages.
- If answers are often “I don’t know” when the information exists, the problem is usually retrieval or chunking, not the prompt.
- Log questions that ended in “I don’t know” and use them to improve your documents.
- Keep the system prompt in version control and change one rule at a time.