Sub topic 10
Checking the Set Against Held-Out Real Questions
Assume you understand basic AI search evaluation, simple Python, and data privacy. This chapter focuses on validation: checking whether your prompt set represents real customer questions that were not used while building it.
A prompt set can look realistic and still fail in practice. It may overrepresent questions from one support channel, miss rare but important intents, or contain many slightly different versions of the same question. Held-out validation gives you evidence about those problems.
What “held-out” means
A held-out question is a real question kept separate from the data used to create, label, cluster, or sample the prompt set. You only use it for evaluation.
Split data by time, customer case, or conversation rather than copying random rows into both sets. A random split can place nearly identical questions in both sets, making coverage look better than it is.
| Dataset | Purpose | Used to write prompts? |
|---|---|---|
| Development set | Clean, label, cluster, and sample questions | Yes |
| Held-out set | Measure coverage and gaps | No |
| New monitoring set | Check future changes in demand | No |
A time-based split is often useful. For example, use January through September to build the set and October questions for validation. This tests whether the set still represents later demand.
Define validation questions and metrics
Validation should answer specific questions:
- Does the prompt set cover the intents found in real traffic?
- Does it cover important topic clusters?
- Does its frequency distribution resemble customer demand?
- Does it include rare, high-risk questions?
- Are held-out questions represented by natural prompts rather than artificial rewrites?
Useful measurements include:
- Exact coverage: the percentage of held-out questions whose normalised wording appears in the prompt set.
- Intent coverage: the percentage of held-out intent categories represented by at least one prompt.
- Cluster coverage: the percentage of held-out topic clusters represented.
- Weighted coverage: coverage weighted by question frequency or business risk.
- Gap rate: the percentage of held-out questions that have no suitable prompt match.
Exact coverage is strict. It is useful for detecting duplicates, but it does not recognise two questions with different wording and the same meaning. Add semantic review or an embedding-based similarity check when the evaluation requires meaning-level matching.
Run a reproducible baseline
The following script measures exact coverage and intent coverage. It assumes that each record has already been scrubbed and labelled.
import re
from collections import Counter
def normalise(text):
text = text.lower()
return re.sub(r"\s+", " ", text).strip()
def validate(prompt_rows, held_out_rows):
prompt_texts = {normalise(row["text"]) for row in prompt_rows}
prompt_intents = {row["intent"] for row in prompt_rows}
exact_matches = sum(
normalise(row["text"]) in prompt_texts
for row in held_out_rows
)
intent_matches = sum(
row["intent"] in prompt_intents
for row in held_out_rows
)
total = len(held_out_rows)
if total == 0:
raise ValueError("The held-out set cannot be empty")
return {
"exact_coverage": exact_matches / total,
"intent_coverage": intent_matches / total,
"unmatched_questions": [
row["text"]
for row in held_out_rows
if normalise(row["text"]) not in prompt_texts
],
}
prompts = [
{"text": "How do I cancel my subscription?", "intent": "how_to"},
{"text": "Can I change the email on my account?", "intent": "account"},
]
held_out = [
{"text": "How can I cancel my subscription?", "intent": "how_to"},
{"text": "Can I change the email on my account?", "intent": "account"},
{"text": "Do you offer refunds after renewal?", "intent": "refund"},
]
result = validate(prompts, held_out)
print(f"Exact coverage: {result['exact_coverage']:.0%}")
print(f"Intent coverage: {result['intent_coverage']:.0%}")
print("Review these gaps:")
for question in result["unmatched_questions"]:
print(f"- {question}")The first held-out question has the same intent as a prompt but different wording. Exact coverage will miss it, which is why the unmatched list needs human review. Reviewers should decide whether a prompt is a true meaning-level match, a partial match, or a genuine gap.
Inspect gaps by importance
Do not treat every missed question equally. A low-frequency question about an account lockout may matter more than dozens of minor wording variants.
Group unmatched questions by:
- intent
- topic cluster
- customer segment
- source channel
- frequency
- business or safety risk
Then decide whether to add a prompt, add a controlled variant, or leave the gap documented. Never add every unmatched question automatically. That can make the set grow without improving coverage.
Interpret results carefully
Low exact coverage does not always mean the set is poor. It may indicate natural wording variation. Low intent or cluster coverage is more serious because it shows missing concepts.
Compare results across versions using the same held-out set. Record the set version, source date, metrics, review decisions, and newly added prompts. Keep a separate future set so repeated tuning does not overfit one validation sample.
Exercise
Why should held-out questions remain separate until the original validation results are recorded?
Show answer
If they influence prompt writing first, the evaluation data becomes development data, so the measured coverage will be biased upward.