This prompt is built for evaluation engineers and AI quality teams who need to run head-to-head comparisons between two passage filtering approaches, model versions, or retrieval configurations. Instead of relying on aggregate metrics like recall@k or NDCG alone, this prompt produces a structured, comparative relevance judgment with detailed reasoning for each query-passage pair. The core job-to-be-done is generating an auditable, human-readable trail that explains why one filtering strategy outperforms another on specific examples. Use it when you are running A/B filter evaluations, calibrating a new relevance scorer against a baseline, or generating evidence for inter-rater reliability checks and bias detection workflows. The prompt forces the model to justify its preference, flag ties, and surface potential biases in its own judgment, which makes it suitable for detecting systematic failures that aggregate metrics often hide.
Prompt
LLM Judge Prompt for Passage Relevance Comparison

When to Use This Prompt
Defines the comparative evaluation workflow, ideal user, and boundaries for the LLM Judge prompt to prevent misuse in single-system or absolute relevance scoring tasks.
This prompt assumes you already have two ranked or filtered passage sets for the same query and need a comparative judgment, not an absolute relevance score. The required inputs are the original query, the two passage sets (labeled Set A and Set B), and any optional evaluation criteria or rubrics you want the judge to apply. The expected output is a structured JSON object containing a preference decision (A, B, or tie), a confidence score, a detailed justification, and a bias self-check. Do not use this prompt for single-system relevance scoring, binary filtering, or tiered labeling—those tasks have dedicated playbooks in this content group. Using this prompt for absolute relevance assessment will produce misleading results because the model is instructed to compare, not to score in isolation. The prompt is also not suitable for production latency-sensitive filtering pipelines; it is an offline evaluation tool designed for depth, not speed.
Before running this prompt at scale, calibrate it against a golden dataset of human-annotated query-passage pairs where the correct preference is known. Measure the judge's agreement rate with human evaluators and check for position bias (favoring Set A or Set B based on presentation order) by randomizing the set labels. If the judge shows systematic bias toward longer passages, more fluent text, or certain source domains, document those biases in your evaluation report rather than treating the LLM judgments as ground truth. For high-stakes filtering decisions—such as medical, legal, or financial content—always include human review of a statistically significant sample of the judge's outputs. The next step after reading this section is to review the prompt template and implementation harness to understand how to wire this judge into your existing evaluation pipeline.
Use Case Fit
Where this prompt works, where it fails, and what you must have in place before relying on it in production.
Good Fit: A/B Filter Evaluation
Use when: comparing two passage filtering approaches (e.g., vector similarity vs. keyword, or two model versions) on the same query set. Why: the prompt produces comparative judgments with detailed reasoning, making it ideal for offline eval harnesses that measure which filter returns more relevant passages.
Good Fit: Inter-Rater Reliability Calibration
Use when: you need to measure agreement between human annotators and an LLM judge, or between two LLM judges. Why: the prompt includes reliability checks and bias detection, so you can quantify judge consistency before trusting automated relevance scores in your pipeline.
Bad Fit: Real-Time Filtering
Avoid when: you need passage relevance decisions inside a latency-sensitive RAG pipeline serving user requests. Why: comparative LLM judging is too slow and expensive for per-query filtering. Use a lightweight relevance classifier or embedding similarity threshold instead, and reserve this prompt for offline evaluation.
Bad Fit: Single-Passage Scoring
Avoid when: you only need a relevance score for one passage against one query. Why: this prompt is designed for pairwise or set-wise comparison. For single-passage scoring, use the RAG Passage Relevance Scoring Prompt Template instead to avoid unnecessary token cost and comparison overhead.
Required Inputs
Must have: a set of passages from two or more filtering approaches applied to the same query, plus ground-truth relevance labels or human judgments for calibration. Without this: you cannot measure which filter is better or detect judge bias. The prompt assumes paired comparison data exists before invocation.
Operational Risk: Judge Bias Drift
What to watch: the LLM judge may develop systematic preferences (e.g., favoring longer passages, certain writing styles, or one filter's output format) that corrupt A/B comparisons over time. Guardrail: rotate passage ordering, blind the judge to filter identity, and periodically recalibrate against human judgments using the inter-rater reliability checks built into the prompt.
Copy-Ready Prompt Template
A reusable prompt for comparing two passage filtering approaches and producing structured comparative relevance judgments with detailed reasoning.
This prompt template is designed for evaluation engineers who need to compare the output of two different passage filtering systems, model versions, or prompt variants against the same query and retrieval set. It produces a structured comparison that includes relevance judgments, reasoning for each decision, and explicit flags for agreement, disagreement, and potential bias. Use this when you need reproducible, side-by-side evaluations to decide which filtering approach performs better before deploying to production. Do not use this for single-system evaluation or when you lack a baseline to compare against—use a single-system scoring prompt instead.
textYou are an impartial evaluation judge comparing two passage filtering systems (System A and System B) on the same retrieval task. Your role is to produce structured, evidence-based comparative judgments that can be used for A/B evaluation and inter-rater reliability analysis. ## INPUT **Query:** [QUERY] **Retrieved Passages (pre-filtering):** [RETRIEVED_PASSAGES] **System A Filtered Passages:** [SYSTEM_A_OUTPUT] **System B Filtered Passages:** [SYSTEM_B_OUTPUT] **Evaluation Criteria:** [EVALUATION_CRITERIA] ## TASK For each passage in the original retrieval set, produce a comparative judgment following the output schema below. You must: 1. Assess whether each passage is truly relevant to the query (ground truth judgment). 2. Compare System A and System B decisions against that ground truth. 3. Identify agreements, disagreements, and potential bias patterns. 4. Provide detailed reasoning for each comparative judgment. ## OUTPUT SCHEMA Return a JSON object with the following structure: ```json { "query": "string", "evaluation_date": "ISO 8601 timestamp", "passage_evaluations": [ { "passage_id": "string", "passage_text": "string", "ground_truth_relevance": "relevant | irrelevant | partially_relevant", "ground_truth_reasoning": "string", "system_a_decision": "kept | filtered", "system_b_decision": "kept | filtered", "comparative_judgment": "agreement_correct | agreement_incorrect | a_better | b_better | both_wrong", "comparative_reasoning": "string", "confidence": 0.0-1.0 } ], "aggregate_metrics": { "system_a_precision": 0.0-1.0, "system_a_recall": 0.0-1.0, "system_b_precision": 0.0-1.0, "system_b_recall": 0.0-1.0, "agreement_rate": 0.0-1.0, "winner": "a | b | tie" }, "bias_detection": { "position_bias_detected": true/false, "position_bias_evidence": "string or null", "length_bias_detected": true/false, "length_bias_evidence": "string or null", "other_biases": ["string"] }, "inter_rater_notes": "string explaining any edge cases or judgment calls that another evaluator might decide differently" }
CONSTRAINTS
- Judge each passage independently before computing aggregate metrics.
- If a passage is partially relevant, explain what portion is relevant and what is not.
- Flag any position bias (e.g., System A always listed first) or length bias in your reasoning.
- Use confidence scores to indicate judgment certainty, not model confidence.
- If the query is ambiguous, state your interpretation in the inter_rater_notes field.
- Do not favor either system by default. Base all judgments on evidence.
To adapt this prompt for your evaluation pipeline, replace each square-bracket placeholder with actual data before sending to the model. The [QUERY] should be the original user question or search intent. [RETRIEVED_PASSAGES] should contain the full set of passages before any filtering, with unique identifiers for each passage. [SYSTEM_A_OUTPUT] and [SYSTEM_B_OUTPUT] should contain the filtered passage sets from the two systems you are comparing, using the same passage identifiers. [EVALUATION_CRITERIA] should specify what makes a passage relevant for this specific use case—be explicit about relevance definitions, as vague criteria produce unreliable judgments. If your provider supports structured output mode, use it to enforce the JSON schema directly. Otherwise, parse the JSON block from the response and validate it against the expected schema before using the results. For high-stakes evaluations where filtering errors could cause downstream harm, always run this prompt with multiple LLM judges and compute inter-rater agreement scores before trusting the comparison.
Prompt Variables
Inputs the LLM Judge prompt needs to produce reliable comparative relevance judgments. Validate each variable before sending to prevent schema errors, bias, and uncalibrated scores.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[QUERY] | The user question or information need that passages were retrieved for | What are the side effects of Drug X in elderly patients? | Must be non-empty string. Check for leading/trailing whitespace. Truncate if over 2000 chars to avoid context dilution |
[PASSAGE_A] | First retrieved passage to compare for relevance | Drug X clinical trial data shows increased dizziness in patients over 65... | Must be non-empty string. Strip any retrieval metadata or vector IDs. Check for minimum 50 chars to ensure meaningful comparison |
[PASSAGE_B] | Second retrieved passage to compare for relevance | Drug X prescribing information lists common adverse reactions including nausea... | Must be non-empty string. Strip any retrieval metadata or vector IDs. Check for minimum 50 chars to ensure meaningful comparison |
[RELEVANCE_CRITERIA] | Domain-specific criteria defining what makes a passage relevant to the query | Directly addresses the query topic; contains factual information about Drug X side effects; mentions elderly population or age-related factors | Must be non-empty string with at least 3 distinct criteria. Validate criteria are specific and measurable, not vague like 'is helpful' |
[OUTPUT_SCHEMA] | Expected JSON structure for the comparative judgment output | {"winner": "A"|"B"|"tie", "score_a": 0.0-1.0, "score_b": 0.0-1.0, "reasoning": "...", "key_differences": ["..."], "confidence": 0.0-1.0} | Must be valid JSON schema string. Validate parseable by JSON.parse. Check required fields: winner, score_a, score_b, reasoning, confidence. Enum values for winner must be exactly A, B, or tie |
[BIAS_CONTROLS] | Instructions to mitigate position bias, length bias, and formatting bias in comparisons | Evaluate passages independently before comparing. Ignore passage order. Do not favor longer passages. Consider relevance to query, not writing style. | Must be non-empty string. Validate contains at least one explicit bias mitigation instruction. Check for position bias control, length bias control, and formatting bias control |
[CALIBRATION_EXAMPLES] | Few-shot examples with known relevance judgments to anchor the judge's scoring scale | Example 1: Query about vaccine efficacy, Passage A directly answers with trial data (score 0.9), Passage B discusses vaccine history (score 0.2), winner A | Must contain at least 2 examples. Validate each example has query, passage_a, passage_b, scores, winner, and reasoning. Check score ranges are 0.0-1.0 and winner is valid enum value |
[INTER_RATER_REFERENCE] | Optional human-annotated relevance judgments for measuring judge alignment | {"human_winner": "A", "human_score_a": 0.85, "human_score_b": 0.30, "annotator_count": 3, "agreement": 0.95} | Optional field, null allowed. If provided, validate human_winner is valid enum, scores are 0.0-1.0, annotator_count is integer >= 1, agreement is 0.0-1.0. Use for calibration checks, not as input to model |
Implementation Harness Notes
How to wire the LLM Judge prompt into an evaluation pipeline for A/B testing, inter-rater reliability checks, and production monitoring.
This prompt is designed to operate inside an automated evaluation harness, not as a one-off manual comparison. The primary integration point is a comparison function that receives two ranked passage lists (from different retrieval or filtering strategies) and a shared query. The harness should call the LLM Judge with a structured prompt, parse the JSON output, and log the comparative judgment along with the detailed reasoning. This structured output is then consumed by downstream analytics to compute win rates, statistical significance, and bias metrics across your evaluation dataset. The harness must enforce a strict schema on the model's response to prevent parsing failures in automated pipelines.
To implement this, wrap the prompt template in a function that accepts query, passages_a, and passages_b as arguments. Before calling the model, validate that both passage lists are non-empty and contain distinct items. Set the model's response_format to JSON mode (or use a structured output API) and provide the expected schema: an object with winner (enum: 'A', 'B', 'tie'), confidence (0.0-1.0), reasoning (string), and bias_flags (array of strings). Implement a retry loop with up to 3 attempts for malformed JSON or schema violations, logging each failure. For high-stakes comparisons, route tie results and low-confidence judgments (confidence < 0.7) to a human review queue. Store the raw prompt, full response, and parsed judgment in an evaluation database with timestamps for later analysis.
Inter-rater reliability checks require running the same comparison multiple times (typically 3-5 runs) with the temperature set to a non-zero value (e.g., 0.2) to surface judgment instability. The harness should compute Cohen's kappa or Krippendorff's alpha across runs and flag query-passage pairs where agreement falls below 0.6 for manual inspection. For bias detection, track win rates per system across demographic or topic slices of your evaluation set. If one system consistently wins for certain query types, the harness should alert the team to potential evaluation bias rather than true quality differences. Avoid running this judge on single-passage comparisons; the prompt is calibrated for ranked lists and may produce unreliable results with insufficient context.
Expected Output Contract
Fields, data types, and validation rules for the LLM judge response when comparing passage relevance. Use this contract to parse, validate, and store judgments in your evaluation pipeline.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
judgment_id | string (UUID v4) | Must parse as valid UUID v4. Reject if missing or malformed. | |
comparison_type | enum: pairwise | listwise | reference_based | Must match one of the allowed enum values exactly. Reject unknown values. | |
passage_a_id | string | true if comparison_type is pairwise | Must be non-empty and match a passage ID from the input set. Null allowed for non-pairwise comparisons. |
passage_b_id | string | true if comparison_type is pairwise | Must be non-empty and match a passage ID from the input set. Null allowed for non-pairwise comparisons. |
relevance_ranking | array of passage_id strings | Must contain at least 2 entries. Each ID must appear in the input passage set. No duplicates allowed. Order must reflect descending relevance. | |
relevance_scores | object mapping passage_id to float | Each value must be a float between 0.0 and 1.0 inclusive. Every passage in the input set must have a score. No extra keys allowed. | |
rationale | string | Must be non-empty. Should reference specific content from passages. Length between 50 and 2000 characters recommended. Flag if shorter than 20 characters. | |
confidence | float | Must be between 0.0 and 1.0 inclusive. Values below 0.5 should trigger human review or retry. |
Common Failure Modes
LLM judges fail in predictable ways when comparing passage relevance. These are the most common failure modes in production evaluation pipelines and how to guard against them.
Position Bias Skews Rankings
What to watch: The judge systematically prefers passages appearing first or last in the input list, regardless of actual relevance. This is especially common when comparing more than three passages. Guardrail: Randomize passage order for each judgment call and run multiple order permutations. Measure position-relevance correlation across your eval set. If correlation exceeds 0.3, add explicit instructions to ignore position.
Length Bias Favors Longer Passages
What to watch: The judge assigns higher relevance scores to longer passages because they contain more words that overlap with the query, even when shorter passages are more precisely relevant. Guardrail: Normalize passage lengths before comparison or include a length-penalty instruction. Track score-vs-length correlation in eval logs. Flag comparisons where the longest passage wins more than 60% of the time.
Semantic Drift in Reasoning Chains
What to watch: The judge's written reasoning introduces claims not present in the passage, then uses those fabricated claims to justify the relevance score. This creates a hallucination loop where bad reasoning produces bad scores. Guardrail: Add a verification step that requires the judge to quote the exact passage text supporting each reason. Run a secondary check comparing reasoning claims against passage content.
Inter-Rater Inconsistency Across Runs
What to watch: The same judge produces different relevance scores for the same query-passage pair across multiple runs, making A/B filter comparisons unreliable. Temperature settings and non-deterministic sampling are common causes. Guardrail: Set temperature to 0 for evaluation judgments. Run each comparison at least three times and flag pairs where score variance exceeds your threshold. Use majority-vote or mean-score aggregation for final labels.
Query Misinterpretation in Edge Cases
What to watch: The judge misunderstands ambiguous, negated, or multi-intent queries and evaluates passages against the wrong interpretation. This produces systematically wrong relevance labels for entire query categories. Guardrail: Include query-clarification examples in few-shot prompts for ambiguous query types. Log query-category failure rates separately. If a query category exceeds 15% failure, add category-specific instructions or route to human review.
Overfitting to Surface Keyword Match
What to watch: The judge rewards passages with high keyword overlap but low semantic relevance, missing passages that use different terminology to address the same concept. This is common in technical domains with synonym-rich vocabularies. Guardrail: Include synonym-aware examples in few-shot prompts. Add an explicit instruction to reward conceptual relevance over lexical overlap. Validate against a synonym test set where keyword-matched passages are intentionally irrelevant.
Evaluation Rubric
Use this rubric to test the LLM Judge prompt's output quality before shipping it into your evaluation pipeline. Each criterion targets a specific failure mode observed in comparative relevance judgment tasks.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Relevance Justification Completeness | Every relevance judgment includes a specific reason referencing passage content, not just a score or label | Justifications are generic (e.g., 'relevant to query'), circular, or missing entirely | Run 20 query-passage pairs through the judge; manually verify each justification references at least one concrete detail from the passage |
Comparative Consistency | When Passage A is judged more relevant than Passage B, the reasoning explicitly addresses why A outperforms B on the given query | Judgments flip when passage order is reversed, or the judge assigns different scores without explaining the difference | Pairwise swap test: run each pair in both orders (A,B) and (B,A); flag any case where the relative ranking changes without a documented interaction effect |
Score Calibration Across Queries | Relevance scores for passages of similar quality fall within a 1-point band on the defined scale across different queries | Score drift where identical-quality passages receive a 2/5 on one query and a 4/5 on another without query-specific justification | Create a calibration set of 10 passages with known relevance levels; measure score variance across 5 different queries; flag variance >1.5 points |
Bias Detection: Position Sensitivity | The judge does not systematically favor the first or last passage in the input list | First-passage preference where the initial passage receives higher scores regardless of content, or recency bias favoring the final passage | Randomize passage order across 30 trials; compute average score by position; flag if any position's mean score differs from the grand mean by >0.5 points |
Bias Detection: Length Sensitivity | The judge does not systematically assign higher relevance scores to longer passages | Longer passages consistently outscore shorter passages of equal or greater relevance to the query | Pair 10 long passages with 10 short passages of matched relevance; flag if the long-passage win rate exceeds 60% |
Inter-Rater Reliability with Human Judgments | LLM judge rankings correlate with human evaluator rankings at Spearman's ρ ≥ 0.7 on a held-out set | Low correlation (ρ < 0.5) or systematic disagreement on boundary cases where relevance is genuinely ambiguous | Run judge and 2 human evaluators on the same 50 query-passage pairs; compute Spearman's ρ between judge and each human; flag if either correlation < 0.7 |
Refusal and Edge-Case Handling | Judge correctly identifies and flags passages that are empty, non-language content, or entirely unrelated, assigning minimum relevance with a clear reason | Judge assigns mid-range scores to garbage passages, or hallucinates relevance where none exists | Include 5 edge cases in test set: empty passage, base64 blob, passage in wrong language, completely off-topic passage, single-word passage; verify all receive minimum score with appropriate flag |
Output Schema Compliance | Every response strictly follows the defined [OUTPUT_SCHEMA] with all required fields present and correctly typed | Missing fields, extra fields, type mismatches (e.g., string where number expected), or malformed JSON that fails parsing | Schema validation check: parse every output through a JSON Schema validator; flag any response that fails validation; target 100% compliance across 50 test runs |
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
Start with the base pairwise comparison prompt. Use a single frontier model (e.g., GPT-4o or Claude 3.5 Sonnet) with minimal output constraints. Accept free-text reasoning and a simple [PASSAGE_A] / [PASSAGE_B] / [TIE] verdict. Skip inter-rater reliability checks and bias detection during early exploration.
Keep the prompt structure:
[QUERY]: the user question[PASSAGE_A]: first retrieved passage[PASSAGE_B]: second retrieved passage[JUDGMENT_CRITERIA]: relevance, specificity, completeness
Watch for
- Position bias (model favoring Passage A or B based on order)
- Overly verbose reasoning that obscures the verdict
- Missing edge cases where both passages are irrelevant
- No calibration against human judgments

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