This prompt is for search quality engineers and RAG developers who need to validate that a synonym expansion system produces correct, relevant terms before shipping to production. Use it when you have a golden set of queries with known-good expansions and you want a structured evaluation report measuring precision, recall, term drift, and regression risk. The prompt assumes you already have an expansion prompt generating candidate terms; its job is to evaluate those outputs, not generate expansions.
Prompt
Synonym Expansion Eval Check Prompt Template

When to Use This Prompt
A structured evaluation report for synonym expansion quality against a golden query set.
The ideal workflow places this eval prompt inside a CI/CD pipeline or a pre-release validation harness. You provide the candidate expansion outputs from your system under test, the golden set of expected expansions, and any domain constraints. The prompt returns a structured JSON report with per-query metrics, aggregate scores, flagged regressions, and a pass/fail recommendation. This lets you gate deployment on measurable quality thresholds rather than manual spot checks.
Do not use this prompt for real-time expansion during user queries—it is an offline evaluation tool. Do not use it when you lack a curated golden set with verified ground-truth expansions, because the eval has no reference point for correctness. Do not use it as a substitute for production observability; it measures pre-release quality, not runtime drift. For high-risk domains such as legal or medical search, always include human review of flagged regressions and edge cases before accepting a pass recommendation.
Use Case Fit
Where the Synonym Expansion Eval Check prompt delivers reliable value and where it introduces risk. Use this to decide if the prompt is the right tool before integrating it into your search quality pipeline.
Good Fit: Pre-Release Prompt Regression Testing
Use when: You are changing the system prompt, few-shot examples, or model for a synonym expansion step and need to quantify the impact before deployment. Guardrail: Run the eval against a frozen golden query set and block the release if precision or recall drops beyond a defined threshold.
Good Fit: Measuring Term Drift in Production
Use when: You need to detect semantic drift where expanded terms slowly become less relevant to the original query intent over time. Guardrail: Schedule periodic eval runs and alert on statistically significant increases in the 'unrelated term' category.
Bad Fit: Real-Time Query Guardrails
Avoid when: You need a low-latency, in-line filter to block bad expansions before they hit the retrieval index. The eval prompt is an offline analysis tool, not a production safety net. Guardrail: Use a lightweight, rule-based validator or a smaller, faster model for real-time rejection.
Required Input: A High-Quality Golden Set
Risk: The eval is only as good as the golden set of queries and their known-good expansions. A small, biased, or stale golden set will produce a misleadingly positive evaluation. Guardrail: The golden set must be curated by search relevance experts, cover edge cases, and be versioned alongside the prompt.
Operational Risk: Metric Over-Optimization
Risk: Teams may tune the expansion prompt to maximize eval metrics at the expense of real-world user satisfaction, a classic Goodhart's Law failure. Guardrail: Always pair offline eval metrics with online A/B tests measuring end-user task completion rates and result click-through.
Operational Risk: Domain-Specific Terminology
Risk: The eval prompt may penalize correct but highly domain-specific expansions if the evaluator model lacks the necessary vertical expertise. Guardrail: Include a domain context preamble in the eval prompt and spot-check a random sample of 'false positive' flags with a human expert.
Copy-Ready Prompt Template
A reusable prompt that evaluates synonym expansion quality against a golden set, producing structured precision, recall, drift, and regression reports.
This template is the core evaluation prompt for synonym expansion systems. It takes a batch of user queries, the expansion terms your system produced, and a golden set of expected expansions, then returns a structured evaluation with per-query metrics, aggregate scores, pass/fail criteria, and regression flags. Use it before deploying expansion changes, when tuning expansion parameters, or as part of a CI pipeline that gates prompt updates.
textYou are a search quality evaluator. Your task is to evaluate synonym expansion outputs against a golden set of expected expansions. ## INPUTS - User Queries: [QUERIES] - Generated Expansions: [GENERATED_EXPANSIONS] - Golden Expected Expansions: [GOLDEN_EXPANSIONS] - Domain Context: [DOMAIN_CONTEXT] - Previous Evaluation Baseline (optional): [BASELINE_EVAL] - Evaluation Thresholds: [THRESHOLDS] ## OUTPUT SCHEMA Return a JSON object with this exact structure: { "evaluation_id": "string", "timestamp": "ISO8601", "summary": { "total_queries": number, "passed": number, "failed": number, "aggregate_precision": number, "aggregate_recall": number, "aggregate_f1": number, "mean_term_drift_score": number, "regression_detected": boolean }, "per_query_results": [ { "query_id": "string", "original_query": "string", "generated_terms": ["string"], "expected_terms": ["string"], "true_positives": ["string"], "false_positives": ["string"], "false_negatives": ["string"], "precision": number, "recall": number, "f1": number, "term_drift_score": number, "drift_terms": ["string"], "passed": boolean, "failure_reasons": ["string"] } ], "regression_analysis": { "regression_detected": boolean, "regressed_queries": ["string"], "improved_queries": ["string"], "delta_summary": "string" }, "recommendations": ["string"] } ## EVALUATION RULES 1. For each query, compare generated terms to expected terms using exact string match after lowercasing and stripping whitespace. 2. True positives: terms present in both generated and expected sets. 3. False positives: terms in generated set but not in expected set. 4. False negatives: terms in expected set but not in generated set. 5. Precision = true_positives / (true_positives + false_positives). If denominator is 0, precision = 0. 6. Recall = true_positives / (true_positives + false_negatives). If denominator is 0, recall = 0. 7. F1 = 2 * (precision * recall) / (precision + recall). If both are 0, F1 = 0. 8. Term drift: flag any generated term that is semantically unrelated to the original query or domain context. Score = 1 - (drift_terms_count / total_generated_terms). 9. A query passes if: precision >= [THRESHOLDS.precision_min], recall >= [THRESHOLDS.recall_min], and term_drift_score >= [THRESHOLDS.drift_min]. 10. If [BASELINE_EVAL] is provided, compare per-query metrics and flag regression where F1 drops by more than [THRESHOLDS.regression_delta] or previously-passing queries now fail. ## CONSTRAINTS - Do not hallucinate metrics. Every number must derive from the input data. - If expected terms are empty for a query, mark recall as 1.0 and note "no golden terms provided." - If generated terms are empty for a query, mark precision as 0 and recall as 0. - Flag queries with zero generated terms as "empty expansion" failures. - Report domain mismatches where generated terms contradict [DOMAIN_CONTEXT].
Adaptation notes: Replace [QUERIES] with a JSON array of query objects, each containing an id and text. [GENERATED_EXPANSIONS] should be a JSON array mapping query_id to arrays of expanded terms. [GOLDEN_EXPANSIONS] uses the same structure with your curated expected terms. [DOMAIN_CONTEXT] is a short string describing the domain (e.g., "enterprise SaaS support tickets") to help detect semantic drift. [THRESHOLDS] is a JSON object with keys precision_min, recall_min, drift_min, and regression_delta. [BASELINE_EVAL] is optional—omit the entire field and the regression section when running the first evaluation. For CI pipelines, parse the summary.passed boolean and regression_analysis.regression_detected flag to gate deployment. Always validate the output against the schema before trusting the metrics.
Prompt Variables
Inputs the Synonym Expansion Eval Check prompt needs to work reliably. Validate each before sending to avoid silent evaluation failures or misleading pass/fail signals.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[QUERY] | The original user query being evaluated for expansion quality | how to fix leaking pipe under sink | Must be non-empty string. Check for null, whitespace-only, or injection markers before passing |
[EXPANDED_TERMS] | The synonym expansion output produced by the prompt under test, as a list of terms with optional weights | ["repair leaky pipe", "fix plumbing leak", "stop water drip"] | Must be a JSON array. Validate array length > 0. Each element must have a 'term' string field. Reject if malformed |
[GOLDEN_EXPANSIONS] | The curated reference set of known-good expansions for this query, used as ground truth | ["repair leaking pipe", "fix sink leak", "plumbing leak repair"] | Must be a JSON array of strings. Validate against schema. Null allowed only if golden set is intentionally absent for recall-only eval |
[DOMAIN_CONTEXT] | Optional domain label or glossary reference that constrains valid expansion vocabulary | "residential_plumbing" | If provided, must match a known domain key in the eval config. Reject unknown domains to prevent cross-domain false positives |
[CONFIDENCE_THRESHOLD] | Minimum per-term confidence score below which expansions are excluded from evaluation | 0.6 | Must be a float between 0.0 and 1.0. Default to 0.5 if not provided. Log warning if threshold < 0.3 or > 0.95 |
[PRECISION_WEIGHT] | Relative weight of precision vs recall in the composite score, controlling evaluation bias | 0.5 | Must be a float between 0.0 and 1.0. 0.0 = recall-only, 1.0 = precision-only. Validate range before eval run |
[PREVIOUS_EVAL_RESULTS] | Prior evaluation output for regression detection when comparing prompt versions | {"precision": 0.82, "recall": 0.74, "f1": 0.78} | Optional. If provided, must contain precision, recall, and f1 numeric fields. Schema-check before diff computation. Null allowed for first-run evals |
Implementation Harness Notes
How to wire the Synonym Expansion Eval Check prompt into a CI/CD pipeline or evaluation harness for production-grade quality gates.
The Synonym Expansion Eval Check prompt is designed to operate as a gated evaluation step within a continuous integration pipeline, not as an ad-hoc manual check. Its primary function is to compare the output of a candidate expansion prompt against a curated golden dataset of queries and their known-good expansions. The harness must orchestrate three stages: executing the expansion prompt under test across all golden queries, running this eval prompt to score each output, and aggregating results into a pass/fail report. This structured approach prevents regressions in search recall when prompt templates, model versions, or expansion strategies change.
To implement the harness, store the golden dataset as a version-controlled JSONL file where each line contains a query, context (domain, user intent), and expected_expansions (an array of term objects with term and min_weight). The test runner iterates through each entry, calls the expansion prompt under test, and captures the raw output. That output, along with the expected expansions and any domain constraints, is fed into this eval prompt. The eval prompt returns a structured JSON object containing per-query metrics (precision, recall, term_drift_score) and a global pass boolean. The harness must validate this JSON against a strict schema before aggregation. Configure the harness to log the full prompt input, raw model response, and parsed eval output for every test case to enable post-mortem debugging of failures.
Set explicit thresholds for the CI gate: for example, require mean_recall >= 0.85 and mean_precision >= 0.80 across the golden set, with no single query falling below a recall of 0.60. The harness should also detect regressions by comparing the current run's aggregate scores against a stored baseline from the last approved prompt version. If the term_drift_score exceeds a configured threshold (indicating the model is introducing novel but unvalidated synonyms), flag the run for human review even if precision and recall pass. For high-stakes search applications, add a manual approval step in the pipeline that requires a search quality engineer to sign off on the diff report before the new prompt is promoted to production. Avoid running this eval on a model that is significantly weaker than the generation model, as low-quality eval scores will produce noisy gates and erode trust in the pipeline.
Expected Output Contract
Machine-readable contract for the Synonym Expansion Eval Check prompt. Use this schema to validate model responses, wire output into automated eval pipelines, and detect regression before release.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
evaluation_id | string (UUID v4) | Must match the provided [EVAL_RUN_ID] or be a valid UUID generated by the model. Reject if missing or malformed. | |
query | string | Must exactly match the [INPUT_QUERY] provided in the prompt. Reject if altered, truncated, or rephrased. | |
golden_terms | array of strings | Must be a non-empty array. Each term must be a non-empty string. Reject if empty array or contains null/empty entries. | |
generated_terms | array of objects | Each object must contain 'term' (string), 'weight' (float 0.0-1.0), and 'source' (string). Reject if array is empty or any required key is missing. | |
precision_at_k | float | Must be a float between 0.0 and 1.0 inclusive. Calculated as (true positives in top-k generated terms) / k. Reject if NaN, negative, or >1.0. | |
recall_at_k | float | Must be a float between 0.0 and 1.0 inclusive. Calculated as (true positives in top-k generated terms) / len(golden_terms). Reject if NaN, negative, or >1.0. | |
term_drift_flags | array of strings | If present, each entry must be a non-empty string describing a specific drift instance. Null allowed. Reject if array contains non-string elements. | |
pass_fail | string (enum) | Must be exactly 'PASS' or 'FAIL'. Determined by precision_at_k >= [PRECISION_THRESHOLD] AND recall_at_k >= [RECALL_THRESHOLD]. Reject on any other value. |
Common Failure Modes
What breaks first when evaluating synonym expansion quality and how to guard against it.
Golden Set Drift
What to watch: The golden query set becomes stale as your domain vocabulary, product names, or user language evolves. Expansions that pass eval today may be irrelevant next quarter. Guardrail: Version your golden set alongside your prompt. Schedule quarterly reviews to add new terms, retire obsolete ones, and re-validate edge cases against recent production queries.
Precision-Recall Tradeoff Collapse
What to watch: The eval reports high recall but ignores precision degradation. Over-expansion floods retrieval with irrelevant documents, drowning the re-ranker. Guardrail: Require both precision and recall thresholds in your pass/fail criteria. Add a maximum term count per query and a minimum relevance score per expanded term to prevent term spam.
Term Drift Under Prompt Changes
What to watch: A minor prompt edit causes silent regression where expansions shift semantically without triggering obvious failures. Synonyms become antonyms or domain-inappropriate. Guardrail: Run the eval check against a fixed golden set on every prompt change. Diff the expansion outputs and flag any term that changed without a corresponding golden-set update. Block deployment if drift exceeds threshold.
Domain Boundary Violation
What to watch: The expansion model introduces terms from adjacent but incorrect domains, especially when queries contain ambiguous words. A medical query about 'cells' gets biology expansions when the user meant 'battery cells.' Guardrail: Include domain-context metadata in the eval input. Check expanded terms against a domain exclusion list. Flag any term that belongs to a known-conflict domain for human review.
Negation and Exclusion Inversion
What to watch: The expansion adds synonyms for negated terms, inverting the query intent. 'Laptops without touchscreens' expands to include 'touchscreen laptops.' Guardrail: Include negation-specific test cases in the golden set. Validate that expanded terms do not contradict exclusionary intent. Add a negation-preservation check that compares expanded queries against the original negation scope.
Confidence Score Calibration Decay
What to watch: The model's self-reported confidence scores drift from actual relevance, causing the harness to accept bad expansions or reject good ones. Guardrail: Track calibration error over time by comparing confidence scores against human relevance judgments in the golden set. Set a maximum calibration error threshold. Trigger recalibration review when the gap exceeds 0.15.
Evaluation Rubric
Apply these checks to the evaluator output itself before trusting the synonym expansion eval results. This rubric validates that the eval prompt produced a usable, well-formed, and trustworthy evaluation report.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Output Schema Validity | Output parses as valid JSON matching the [OUTPUT_SCHEMA] contract | JSON parse error or missing required fields such as overall_score, per_term_metrics, or regression_flags | Automated schema validation against the expected JSON Schema definition |
Golden Set Coverage | Every query in the provided [GOLDEN_QUERY_SET] appears in the evaluation output with a corresponding result | Missing query IDs or queries from the golden set that are absent from the eval report | Count comparison: len(output.queries_evaluated) == len(input.golden_set) |
Metric Plausibility | Precision, recall, and F1 scores are between 0.0 and 1.0 inclusive and are internally consistent | Scores outside 0-1 range, NaN, null, or F1 that does not align with reported precision and recall values | Range check on numeric fields; recompute F1 from reported precision and recall and compare |
Term Drift Classification Accuracy | Each expanded term is classified as exact_match, synonym, hypernym, hyponym, related, or drift with a rationale | Unclassified terms, missing rationale strings, or classifications that contradict the provided [DOMAIN_THESAURUS] | Spot-check 10 random classifications against the thesaurus; require rationale string length > 0 |
Regression Flag Completeness | Any metric delta exceeding the [REGRESSION_THRESHOLD] triggers a regression_flag with before_value, after_value, and delta fields | Regression detected in numeric comparison but no corresponding flag object, or flag missing required delta fields | Parse all regression_flags; verify each has before_value, after_value, delta; compare delta to threshold |
Source Attribution Presence | Every evaluation claim about term correctness references a source from the [GOLDEN_QUERY_SET] or [DOMAIN_THESAURUS] | Evaluative statements without source grounding, or citations to sources not present in the provided inputs | Regex search for unattributed claims; verify all cited source IDs exist in the input payload |
Confidence Score Calibration | Per-term confidence scores are provided and the overall confidence aligns with the mean of per-term scores within a 0.1 tolerance | Missing confidence fields, null confidence, or overall confidence that deviates from the per-term mean by more than 0.1 | Compute mean of all per_term.confidence values; assert abs(mean - output.overall_confidence) <= 0.1 |
Human Review Escalation Trigger | Output includes a human_review_required boolean set to true when any regression_flag is triggered or overall_score < [PASS_THRESHOLD] | human_review_required is false but regression_flags array is non-empty or overall_score is below the pass threshold | Assert: if regression_flags.length > 0 or overall_score < pass_threshold, then human_review_required == true |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base eval prompt with a small golden set of 10-20 query-expansion pairs. Run manually or in a notebook. Focus on getting the output schema right before adding rigor.
- Remove strict pass/fail thresholds; use qualitative review.
- Replace
[GOLDEN_SET]with a hardcoded inline JSON array. - Skip regression detection; just compare two runs side by side.
Watch for
- Schema drift between runs making diffs unreadable.
- Overly strict criteria causing false failures on acceptable synonyms.
- Missing edge cases in the golden set (negations, acronyms, domain terms).

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us