This prompt is designed for RAG system operators and pipeline engineers who need to programmatically exclude low-quality evidence before it reaches the answer generation step. It applies a configurable score threshold to a set of pre-scored passages, filters out those that fall below the cutoff, and produces explicit, auditable reasoning for every exclusion decision. The primary job-to-be-done is preventing noise, irrelevant context, and weak evidence from degrading downstream answer quality, while maintaining a transparent record of what was removed and why. The ideal user is someone who already has a retrieval pipeline that assigns relevance or quality scores to passages—this prompt is a deterministic filtering gate, not a scoring engine.
Prompt
Threshold-Based Evidence Filtering Prompt

When to Use This Prompt
A guide for RAG pipeline engineers on when to deploy a threshold-based filtering gate to exclude low-quality evidence before answer generation.
Use this prompt when your retrieval pipeline produces numerical scores for each passage, you have a defined quality threshold, and you need an auditable filtering step before answer synthesis. It is particularly valuable in high-stakes domains like legal research, clinical decision support, or financial analysis where excluding weak evidence is as important as including strong evidence. The prompt expects a structured input containing scored passages with their associated scores and a threshold value. It returns a filtered set of passages that meet or exceed the threshold, along with a justification for each excluded passage that explains why the score was insufficient. This creates an audit trail that downstream systems and human reviewers can inspect.
Do not use this prompt when you need to generate scores for un-scored passages—it assumes scores already exist and focuses solely on thresholding logic. It is also not suitable for cases where you need nuanced re-ranking of passages that all exceed the threshold, or where the threshold itself needs to be dynamically calculated from the score distribution. For those scenarios, consider pairing this prompt with an evidence scoring prompt from the Evidence Weighting and Scoring Models group, or a re-ranking prompt that handles relative ordering. Additionally, avoid this prompt when the filtering decision requires subjective judgment about content quality beyond what a numerical score captures—the prompt's reasoning is constrained to explaining threshold failures, not performing deep content analysis.
Before deploying this prompt in production, establish clear evaluation criteria for your threshold setting. Over-filtering removes useful context and can cause downstream answer generation to miss critical evidence, while under-filtering admits noise that degrades answer quality. Run this prompt against a golden dataset of scored passages with known good and bad examples, and measure both precision (are excluded passages truly low-quality?) and recall (are all low-quality passages being caught?). In regulated or high-risk domains, always route exclusion decisions above a certain impact threshold to human review, and log all filtering decisions for audit purposes.
Use Case Fit
Threshold-based evidence filtering works best when you have calibrated scores and clear exclusion criteria. It fails when scores are unreliable or the cost of discarding a useful passage is high.
Good Fit: Calibrated Scoring Pipelines
Use when: You have a reliable upstream scoring model that produces consistent, calibrated relevance scores. Guardrail: Validate score distributions across a representative query sample before setting thresholds. If score variance is low, thresholding becomes arbitrary.
Bad Fit: Ambiguous or Exploratory Queries
Avoid when: User intent is unclear or the query is exploratory. Premature filtering can remove context that becomes relevant after clarification. Guardrail: Route low-confidence queries to a clarification step before applying aggressive thresholds.
Required Input: Configurable Thresholds
What to watch: Hard-coded thresholds break across domains and query types. A threshold that works for technical documentation may filter out all evidence for creative queries. Guardrail: Accept thresholds as a runtime parameter with per-use-case defaults, not a single global constant.
Operational Risk: Silent Over-Filtering
Risk: The system discards all evidence and generates an answer from nothing, or refuses when a partial answer was possible. Guardrail: Monitor the ratio of filtered-to-retained passages per query. Alert when the filter rate exceeds a configurable ceiling, and log exclusion reasons for audit.
Operational Risk: Under-Filtering Noise
Risk: The threshold is set too low, admitting irrelevant passages that dilute the context window and cause hallucination. Guardrail: Track answer grounding scores downstream. If grounding degrades, tighten the threshold and re-evaluate against a golden dataset.
Eval Requirement: Boundary Testing
What to watch: Passages that score exactly at the threshold boundary cause flaky behavior across model versions. Guardrail: Include boundary-case passages in your eval set and assert consistent inclusion or exclusion decisions. Flag any threshold where a 0.01 score change flips the decision.
Copy-Ready Prompt Template
A production-ready prompt that filters retrieved passages against configurable thresholds, explains each exclusion, and flags risky filtering decisions for human review.
This prompt template implements threshold-based evidence filtering for RAG pipelines. It accepts a set of scored passages, applies minimum score thresholds per factor (relevance, recency, authority, specificity), and returns only the passages that meet all criteria. Each excluded passage receives an explicit reason, and the prompt flags borderline cases where threshold adjustments might be warranted. Use this when downstream answer generation depends on clean, high-quality evidence and when exclusion decisions must be auditable.
codeYou are an evidence filtering system for a RAG pipeline. Your job is to apply configurable score thresholds to a set of retrieved passages and determine which passages qualify for downstream answer generation. ## INPUT - Passages with pre-computed scores: [SCORED_PASSAGES] - Threshold configuration: [THRESHOLD_CONFIG] - Query context: [USER_QUERY] ## THRESHOLD CONFIGURATION Apply these minimum score thresholds to each passage: - relevance_min: [RELEVANCE_THRESHOLD] - recency_min: [RECENCY_THRESHOLD] - authority_min: [AUTHORITY_THRESHOLD] - specificity_min: [SPECIFICITY_THRESHOLD] ## INSTRUCTIONS 1. For each passage, check whether ALL factor scores meet or exceed their respective minimum thresholds. 2. If a passage meets ALL thresholds, mark it as INCLUDED. 3. If a passage fails ANY threshold, mark it as EXCLUDED and provide a specific reason naming the failed factor(s) and the actual score versus the threshold. 4. For passages within [MARGIN] points of any threshold, add a BORDERLINE flag with a note explaining the risk of over-filtering or under-filtering. 5. Do not modify, summarize, or re-score the passages. Only filter and annotate. ## OUTPUT FORMAT Return a JSON object with this exact structure: { "filtered_passages": [ { "passage_id": "string", "status": "INCLUDED" | "EXCLUDED", "scores": { "relevance": number, "recency": number, "authority": number, "specificity": number }, "exclusion_reason": "string | null", "borderline_flag": { "is_borderline": boolean, "near_threshold_factors": ["string"], "risk_note": "string | null" } } ], "summary": { "total_passages": number, "included_count": number, "excluded_count": number, "borderline_count": number, "filtering_concern": "string | null" } } ## CONSTRAINTS - Do not invent scores. Use only the scores provided in [SCORED_PASSAGES]. - If a passage is missing a required score factor, treat that factor as 0 and exclude the passage with reason "missing_score". - If fewer than [MIN_PASSAGES_TO_RETAIN] passages qualify, include a filtering_concern in the summary noting "insufficient_qualifying_passages" and list the highest-scoring excluded passages as candidates for threshold relaxation. - If more than [MAX_PASSAGES_TO_RETAIN] passages qualify, keep only the top [MAX_PASSAGES_TO_RETAIN] by composite score and note the truncation in the summary.
Adaptation guidance: Replace [SCORED_PASSAGES] with your retrieval output including pre-computed factor scores. Set [THRESHOLD_CONFIG] thresholds based on your domain calibration—start conservatively and tighten after reviewing borderline flags in production. The [MARGIN] parameter controls how many near-threshold passages get flagged for review; 0.05–0.10 is a reasonable starting range on a 0–1 scale. Wire [MIN_PASSAGES_TO_RETAIN] and [MAX_PASSAGES_TO_RETAIN] to your downstream answer generator's context window and quality requirements. If your scoring system uses different factor names, replace the factor keys throughout the template and output schema. Always validate the JSON output against the schema before passing filtered passages to answer generation—malformed exclusion reasons or missing borderline flags indicate the model misunderstood the task and the filtering results should not be trusted.
Prompt Variables
Each placeholder required by the Threshold-Based Evidence Filtering Prompt. Validate inputs before assembly to prevent runtime failures and silent filtering errors.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[PASSAGES] | Array of retrieved evidence passages with metadata to filter | [{"id":"p1","text":"...","score":0.78,"source":"...","date":"2024-03-15"}] | Must be a non-empty JSON array. Each object requires id and text fields. Score field must be numeric if present. Reject if array is null or contains malformed objects. |
[SCORE_THRESHOLD] | Minimum evidence score required for a passage to pass the filter | 0.65 | Must be a float between 0.0 and 1.0. Reject if null, negative, or greater than 1.0. Default to 0.5 if not explicitly provided but log a warning. |
[SCORE_FIELD] | Name of the field containing the evidence quality score in each passage object | relevance_score | Must be a non-empty string matching a key present in every passage object. Validate by checking first passage for field existence. Reject if field is missing from any passage. |
[MIN_PASSAGES] | Minimum number of passages that must survive filtering before the prompt refuses to proceed | 3 | Must be a positive integer. If fewer passages pass the threshold, the prompt should return an empty result set with a refusal reason rather than proceeding with insufficient evidence. Set to 1 to disable. |
[EXCLUSION_REASONING] | Boolean flag controlling whether the prompt outputs explicit reasons for each excluded passage | Must be true or false. When true, output schema must include a reason field for each excluded passage. When false, excluded passages are silently dropped. Default to true for auditability. | |
[OUTPUT_SCHEMA] | Expected structure for the filtered output including passed and excluded passage lists | {"passed":[],"excluded":[],"summary":"..."} | Must be a valid JSON schema object or reference to a named schema. Validate that schema includes required fields for passed passages, excluded passages, and a summary. Reject if schema is missing or unparseable. |
[DOMAIN_CONTEXT] | Optional domain description to calibrate threshold sensitivity for specialized terminology | medical literature review for adverse event detection | Can be null or empty string. If provided, must be a non-empty string under 500 characters. Used to adjust filtering strictness. Log if provided but threshold is not adjusted accordingly. |
[OVERFILTERING_GUARD] | Boolean flag to enable a secondary check that warns when potentially useful passages are excluded near the threshold boundary | Must be true or false. When true, passages within 0.05 of the threshold are flagged for review even if excluded. Default to true for production systems where recall matters. Set to false for high-precision use cases. |
Implementation Harness Notes
How to wire the threshold-based evidence filtering prompt into a production RAG pipeline with validation, retries, and observability.
The threshold-based evidence filtering prompt is designed to sit between retrieval and answer generation in a RAG pipeline. It accepts a ranked list of evidence passages with scores and a configurable threshold, then returns only the passages that meet or exceed that threshold along with explicit reasoning for each exclusion. In production, this prompt should be called as a synchronous step after retrieval re-ranking and before the final answer synthesis prompt. The primary integration points are: (1) a retrieval service that provides scored passages, (2) a threshold configuration store that can be adjusted per query type or risk level, (3) the filtering prompt itself, and (4) downstream answer generation that receives only filtered evidence. Avoid calling this prompt when the retrieval set is already small — filtering three passages down to one may discard useful context that a capable model could have navigated with appropriate uncertainty expression.
Validation is the first line of defense after the model returns. Parse the output against the expected schema: a list of kept passages, a list of excluded passages, and a reason string for each exclusion. Validate that every passage in the input set appears exactly once across the kept and excluded lists — missing passages indicate a model output error. Check that excluded passages have scores strictly below the threshold and kept passages have scores at or above it. If the model excluded a passage above threshold or kept one below, flag it for retry. For high-stakes domains such as healthcare or legal, add a human review step when the filtering decision is borderline — specifically when a passage score falls within 0.05 of the threshold on a normalized 0–1 scale. Log the full input set, threshold value, model output, and validation result for every call. This trace data is essential for debugging threshold calibration issues later.
Retry logic should be bounded and diagnostic. If validation fails, retry once with the same prompt but append the validation errors as additional context in a [VALIDATION_ERRORS] placeholder, instructing the model to correct the specific discrepancies. If the second attempt also fails validation, fall back to a simple score-threshold cutoff without model reasoning — this ensures the pipeline degrades gracefully rather than blocking answer generation entirely. For model choice, prefer a fast, instruction-following model such as GPT-4o-mini, Claude Haiku, or Gemini Flash for this filtering step. The task is classification and justification, not complex reasoning, and latency matters because this step adds overhead between retrieval and answer generation. Avoid using the same model instance for filtering and answer generation if throughput is a concern — parallelize where possible.
Observability is critical because threshold tuning is an empirical process. Track three metrics in production: the filtering rate (percentage of passages excluded per query), the threshold boundary density (how many passages fall within 0.1 of the threshold), and downstream answer grounding scores. If the filtering rate is consistently above 80%, your retrieval set may be too noisy or your threshold is too aggressive — investigate retrieval quality before adjusting the threshold. If answer grounding scores degrade after introducing filtering, you may be over-filtering and removing context the answer model needs. Set up a dashboard that plots these metrics per query category so you can tune thresholds independently for different use cases. Finally, run periodic eval sweeps using a golden dataset of query–passage–threshold triples with known good filtering decisions to detect drift in model behavior across model version updates.
Expected Output Contract
The exact JSON structure, field types, and validation rules your application should enforce when processing the Threshold-Based Evidence Filtering Prompt output.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
filtered_passages | Array of objects | Must be an array. Can be empty if all passages fall below threshold. Validate array length ≤ input passage count. | |
filtered_passages[].passage_id | String | Must match an id from the input passages array. Parse check: confirm id exists in input set. Fail if orphaned id. | |
filtered_passages[].score | Number (float) | Must be ≥ [SCORE_THRESHOLD]. Must be ≤ 1.0. Must match the score assigned in the scoring step. Parse check: numeric, within bounds. | |
filtered_passages[].retention_reason | String | Must be a non-empty string explaining why the passage met the threshold. Citation check: reason must reference specific passage content. Max 200 characters. | |
excluded_passages | Array of objects | Must be an array. Can be empty if all passages pass threshold. Validate that filtered + excluded count equals total input passage count. | |
excluded_passages[].passage_id | String | Must match an id from the input passages array. Must not appear in filtered_passages. Parse check: no duplicate ids across both arrays. | |
excluded_passages[].score | Number (float) | Must be < [SCORE_THRESHOLD]. Must be ≥ 0.0. Must match the score assigned in the scoring step. Parse check: numeric, within bounds. | |
excluded_passages[].exclusion_reason | String | Must be a non-empty string explaining why the passage fell below threshold. Citation check: reason must reference specific passage content. Max 200 characters. |
Common Failure Modes
Threshold-based filtering fails silently in production. These are the most common failure modes when excluding low-quality evidence before answer generation, with concrete guardrails to catch each one before it reaches users.
Over-Filtering Removes Useful Context
What to watch: The threshold is set too high, and passages with moderate scores that contain critical supporting details are excluded. The model then generates answers from incomplete context, producing plausible-sounding but factually incomplete responses. Guardrail: Log every excluded passage with its score and a one-line content summary. Run periodic spot-checks on excluded passages to detect patterns of useful context being discarded.
Under-Filtering Admits Noise
What to watch: The threshold is set too low, and tangentially related or low-authority passages flood the context window. The model synthesizes across weak evidence, diluting strong sources with noise and producing answers that cite irrelevant or contradictory material. Guardrail: Track the score distribution of passages that actually get cited in final answers. If low-scoring passages appear frequently in citations, raise the threshold or add a citation-quality check.
Threshold Drift Across Retrieval Batches
What to watch: Evidence scores shift across different queries, retrieval backends, or document collections, but the threshold stays fixed. A threshold calibrated on one batch silently becomes too strict or too lenient on the next. Guardrail: Monitor the percentage of passages passing the threshold per query over time. Set alerts when the pass rate drops below 10% or exceeds 90%, indicating the threshold needs recalibration for the current distribution.
Exclusion Reasoning Is Opaque
What to watch: Passages are excluded without explanation, making it impossible to audit why evidence was dropped. When answers are wrong, the team cannot determine whether the filter removed the right evidence or the model hallucinated from what remained. Guardrail: Require the filtering prompt to output a structured reason for each exclusion, including the score, the threshold, and a brief justification. Store these in the trace for downstream debugging.
Score Calibration Drift Over Time
What to watch: The scoring model's calibration shifts as new documents, domains, or query patterns enter production. Scores that once reliably separated good from bad evidence become inflated or deflated, breaking the threshold's meaning. Guardrail: Periodically run a calibration set of human-scored passage-query pairs through the scoring prompt. Compare score distributions and adjust the threshold or recalibrate the prompt if the separation between relevant and irrelevant passages degrades.
Single Threshold Ignores Evidence Quality Dimensions
What to watch: A single composite score threshold masks problems in individual quality dimensions. A passage with high relevance but low authority passes, or a passage with high recency but low specificity gets through, producing answers grounded in superficially scored but dimensionally weak evidence. Guardrail: Implement per-dimension minimums alongside the composite threshold. Require minimum scores on authority and specificity before a passage can be included, even if its composite score passes.
Evaluation Rubric
Test output quality before shipping the threshold-based evidence filtering prompt to production. Each criterion validates a specific failure mode: over-filtering useful context, under-filtering noise, or producing unverifiable exclusion decisions.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Exclusion justification presence | Every filtered passage includes a non-empty [EXCLUSION_REASON] field with a specific reference to the passage content | Filtered passages appear with null, empty, or generic reasons like 'low score' without content reference | Parse output JSON and assert [EXCLUSION_REASON] is non-null, length > 20 chars, and contains a passage-specific detail for every excluded item |
Threshold adherence | All passages with [EVIDENCE_SCORE] below [SCORE_THRESHOLD] are excluded; all passages at or above threshold are retained | Passages below threshold appear in the retained set or passages above threshold appear in the excluded set | Sort passages by [EVIDENCE_SCORE], verify no retained passage has score < [SCORE_THRESHOLD] and no excluded passage has score >= [SCORE_THRESHOLD] |
Over-filtering detection | Retained passages collectively cover all distinct facts required to answer the query, verified against a pre-labeled fact set | Retained set omits a fact present in the full retrieval set that is necessary for a correct answer | Run fact coverage comparison: extract claims from retained passages, check against a golden fact list derived from the full retrieval set, flag missing required facts |
Under-filtering detection | No retained passage has [EVIDENCE_SCORE] in the bottom quartile of the retrieval set unless it contains a unique required fact | Multiple low-score passages retained without unique fact justification, introducing noise into the answer generation context | Calculate score distribution of retained set, flag if > 20% of retained passages fall in the bottom quartile without a [UNIQUE_FACT] flag set to true |
Score justification consistency | The [EXCLUSION_REASON] for each filtered passage is consistent with the factor breakdown in [SCORE_BREAKDOWN] for that passage | Exclusion reason cites 'low relevance' but [SCORE_BREAKDOWN] shows relevance sub-score above threshold, indicating contradictory reasoning | For each excluded passage, extract the lowest sub-score from [SCORE_BREAKDOWN], verify the [EXCLUSION_REASON] references that specific factor |
Output schema validity | Output is valid JSON matching the [OUTPUT_SCHEMA] with all required fields present and correctly typed | Missing required fields, wrong types, or malformed JSON that fails schema validation | Validate output against the JSON schema using a programmatic validator, assert no schema violations |
Boundary case handling at threshold | Passages with [EVIDENCE_SCORE] exactly equal to [SCORE_THRESHOLD] are consistently handled as retained, with a [BOUNDARY_FLAG] set to true | Threshold-edge passages are inconsistently classified across runs or the [BOUNDARY_FLAG] is missing | Inject a passage with score exactly equal to [SCORE_THRESHOLD], verify it appears in retained set with [BOUNDARY_FLAG] = true across 5 repeated runs |
Empty retrieval set handling | When [RETRIEVED_PASSAGES] is an empty array, output contains an empty retained array and an empty excluded array with no errors | Empty input produces a hallucinated passage, error message, or non-empty arrays | Submit a request with [RETRIEVED_PASSAGES] = [], assert retained and excluded arrays are both empty and no error field is populated |
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 threshold prompt but use a single hardcoded threshold value (e.g., 0.6) instead of configurable tiers. Skip the per-passage reasoning output and just return a filtered list. Use a simpler output schema with only passage_id and score fields.
codeFilter passages with score < [THRESHOLD]. Return only passages above threshold. Passages: [PASSAGES] Threshold: [THRESHOLD]
Watch for
- No visibility into why passages were excluded, making debugging hard
- Single threshold may be too coarse for mixed-quality retrieval sets
- Missing score normalization across different retrievers leads to inconsistent filtering

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