Back to cookbook

AI Prompt to Build a Golden Test Set for Evaluating RAG Retrieval Accuracy

0 views Published

Make this prompt yours

Share

This RAG test set prompt helps you generate a golden evaluation set for a retrieval-augmented generation pipeline, built for developers and ML engineers who need to measure retrieval quality instead of guessing from a handful of manual spot checks. You feed the model a batch of source documents, and it produces question-answer pairs tied to specific passages, along with the exact source text each answer should come from.

The prompt works by asking the model to read each document chunk and invent realistic user questions that a retrieval system should be able to answer using only that chunk, plus a few adversarial questions designed to have no good answer in the corpus. This mix lets you test both retrieval precision (does the right chunk get retrieved) and the system's ability to say "I don't know" when nothing relevant exists. Running this periodically as your knowledge base grows catches retrieval drift before users notice it.

If you're assembling this test set from a large batch of PDFs, contracts, or support docs, pulling only the relevant passages first with Context Extractor makes it easier to generate accurate, source-grounded question-answer pairs instead of working from whole documents at once.

Prompt template

Make this prompt yours

prompt-template
248 tokens
You are a test-set generator for evaluating a retrieval-augmented generation (RAG) system. CONTEXT: Source document: [DOCUMENT TEXT OR CHUNK] Domain: [DOMAIN, e.g. internal HR policy, product documentation, legal contracts] Number of questions needed: [NUMBER] TASK: 1. Read the source document carefully. 2. Generate [NUMBER] question-answer pairs that can be fully answered using only this document. 3. For each pair, include the exact sentence or passage the answer is drawn from. 4. Additionally generate [NUMBER OF ADVERSARIAL QUESTIONS] plausible-sounding questions that CANNOT be answered from this document, and label them as such. 5. Vary question phrasing: include direct factual questions, comparison questions, and questions phrased the way a real user would type them (casual, incomplete, or ambiguous). CONSTRAINTS: - Do not invent facts not present in the source document. - Do not answer questions using outside knowledge. - Flag any question where the answer requires combining multiple parts of the document. OUTPUT FORMAT: Return a numbered list. For each item include: - Question: - Expected Answer: - Source Passage: - Answerable: [Yes/No]

Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.

Example input

example-input
104 tokens
Source document: "Employees are entitled to 15 paid vacation days per calendar year, accrued monthly at a rate of 1.25 days. Unused vacation days may be carried over up to a maximum of 5 days into the following year. Carried-over days must be used by March 31st or they are forfeited. Sick leave is tracked separately and does not count toward the vacation balance." Domain: internal HR policy Number of questions needed: 3 Number of adversarial questions: 1

When to use it

  • You're launching a new RAG pipeline and have no baseline for retrieval accuracy
  • Your knowledge base has grown and you suspect older queries no longer retrieve the right chunks
  • You need a repeatable benchmark to compare two chunking or embedding strategies
  • You're debugging user complaints about wrong or missing answers from a RAG assistant

Best practices

  • Generate questions from a representative sample of documents, not just your longest or most detailed ones
  • Include a deliberate share of unanswerable questions to test refusal behavior, not just correct retrieval
  • Have a human spot-check a sample of generated Q&A pairs before trusting the set as ground truth
  • Re-run the test set after any change to chunk size, embedding model, or reranking logic

Common mistakes

  • Only testing easy, single-fact questions that don't reflect how real users phrase queries
  • Generating the test set from the same documents used to tune the retrieval system, which hides overfitting
  • Treating a one-time test set as permanent instead of refreshing it as content changes
  • Skipping unanswerable questions, so the system's hallucination rate never gets measured

FAQs

What is a golden test set in RAG?

A golden test set is a curated collection of questions paired with known-correct answers and source passages, used as a benchmark to measure whether a retrieval-augmented generation system retrieves and answers accurately over time.

How many test questions do I need to evaluate a RAG pipeline?

There's no fixed number, but most teams start with 50-100 questions covering a representative mix of document types, question styles, and at least 10-15% unanswerable questions to test refusal behavior.

Can ChatGPT or Claude generate realistic test questions from my documents?

Yes, both can generate question-answer pairs grounded in a provided document when given clear instructions and the source text, though a human should still review a sample before treating the output as ground truth.

Which Cuelara tool can help me prepare documents before building this test set?

Context Extractor — it pulls only the relevant passages from large PDFs or CSVs first, which makes it easier to generate accurate, source-grounded test questions from big document sets.

Found this prompt useful? Share it.

Share

More in RAG & Knowledge Retrieval

RAG & Knowledge Retrieval

AI Prompt to Query and Summarize Pinecone Vector Search Results via Pinecone's MCP Server

This Pinecone MCP prompt is for teams running a RAG pipeline on top of a Pinecone vector index who want an AI assistant to query that index…

ROLE:
You are a retrieval assistant that answers questions using only records returned from a Pinecone vector search via MCP.

CONTEXT:
Query: [USER_QUESTION]
Index/namespace: [PINECONE_NAMESPACE_OR_INDEX_NAME]
Top-k retrieved: [NUMBER_OF_MATCHES_RETURNED]
Retrieved matches (provided by the MCP server):
[LIST_OF_MATCHES_WITH_ID_SCORE_METADATA_AND_TEXT_SNIPPET]

INSTRUCTIONS:
1. Review each retrieved match and its similarity score.
2. Treat matches below [CONFIDENCE_THRESHOLD] similarity as low-confidence; do not state their contents as fact without flagging them as uncertain.
3. Answer the query using only information present in the retrieved matches. Do not add outside knowledge.
4. For every claim in your answer, cite the record ID or title it came from in parentheses.
5. If none of the retrieved matches answer the query, say so explicitly instead of guessing.

OUTPUT FORMAT:
Answer: [YOUR_GROUNDED_ANSWER_WITH_INLINE_CITATIONS]
Confidence note: [ANY_CAVEATS_ABOUT_LOW-SCORE_MATCHES_OR_MISSING_COVERAGE]

Make this prompt yours

RAG & Knowledge Retrieval

AI Prompt to Deduplicate Near-Duplicate Documents Before RAG Indexing

This prompt asks ChatGPT, Claude, or Gemini to design a strategy for catching near duplicate documents before they go into a RAG index, the…

You are a retrieval systems engineer designing a document deduplication stage for a RAG pipeline.

Context:
- Document sources: [LIST SOURCES, e.g. Confluence export, CMS pages, uploaded PDFs]
- Approximate corpus size: [NUMBER OF DOCUMENTS]
- Current chunking strategy: [e.g. 512-token chunks with 50-token overlap]
- Embedding model in use: [MODEL NAME]
- Known duplication pattern, if any: [e.g. same FAQ exported in two formats, revised policy versions]

Design a near-duplicate detection and resolution strategy with the following requirements:
1. Recommend a detection method (embedding cosine similarity, MinHash/shingling, or a hybrid) appropriate for the corpus size and chunking strategy above
2. Propose a specific similarity threshold or range, and explain the tradeoff of setting it higher versus lower
3. Define a tie-breaking rule for which document in a near-duplicate pair to keep
4. Specify a dry-run report format that lists candidate duplicate pairs with their similarity score before anything is removed
5. Describe how to flag pairs that are similar overall but differ in a critical detail, such as a number, date, or clause, so those are kept rather than merged
6. Explain how to log every merge or removal decision for later auditing

Output format:
- A short written plan covering points 1-3
- A sample dry-run report row format (as a table or structured record)
- A short section on the critical-detail safeguard from point 5
- A one-paragraph logging and audit approach

Make this prompt yours

RAG & Knowledge Retrieval

AI Prompt to Design a Metadata Filtering Strategy for RAG Retrieval

Metadata filtering narrows a RAG system's search space before similarity ranking even runs, using fields like document date, source, departm…

You are a retrieval systems engineer designing a metadata filtering strategy for a RAG pipeline.

Corpus description: [WHAT THE DOCUMENTS ARE, E.G. INTERNAL POLICY DOCS, PRODUCT MANUALS, SUPPORT TICKETS]
Available metadata fields: [LIST FIELDS, E.G. DOCUMENT DATE, DEPARTMENT, PRODUCT VERSION, ACCESS LEVEL]
Current retrieval problem: [DESCRIBE THE SPECIFIC FAILURE, E.G. RETURNS OUTDATED POLICY VERSIONS ALONGSIDE CURRENT ONES]
Example query that fails today: [EXAMPLE QUERY]
Query volume/pattern notes (optional): [E.G. MOST QUERIES DON'T MENTION A DATE OR VERSION]

Task:
1. Identify which available metadata fields would most directly address the retrieval problem described.
2. For each recommended field, specify whether it should be applied as a hard pre-filter or a soft ranking boost, and explain why.
3. Describe how the system should behave when a query gives no explicit signal for that field (e.g. default to most recent, ask a clarifying question, or search unfiltered).
4. Flag any field where filtering carries a real risk of excluding a relevant result due to inconsistent or missing metadata.
5. Walk through the example query that fails today and show how the proposed strategy would change the result.

Constraints:
- Only recommend filtering on fields explicitly listed as available.
- Do not recommend a hard filter without first addressing what happens to documents missing that field.

Output format: a table of recommended fields with filter type and rationale, followed by a short walkthrough of the example query.

Make this prompt yours