Inferensys

Prompt

RAG Passage Relevance Scoring Prompt Template

A practical prompt playbook for using RAG Passage Relevance Scoring Prompt Template in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, ideal user, required inputs, and operational constraints for the RAG Passage Relevance Scoring Prompt Template.

This prompt is for RAG pipeline engineers who need to score the relevance of retrieved passages against a user query before those passages are injected into the generation context. The core job-to-be-done is calibrated filtering: converting a noisy retrieval set into a ranked, scored list where each passage receives a relevance score and a human-readable justification. The ideal user is an engineer or ML operator tuning a production retrieval-augmented generation system, not an end-user chatting with a bot. You should use this prompt when your retrieval step returns more passages than you can safely pack into a context window, when you need an auditable relevance signal to trigger fallback or human review, or when you are calibrating a downstream reranker and need a baseline LLM relevance judgment to compare against.

This prompt is not a replacement for a trained cross-encoder reranker when latency budgets are under 100ms or when you are scoring thousands of passage pairs per query. It is also not the right tool when you need a hard binary include/exclude decision—use the Binary Passage Relevance Filter Prompt Template for that. Do not use this prompt if your passages contain highly sensitive or regulated data that cannot be sent to an external model endpoint without redaction. The prompt assumes you have already retrieved passages and that each passage has a stable identifier you can reference in the output. You must provide the original user query, the set of candidate passages with their IDs, and a defined relevance scale with clear criteria for each score level.

Before integrating this prompt into a production pipeline, you must calibrate the scoring rubric against a golden dataset of query-passage pairs with human relevance judgments. Run the prompt over your eval set, measure score distribution alignment, and tune the scale descriptions until inter-rater agreement between the LLM and human annotators reaches an acceptable threshold for your use case. If your application is in a regulated domain—such as healthcare, legal, or finance—add a human review step for passages that fall into a 'borderline' score bucket, and log every scored passage with its justification for audit. The next section provides the copy-ready prompt template you can adapt and deploy.

PRACTICAL GUARDRAILS

Use Case Fit

Where the RAG Passage Relevance Scoring Prompt Template delivers value and where it introduces risk. Use these cards to decide if this prompt fits your pipeline stage before integrating it.

01

Good Fit: Pre-Generation Filtering

Use when: you need to score and rank retrieved passages before they enter the context window for answer generation. Why: calibrated relevance scores prevent irrelevant context from diluting the generator's attention and reduce hallucination risk. Guardrail: set a minimum score threshold and route passages below it to a separate 'low-confidence' handling path.

02

Good Fit: Retrieval Pipeline Tuning

Use when: you are debugging or optimizing a retrieval system and need to compare the quality of results from different embedding models, chunking strategies, or hybrid search weights. Why: the prompt produces justifications alongside scores, giving you diagnostic signal beyond a numeric metric. Guardrail: run the prompt against a fixed golden set of query-passage pairs to isolate retrieval changes from scoring drift.

03

Bad Fit: Real-Time Chat Without Caching

Avoid when: you need sub-second latency on every user message and cannot cache or pre-score passages. Why: LLM-based scoring adds a full model inference round per query, which can double end-to-end latency. Guardrail: use a lightweight cross-encoder or bi-encoder for real-time filtering and reserve this prompt for offline evaluation, periodic re-ranking, or async pipelines.

04

Required Inputs

Must provide: a user query, a set of retrieved passages with source identifiers, and a defined output schema for scores and justifications. Optional but recommended: a relevance rubric with examples of score levels, domain-specific criteria for what counts as relevant, and a calibration set of scored query-passage pairs. Guardrail: validate that every passage has a unique ID before calling the prompt to ensure traceable output.

05

Operational Risk: Score Drift After Model Updates

What to watch: relevance score distributions can shift when the underlying model is updated, breaking downstream thresholds that trigger generation or human review. Guardrail: pin model versions in production, maintain a calibration set of scored pairs, and run a distribution comparison test before promoting a new model version.

06

Operational Risk: Cost Amplification at Scale

What to watch: scoring every passage for every query multiplies token consumption, especially with large retrieval sets. Guardrail: apply the scoring prompt only to the top-N passages from a faster first-stage retriever, and consider batching multiple query-passage pairs into a single call where the model context window permits.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for scoring retrieved passages by relevance, with square-bracket placeholders for calibration, constraints, and output schema.

This prompt template is designed for RAG pipeline engineers who need to score retrieved passages before they are injected into the generation context. The template forces the model to produce a calibrated relevance score and a concise justification for each passage, making the selection step auditable and tunable. Use it as a filtering gate: passages scoring below a defined threshold should be discarded or flagged for human review before answer generation.

text
You are a relevance scoring engine for a retrieval-augmented generation (RAG) system. Your task is to evaluate each retrieved passage against the user query and assign a relevance score along with a brief justification.

## INPUT
User Query: [USER_QUERY]
Retrieved Passages:
[PASSAGE_LIST]

## SCORING CRITERIA
Score each passage on a scale of [SCORE_MIN] to [SCORE_MAX] using these criteria:
- [SCORE_HIGH]: The passage directly answers or contains key information needed to answer the query.
- [SCORE_MEDIUM]: The passage is topically related but lacks specific answer details.
- [SCORE_LOW]: The passage is only tangentially related or contains no useful information.
- [SCORE_IRRELEVANT]: The passage is unrelated to the query.

## CONSTRAINTS
- Do not generate an answer to the user query. Only score relevance.
- If a passage is ambiguous, score conservatively and note the ambiguity in the justification.
- If the passage contains contradictory information relative to other passages, flag it with a `conflict_flag: true`.
- Ignore passage order; treat each independently.

## OUTPUT SCHEMA
Return a valid JSON object with this exact structure:
{
  "query": "string",
  "passages": [
    {
      "passage_id": "string",
      "relevance_score": number,
      "justification": "string",
      "conflict_flag": boolean
    }
  ]
}

## EXAMPLES
[FEW_SHOT_EXAMPLES]

## RISK LEVEL
[RISK_LEVEL]

Adaptation guidance: Replace [SCORE_MIN] and [SCORE_MAX] with your numeric range (e.g., 0-1 or 1-5). Define [SCORE_HIGH] through [SCORE_IRRELEVANT] with concrete descriptions that match your domain's tolerance for noise. The [PASSAGE_LIST] placeholder should be populated with pre-numbered or ID-tagged passages from your retrieval step. Include 2-3 [FEW_SHOT_EXAMPLES] that demonstrate borderline cases and conflict scenarios. Set [RISK_LEVEL] to high if downstream actions are irreversible; this should trigger additional validation and human review gates in your harness. Always validate the output JSON against the schema before passing scores to the next pipeline stage. If the model returns malformed JSON, use a repair prompt or retry with stricter formatting instructions.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the RAG Passage Relevance Scoring Prompt Template. Each variable must be populated before the prompt is assembled and sent to the model. Missing or malformed variables are the most common cause of scoring failures in production.

PlaceholderPurposeExampleValidation Notes

[QUERY]

The user question or search intent that passages are being scored against

What are the side effects of atorvastatin?

Must be non-empty string. Check for truncation if query exceeds 200 tokens. Null or whitespace-only queries should abort before prompt assembly.

[PASSAGES]

The retrieved passage set to score, each with a unique identifier

[{"id":"p1","text":"Atorvastatin may cause muscle pain..."},{"id":"p2","text":"Common side effects include headache..."}]

Must be valid JSON array with 1-50 objects. Each object requires non-empty id and text fields. Validate JSON parse before prompt injection. Empty array should route to fallback, not scoring.

[SCORING_CRITERIA]

The relevance dimensions the model should evaluate

["topical_match","information_density","specificity_to_query","actionability"]

Must be a JSON array of 1-6 criterion strings. Each criterion must match a known enum value in the scoring harness. Unknown criteria should trigger a warning but not block execution.

[SCORE_RANGE]

The numeric range for relevance scores

{"min":0,"max":10,"step":1}

Must be a valid JSON object with integer min, max, and step fields. Max must exceed min. Step must divide evenly into the range. Scores outside this range in output should trigger repair or retry.

[OUTPUT_SCHEMA]

The expected JSON structure for scored passages

{"id":"string","score":"number","justification":"string","key_excerpt":"string"}

Must be a valid JSON Schema subset. The scoring harness must validate every output object against this schema. Missing required fields should trigger output repair, not silent acceptance.

[CALIBRATION_EXAMPLES]

Few-shot examples of query-passage pairs with expected scores for calibration

[{"query":"...","passage":"...","score":8,"reasoning":"Directly addresses query with specific details"}]

Optional array of 0-5 examples. Each example must include query, passage, score, and reasoning fields. Scores must fall within SCORE_RANGE. Examples with out-of-range scores should be rejected at assembly time.

[CONSTRAINTS]

Behavioral rules for the scoring task

["Score each passage independently","Do not compare passages to each other","If passage is completely irrelevant, score 0","Provide a specific quote as key_excerpt"]

Must be a JSON array of 1-8 constraint strings. Each constraint should be testable in evaluation. Vague constraints like "be accurate" should be replaced with measurable instructions before production use.

PRACTICAL GUARDRAILS

Common Failure Modes

When relevance scoring breaks in production, it's rarely the model's fault. These are the most common failure patterns in RAG passage relevance scoring and how to prevent them before they reach users.

01

Score Inflation on Familiar Patterns

What to watch: The model assigns high relevance scores to passages that match common query patterns but miss the specific intent. This happens when surface-level keyword overlap tricks the scorer into confidence. Guardrail: Include negative examples in your few-shot prompt that demonstrate near-miss passages with explicit reasons for low scores. Calibrate thresholds against a golden dataset containing deceptive near-matches.

02

Threshold Drift Across Query Types

What to watch: A relevance threshold of 0.7 works for factual lookup queries but silently drops valid passages for ambiguous or multi-part questions. The same cutoff produces different precision-recall tradeoffs across query categories. Guardrail: Implement per-query-type threshold calibration. Log threshold decisions by query category and monitor passage drop rates. Use the eval harness to measure threshold performance against labeled query clusters.

03

Position Bias in Passage Ordering

What to watch: The model overweights passages appearing early in the retrieval set and underweights equally relevant passages later in the list. This recency-within-context bias distorts ranking when retrieval order is arbitrary. Guardrail: Randomize passage order before scoring and run multiple scoring passes. Compare score distributions across positions. If scores shift with order, add explicit instructions to evaluate each passage independently of its list position.

04

Length Bias Favoring Longer Passages

What to watch: Longer passages receive inflated relevance scores because they contain more tokens that can match query terms, even when the relevant information is sparse or diluted. Short, dense passages get penalized. Guardrail: Normalize scores by passage information density. Include a length-awareness instruction in the prompt template. Test with synthetic passage pairs where a short passage contains the exact answer and a long passage only tangentially mentions the topic.

05

Justification-Relevance Mismatch

What to watch: The model produces a plausible-sounding justification that doesn't match the assigned score. A passage gets a high score but the justification describes missing information, or a low score with a justification that describes strong relevance. Guardrail: Add a consistency check that compares the score value against the justification text. Flag score-justification pairs where sentiment polarity conflicts. Use the eval harness to measure justification alignment as a separate metric from score accuracy.

06

Silent Failure on Empty or Degraded Retrieval Sets

What to watch: When retrieval returns zero passages, near-duplicate noise, or completely off-topic content, the scoring prompt still produces confident scores instead of signaling that nothing is usable. Downstream generation then proceeds with bad context. Guardrail: Add a pre-scoring gate that checks retrieval set quality before invoking the scoring prompt. Include explicit instructions for handling empty sets, all-irrelevant sets, and sets below a minimum diversity threshold. Return a distinct signal when no passage meets the relevance bar.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the quality of the RAG Passage Relevance Scoring Prompt before shipping. Each criterion targets a specific failure mode observed in production scoring pipelines.

CriterionPass StandardFailure SignalTest Method

Score Calibration

Score for a known-relevant golden passage is >= 0.8; score for a known-irrelevant passage is <= 0.3

All passages receive scores in a narrow band (e.g., 0.5-0.7) regardless of true relevance

Run prompt against a golden query-passage dataset with pre-labeled relevance scores; measure mean absolute error

Justification Grounding

Justification references specific spans or concepts from [PASSAGE] and [QUERY]

Justification is generic (e.g., 'the passage is relevant') or hallucinates content not present in the passage

Manual review of 50 scored passages; flag justifications that lack a direct quote or specific concept match

Score-Consistency Across Similar Passages

Two semantically equivalent passages receive scores within 0.15 of each other

Paraphrased versions of the same passage receive scores differing by > 0.3

Generate paraphrased variants of 20 golden passages; measure score variance across variants

Threshold Discrimination

Clear separation between relevant and irrelevant score distributions; no overlap in interquartile ranges

Score distributions for relevant and irrelevant passages overlap significantly, making threshold selection impossible

Plot score distributions for a balanced test set of 100 relevant and 100 irrelevant passages; calculate overlap coefficient

Query-Intent Alignment

Score reflects alignment with the full intent of [QUERY], not just keyword overlap

Passage receives a high score for keyword match but is about a different topic or answers a different question

Curate 10 queries with keyword-overlap distractors; verify that distractors score lower than intent-matching passages

Length Normalization

Passage length does not systematically bias the score upward or downward

Longer passages consistently receive higher scores regardless of relevance density

Correlate passage length with relevance score on a test set where relevance is length-independent; Pearson r should be < 0.2

Edge-Case Handling

Empty or near-empty [PASSAGE] receives score 0.0 with justification 'insufficient content'; malformed input triggers a parseable error

Empty passage receives a hallucinated score > 0 or prompt returns unparseable output

Unit test with empty string, single character, and non-text input; assert score == 0.0 and justification contains 'insufficient'

Confidence-Weighted Output

When [INCLUDE_CONFIDENCE] is true, output includes a confidence field between 0.0 and 1.0 that correlates with score extremity

Confidence is always 1.0 or is missing when requested; confidence is high for mid-range scores

Check that mid-range scores (0.4-0.6) have lower confidence than extreme scores (<0.2 or >0.8); measure Spearman correlation

TROUBLESHOOTING

Troubleshooting and Edge Cases

Common failure modes, calibration issues, and edge cases encountered when deploying a RAG passage relevance scoring prompt in production.

Score drift often comes from model updates, changing retrieval sources, or shifting user query distributions. Pin the model version in your API calls. Log the score distribution per model version and per data source. Recalibrate your threshold against a fixed golden dataset of query-passage pairs whenever you change the model, the embedding index, or the ingestion pipeline. If you cannot pin the model, run a daily calibration check and alert on distribution shift.

Prasad Kumkar

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.