Inferensys

Prompt

Evidence Ranking with Diversity Constraint Prompt

A practical prompt playbook for using Evidence Ranking with Diversity Constraint Prompt in production AI workflows.
Wide-angle shot of a modern WeWork open floor plan with creative walls covered in AI system architecture diagrams, product team collaborating in standing desk area with industrial lighting.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the job-to-be-done, ideal user profile, required context, and explicit boundaries for the Evidence Ranking with Diversity Constraint Prompt.

This prompt is designed for RAG system designers and search engineers who need to rank retrieved evidence passages by relevance while enforcing diversity across sources, viewpoints, or document types. Standard relevance ranking often produces top-K homogenization where the highest-scoring passages all originate from a single authoritative source, repeating the same perspective and missing critical context from other documents. This prompt solves that problem by making diversity an explicit ranking constraint alongside relevance. Use it when your downstream answer generation or citation selection requires broad coverage, when you need to surface dissenting or complementary viewpoints, or when audit requirements demand multi-source corroboration.

The ideal user has already retrieved a candidate set of passages—typically 10 to 50—from a vector store, keyword index, or hybrid retrieval pipeline. They need to reduce this set to a ranked top-K (often 5 to 10 passages) that will fit within a context window for answer generation. The prompt expects you to provide the original query, the candidate passages with source identifiers, and a diversity dimension specification (e.g., source domain, author, publication, viewpoint). You should also configure the diversity strength parameter: a low setting permits minor source repetition when relevance is overwhelmingly strong, while a high setting forces strict source separation even at the cost of slightly lower relevance scores. The output is a ranked list with relevance scores, diversity annotations, and a coverage summary showing which sources and perspectives are represented.

Do not use this prompt when you need pure relevance ranking without diversity constraints, when your retrieval set is already small and naturally diverse (fewer than 5 passages from distinct sources), or when latency budgets cannot accommodate the additional reasoning tokens this prompt requires. The diversity constraint adds approximately 30-50% more output tokens compared to a standard ranking prompt because the model must explain trade-offs between relevance and source variety. For real-time applications with sub-second latency requirements, consider running diversity-aware ranking as an offline or async preprocessing step rather than inline during user request handling. Also avoid this prompt when your retrieval pipeline already enforces diversity at the retrieval stage through source-aware sampling or federated search across collections—in those cases, a standard relevance ranking prompt is sufficient.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Evidence Ranking with Diversity Constraint Prompt works, where it fails, and what you need before you start.

01

Good Fit: Multi-Source Research Synthesis

Use when: you need to surface evidence from distinct sources, viewpoints, or document types to prevent a single-source echo chamber. Guardrail: define diversity dimensions explicitly (source, date range, author) in the prompt constraints; don't rely on the model to infer what 'diverse' means.

02

Bad Fit: Single-Document Deep Analysis

Avoid when: all evidence comes from one document and you need exhaustive extraction, not diverse coverage. Guardrail: use a dedicated extraction or span-selection prompt instead; diversity constraints here will artificially spread attention across sections and miss critical details.

03

Required Input: Explicit Diversity Dimensions

What to watch: without specifying which dimensions matter (source, viewpoint, recency, document type), the model defaults to surface-level lexical variety. Guardrail: always pass a [DIVERSITY_DIMENSIONS] list with weights; test that the output distribution matches your intent before production.

04

Required Input: Pre-Retrieved Candidate Set

What to watch: this prompt ranks and diversifies existing passages; it does not retrieve them. Feeding it an already-homogeneous set guarantees poor diversity. Guardrail: ensure your retrieval step uses broad queries, multiple indexes, or hybrid search before this prompt runs.

05

Operational Risk: Diversity-Relevance Tradeoff

Risk: forcing diversity can demote highly relevant passages from a dominant source in favor of weaker but different sources. Guardrail: set a minimum relevance threshold below which diversity is ignored; log every tradeoff decision for audit and tuning.

06

Operational Risk: Token Budget Overrun

Risk: diversity constraints can inflate the number of selected passages, blowing past context window limits for downstream answer generation. Guardrail: enforce a hard [MAX_PASSAGES] cap and a [MAX_TOKENS] budget; if diversity can't be satisfied within budget, surface the gap rather than silently truncating.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt that ranks evidence passages for relevance while enforcing diversity across sources, viewpoints, or document types to prevent top-K homogenization.

This prompt template is designed for RAG system builders who need ranked evidence that covers multiple perspectives rather than converging on a single source. It accepts a query, a set of candidate passages with metadata, and configurable diversity constraints. The output is a ranked list where each tier balances relevance against source variety, preventing the common failure mode where all top-K passages originate from the same document or author. Use this when your downstream answer generation or citation selection requires broad coverage, such as in research synthesis, competitive analysis, or decision-support systems where one-sided evidence produces misleading outputs.

text
You are an evidence ranking system that prioritizes both relevance and diversity.

## INPUT
Query: [QUERY]
Candidate Passages:
[PASSAGES]
  - Each passage includes: id, text, source_id, source_type, author, publication_date

## DIVERSITY CONSTRAINTS
- Minimum distinct sources required in top-K: [MIN_SOURCES]
- Maximum passages per source in top-K: [MAX_PER_SOURCE]
- Diversity dimensions to enforce: [DIVERSITY_DIMENSIONS]
  (Options: source_id, source_type, author, viewpoint, document_section)
- Total passages to return (K): [TOP_K]

## RANKING CRITERIA
1. Relevance: How directly the passage addresses the query, including specificity and factual alignment.
2. Authority: Source credibility based on publication recency, author expertise, and document type.
3. Diversity contribution: Whether the passage adds coverage from an underrepresented source or perspective.

## OUTPUT SCHEMA
Return a JSON object with this exact structure:
{
  "ranked_passages": [
    {
      "rank": 1,
      "passage_id": "string",
      "relevance_score": 0.0-1.0,
      "authority_score": 0.0-1.0,
      "diversity_contribution": "high|medium|low",
      "selection_rationale": "One sentence explaining why this passage was selected at this rank."
    }
  ],
  "diversity_summary": {
    "sources_represented": ["source_id"],
    "coverage_gaps": ["dimensions with insufficient representation"],
    "constraint_violations": ["any constraints that could not be satisfied"]
  },
  "excluded_passages": [
    {
      "passage_id": "string",
      "exclusion_reason": "redundant|low_relevance|constraint_conflict",
      "note": "Brief explanation"
    }
  ]
}

## CONSTRAINTS
- If fewer than [MIN_SOURCES] distinct sources have relevant passages, include all available and flag the gap in coverage_gaps.
- Do not fabricate diversity. If the candidate set lacks diverse perspectives, report it honestly.
- When relevance scores are tied, prefer the passage that improves source diversity.
- Exclude passages that are near-duplicates of higher-ranked selections.

## INSTRUCTIONS
1. Score every passage for relevance and authority independently.
2. Build the ranked list iteratively: select the highest-scoring passage, then select the next passage that maximizes both relevance and diversity contribution.
3. Stop when K passages are selected or no more passages satisfy the constraints.
4. Populate the diversity_summary and excluded_passages fields with honest assessments.

To adapt this template for your system, replace each square-bracket placeholder with concrete values from your retrieval pipeline. The [PASSAGES] block should be populated with your actual retrieval results, including the metadata fields your system tracks. If you don't have source_type or author metadata, remove those from the diversity dimensions options and adjust the input schema accordingly. For production deployments, validate the output JSON against the schema before passing ranked passages to downstream answer generation. When operating in high-stakes domains such as medical or legal evidence ranking, add a human review step that inspects the diversity_summary for coverage gaps before the ranked list is used. The most common adaptation mistake is setting [MIN_SOURCES] too high for narrow queries where only one or two sources exist—this forces the model to include irrelevant passages to satisfy an impossible constraint. Start with [MIN_SOURCES]=2 and [MAX_PER_SOURCE]=3 for a [TOP_K] of 5, then tune based on your retrieval corpus characteristics.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Evidence Ranking with Diversity Constraint Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Missing or malformed inputs are the most common cause of ranking failures in production.

PlaceholderPurposeExampleValidation Notes

[QUERY]

The user question or claim that evidence must support

What are the climate impacts of hydrogen fuel cells across different production methods?

Must be a non-empty string. Check for vague queries under 10 words; short queries produce unreliable diversity constraints.

[EVIDENCE_LIST]

Array of retrieved passages to rank, each with a unique ID and full text

[{"id":"doc-12","text":"Green hydrogen produced via electrolysis using renewables..."}]

Must be valid JSON array with 3-50 objects. Each object requires id (string) and text (string). Empty arrays or single-passage inputs make diversity ranking meaningless.

[DIVERSITY_DIMENSIONS]

The axes along which diversity should be enforced in the ranking

["source_author","methodology","publication_year"]

Must be a JSON array of 1-5 strings. Common dimensions: source_author, source_organization, document_type, methodology, viewpoint, publication_year. Null or empty array disables diversity constraint.

[TOP_K]

Number of top-ranked passages to return after diversity filtering

5

Must be an integer between 2 and [EVIDENCE_LIST] length. Values above the evidence count cause the prompt to fail silently. Default to 5 if not specified.

[MIN_DIVERSITY_COUNT]

Minimum number of distinct values required per diversity dimension in the top-K set

2

Must be an integer >= 1 and <= [TOP_K]. A value of 1 disables enforcement for that dimension. If set higher than available distinct values in evidence, ranking will fail with an insufficiency flag.

[OUTPUT_SCHEMA]

JSON schema the model must conform to in its response

{"ranked_passages":[{"id":"string","rank":"integer","relevance_score":"float","diversity_contributions":["string"]}]}

Must be a valid JSON Schema object. Include required fields: id, rank, relevance_score, diversity_contributions. Schema mismatch with model output format is a top-3 production failure mode.

[CONSTRAINTS]

Hard rules the model must follow during ranking

Do not select more than one passage from the same source_author. Relevance scores below 0.5 must be excluded from top-K.

Must be a non-empty string or null. Use bullet-style rules. Avoid contradictory constraints. Test constraint combinations before deployment; models often resolve conflicts unpredictably.

PRACTICAL GUARDRAILS

Common Failure Modes

Evidence ranking with diversity constraints fails in predictable ways. These are the most common production failure modes and the practical checks that catch them before they reach users.

01

Diversity Collapse to Single Source

What to watch: The diversity constraint is too weak or the primary source is overwhelmingly authoritative, causing the top-K to collapse into passages from a single document despite the constraint. The model selects the best passages overall but ignores the diversity requirement when relevance scores dominate. Guardrail: Add a hard post-processing check that counts unique source IDs in the ranked set. If fewer than the minimum diversity threshold, force re-ranking with an explicit exclusion list of already-selected sources.

02

Token-Budget Starvation of Diverse Sources

What to watch: The diversity constraint forces inclusion of lower-relevance passages from different sources, but the token budget is tight. High-relevance passages from the primary source consume most of the budget, leaving diverse sources truncated or represented by fragments too short to be useful. Guardrail: Allocate a minimum token floor per source before ranking. If the budget cannot satisfy both the diversity count and the per-source minimum, reduce the diversity target rather than shipping unusable fragments.

03

Relevance-Diversity Tradeoff Oscillation

What to watch: The prompt weights relevance and diversity as competing objectives without clear priority, causing the model to oscillate between maximizing one at the expense of the other. Output rankings become unstable across similar queries, with diversity sometimes ignored and sometimes over-prioritized. Guardrail: Define an explicit tie-breaking rule in the prompt: when relevance scores are within a defined margin, diversity wins. When the relevance gap exceeds the margin, relevance wins. Test ranking stability across query variants in eval.

04

Semantic Duplicates Across Different Sources

What to watch: The diversity constraint checks source identity but not semantic content. Two passages from different sources express the same claim in nearly identical language, satisfying the source-diversity check while providing no informational diversity. The ranked set looks diverse by metadata but is redundant by content. Guardrail: Add a semantic deduplication pass after ranking. Compute pairwise similarity on selected passages and flag clusters above a threshold. Replace near-duplicates with the next-best passage from an unrepresented source.

05

Viewpoint Homogenization Under Source Diversity

What to watch: Sources are diverse by name but all represent the same perspective, industry consensus, or ideological position. The diversity constraint is satisfied mechanically while the ranked set still lacks genuine viewpoint diversity, producing answers that appear well-sourced but are systematically narrow. Guardrail: Extend the diversity constraint beyond source identity to include viewpoint or perspective tags when available. If viewpoint metadata is absent, add a post-ranking check that asks a separate evaluator prompt whether the selected set represents multiple perspectives on the query.

06

Diversity Constraint Override by Position Bias

What to watch: Early positions in the retrieval set receive higher relevance scores regardless of content, and the diversity constraint is applied after this biased scoring. The model ranks the first few passages highly, then forces diverse sources from later positions that are genuinely less relevant, producing a ranking that is both biased and diluted. Guardrail: Randomize passage order before ranking or use a calibration prompt that scores passages independently before applying the diversity constraint. Verify in eval that position in the input list does not predict rank in the output.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Evidence Ranking with Diversity Constraint prompt before shipping. Each criterion targets a known failure mode in diversity-constrained ranking. Run these checks against a golden dataset of queries with known diverse source sets.

CriterionPass StandardFailure SignalTest Method

Diversity Constraint Adherence

No more than [MAX_PER_SOURCE] passages from any single source appear in the top-K

Top-K contains [MAX_PER_SOURCE+1] or more passages from one source while other relevant sources are excluded

Count source frequency in top-K output; assert count <= [MAX_PER_SOURCE] for all sources

Relevance Floor Maintenance

All ranked passages score above [RELEVANCE_THRESHOLD] on the defined relevance scale

A passage with score below [RELEVANCE_THRESHOLD] appears in the ranking to satisfy diversity quota

Extract relevance scores from output; assert min(score) >= [RELEVANCE_THRESHOLD]

Source Coverage Breadth

At least [MIN_UNIQUE_SOURCES] distinct sources appear in the top-K when available in the retrieval set

Top-K draws from fewer than [MIN_UNIQUE_SOURCES] sources despite the retrieval set containing sufficient distinct sources

Count unique source identifiers in top-K; assert count >= min([MIN_UNIQUE_SOURCES], distinct sources in input)

Ranking Stability Under Source Removal

Removing the top source's passages does not cause a completely different ranking order for remaining passages

Rank correlation between original and source-removed rankings drops below 0.7 on Kendall's tau

Run prompt with and without the dominant source; compute rank correlation on shared passages

Diversity-Relevance Tradeoff Transparency

Output includes explicit rationale when a higher-relevance passage is demoted for diversity reasons

A demotion occurs with no explanation, or the explanation contradicts the diversity constraint rules

Parse rationale field for each demoted passage; assert rationale mentions diversity constraint when relevance rank > output rank

Viewpoint Representation Check

When [VIEWPOINT_LABELS] are provided, each labeled viewpoint present in the retrieval set appears at least once in top-K

A viewpoint label present in the retrieval set is entirely absent from the top-K output

Extract viewpoint labels from ranked passages; assert set of output labels covers all input labels when K >= number of labels

Document Type Diversity

When [DOCUMENT_TYPE_WEIGHTS] are specified, output distribution reflects configured type preferences within tolerance

One document type dominates top-K despite explicit weighting that favors balanced type representation

Compute type distribution in top-K; assert chi-squared distance from expected distribution < [TYPE_TOLERANCE]

Boundary Case: Insufficient Source Diversity

When retrieval set has fewer distinct sources than [MIN_UNIQUE_SOURCES], output does not fabricate sources or hallucinate diversity

Output invents source identifiers, duplicates passages under different source labels, or fails gracefully with explanation

Provide retrieval set with 1-2 sources only; assert output contains only real source IDs and includes insufficiency note

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a small retrieval set (5-10 passages). Remove strict output schema requirements initially. Use natural language ranking instructions: "Rank these passages by relevance to the query, ensuring no more than 2 come from the same source." Test with a single diversity dimension (source uniqueness) before adding viewpoint or document-type constraints.

Watch for

  • Diversity constraint being ignored when relevance scores are close
  • Model defaulting to relevance-only ranking without diversity enforcement
  • No validation of whether diversity was actually achieved in output
  • Position bias: first passages in the list receiving higher ranks regardless of content
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.