This prompt is for RAG pipeline builders and search engineers who need to prevent their question-answering systems from becoming echo chambers. The core job-to-be-done is to transform a flat list of retrieved passages into a diverse evidence set that enforces minimum source count, domain variety, and perspective coverage before any answer synthesis occurs. The ideal user is an AI engineer or technical decision maker who has already observed over-reliance on a single document or author in their production RAG system and needs a programmatic, testable intervention. Required context includes the original user query, the full retrieval set with source metadata (author, domain, publication date), and a defined diversity policy specifying minimum sources, required domains, or perspective categories.
Prompt
Source Diversity Enforcement Prompt for Evidence Selection

When to Use This Prompt
Define the job, reader, and constraints for the Source Diversity Enforcement Prompt.
Do not use this prompt when your retrieval pool is inherently homogeneous—for example, a single textbook, a sole-author codebase, or a corpus where all documents share the same perspective by design. The diversity enforcement will either fail to find sufficient variety or will fabricate distinctions where none exist. This prompt is also inappropriate for latency-sensitive real-time applications where the additional reasoning step adds unacceptable delay; in those cases, push diversity constraints into the retrieval stage itself via hybrid search or multi-index queries. Finally, avoid this prompt when the user's question demands a single authoritative answer from a canonical source, such as 'What is the current SLA for service X?'—diversity enforcement would dilute the correct answer with irrelevant or less-authoritative alternatives.
Before implementing this prompt, define your diversity dimensions explicitly. Common dimensions include source domain (e.g., academic, industry, government), author or publisher, publication date range, and perspective or conclusion. Write these into a policy document that the prompt can reference as [DIVERSITY_POLICY]. Without this, the model will invent its own diversity criteria, which may not match your product requirements. After deployment, monitor two failure modes closely: false diversity, where the model selects passages that appear different but convey identical information, and forced diversity, where it includes low-quality or irrelevant passages just to meet a quota. Both require eval loops comparing selected evidence sets against human-curated diverse sets for the same queries.
Use Case Fit
Where the Source Diversity Enforcement Prompt works, where it fails, and the operational conditions required before deploying it into a production RAG pipeline.
Good Fit: Multi-Source Research Synthesis
Use when: The retrieval set contains many relevant passages, and the risk of echo-chamber answers from a single dominant source is high. Guardrail: Set a minimum source count and domain variety threshold in the prompt constraints to force diverse selection.
Bad Fit: Single-Authoritative-Source Lookups
Avoid when: The knowledge base has only one canonical source for the query (e.g., a specific policy document or regulation). Guardrail: Route queries through a pre-check that counts unique sources in the retrieval set; skip diversity enforcement if only one source exists.
Required Input: Rich Source Metadata
Risk: The prompt cannot enforce domain or perspective diversity without metadata like author, publication, date, or domain tags. Guardrail: Ensure your retrieval pipeline attaches structured metadata to each passage before invoking this prompt. Validate metadata completeness in CI.
Operational Risk: Token Budget Bloat
Risk: Enforcing diversity can force the selection of marginally relevant passages to meet quotas, wasting context window space. Guardrail: Pair diversity constraints with a relevance floor. Exclude passages below the threshold even if it means reporting an incomplete evidence set.
Operational Risk: Diversity Theater
Risk: The model selects passages from different sources that all share the same underlying perspective, creating a false sense of balance. Guardrail: Add an eval step that uses a separate LLM judge to classify the perspective of each selected passage and flag low viewpoint variance.
Bad Fit: Latency-Sensitive User-Facing Chat
Avoid when: The evidence selection step must complete in under 500ms for a real-time chat experience. Guardrail: Use a fast, deterministic re-ranker for the primary selection and apply this diversity prompt only as an asynchronous post-hoc audit or for batch-generated reports.
Copy-Ready Prompt Template
A reusable prompt that enforces minimum source count, domain variety, and perspective coverage during evidence selection.
This prompt template is designed to be dropped into a RAG pipeline after retrieval and before answer synthesis. It instructs the model to select a diverse evidence set from the provided candidate passages, enforcing explicit constraints on source count, domain representation, and viewpoint coverage. The goal is to prevent echo-chamber answers where a single source or perspective dominates the final response. Use this template when your knowledge base contains documents from multiple authors, time periods, or organizational units, and when over-reliance on one source would degrade answer quality or introduce bias.
textYou are an evidence selection specialist. Your task is to select a diverse set of passages from the provided candidates that will support a well-rounded, multi-perspective answer to the user's question. ## INPUT User Question: [USER_QUESTION] Candidate Passages: [CANDIDATE_PASSAGES] ## SELECTION CONSTRAINTS 1. **Minimum Source Count**: Select passages from at least [MIN_SOURCES] distinct sources. A source is defined by its [SOURCE_IDENTIFIER_FIELD] (e.g., author, organization, document ID). 2. **Domain Variety**: If the candidate set spans multiple domains, select at least one passage from [MIN_DOMAINS] different domains. Domains are indicated by the [DOMAIN_FIELD] field. 3. **Perspective Coverage**: Identify the primary perspectives or viewpoints present in the candidate set. Select passages that represent at least [MIN_PERSPECTIVES] distinct perspectives. If fewer perspectives exist, note the limitation. 4. **Relevance Threshold**: Only select passages with a relevance score above [RELEVANCE_THRESHOLD]. Exclude all others. 5. **Token Budget**: The total selected passages must not exceed [MAX_TOKENS] tokens. ## OUTPUT FORMAT Return a JSON object with the following structure: { "selected_passages": [ { "passage_id": "string", "source": "string", "domain": "string", "perspective": "string", "relevance_score": number, "token_count": number, "selection_rationale": "string" } ], "diversity_summary": { "total_sources": number, "total_domains": number, "total_perspectives": number, "total_tokens": number }, "excluded_passages": [ { "passage_id": "string", "exclusion_reason": "string" } ], "underrepresented_viewpoints": ["string"], "diversity_score": number } ## DIVERSITY SCORE CALCULATION Calculate a diversity_score from 0.0 to 1.0 using: - Source spread: (unique_sources_selected / total_unique_sources_available) * 0.3 - Domain spread: (unique_domains_selected / total_unique_domains_available) * 0.3 - Perspective spread: (unique_perspectives_selected / total_unique_perspectives_available) * 0.4 ## RULES - If constraints cannot be met, select the best possible set and flag violations in underrepresented_viewpoints. - Do not fabricate sources, domains, or perspectives not present in the candidate passages. - Prioritize passages that add unique information over those that repeat already-selected content.
Adaptation notes: Replace the square-bracket placeholders with values from your retrieval pipeline. The [SOURCE_IDENTIFIER_FIELD] and [DOMAIN_FIELD] should match the metadata schema of your vector database or search index. If your passages lack domain or perspective metadata, remove those constraints or replace them with proxy signals (e.g., publication date ranges, author affiliations). The diversity score formula can be adjusted to weight source spread, domain spread, and perspective spread differently based on your use case. For high-stakes domains, add a [RISK_LEVEL] field and require human review when the diversity score falls below a threshold. Always validate the JSON output against your expected schema before passing selected passages to the synthesis step.
Prompt Variables
Required inputs for the Source Diversity Enforcement Prompt. Each variable must be populated before the prompt is assembled and sent to the model. Validation notes describe how to verify the input is well-formed before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[RETRIEVED_PASSAGES] | The full set of candidate passages returned by retrieval, including metadata for source, date, and domain | {"passages": [{"id": "p1", "text": "...", "source": "arxiv.org", "date": "2024-03-15", "domain": "computer_science"}]} | Must be a valid JSON array with at least 3 passages. Each passage requires id, text, source, and domain fields. Reject if fewer than 3 unique sources are present. |
[USER_QUERY] | The original user question or search intent that triggered retrieval | What are the latest approaches to reducing transformer inference latency? | Non-empty string with minimum 10 characters. Must not contain only stop words. Reject if query appears to be a system command or injection attempt. |
[MINIMUM_SOURCE_COUNT] | The minimum number of distinct sources that must be represented in the final evidence set | 3 | Integer between 2 and 10. Must be less than or equal to the number of unique sources in [RETRIEVED_PASSAGES]. Default to 3 if not specified. |
[MINIMUM_DOMAIN_COUNT] | The minimum number of distinct domains or perspectives that must be represented | 2 | Integer between 1 and 5. Must be achievable given the domain diversity in [RETRIEVED_PASSAGES]. Warn if set higher than available unique domains. |
[MAX_PASSAGES_PER_SOURCE] | The upper limit on how many passages can be selected from any single source to prevent dominance | 2 | Integer between 1 and 5. Lower values enforce stricter diversity. Set to 1 for maximum source distribution. |
[DIVERSITY_WEIGHTS] | Optional tuning parameters that adjust the trade-off between relevance and diversity in selection | {"source_diversity": 0.4, "domain_diversity": 0.3, "relevance": 0.3} | JSON object with keys source_diversity, domain_diversity, relevance. Values must sum to 1.0. Each value must be between 0.0 and 1.0. Null allowed if using default equal weighting. |
[OUTPUT_SCHEMA] | The expected JSON structure for the diverse evidence set output | {"selected_passages": [], "diversity_summary": {}, "exclusion_reasons": []} | Valid JSON Schema or example structure. Must include fields for selected passages, diversity metrics, and exclusion justifications. Reject if schema lacks traceability fields. |
Common Failure Modes
Source diversity enforcement fails in predictable ways. Here are the most common failure modes and how to guard against them in production.
Token-Budget Starvation of Minority Sources
What to watch: When the context window is tight, the model silently drops the lowest-ranked diverse sources to make room, defeating the diversity constraint. The output claims diversity but only cites the top two sources. Guardrail: Implement a hard reservation of token budget per required source before ranking. Validate post-selection that every required source category has at least one passage present.
Surface-Level Diversity Without Perspective Coverage
What to watch: The model satisfies the source count requirement by picking passages from different domains that all say the same thing, creating the appearance of diversity without actual viewpoint variety. Guardrail: Add a perspective-coverage check that requires at least one passage per distinct stance or interpretation. Use an LLM judge to verify that selected passages represent genuinely different angles, not just different URLs.
Over-Prioritization of High-Credibility Sources
What to watch: Credibility scoring interacts badly with diversity enforcement. The model ranks authoritative sources first, then fills diversity quotas with low-quality passages that undermine answer quality. Guardrail: Separate credibility thresholds from diversity requirements. Require that every diverse source meets a minimum credibility bar before inclusion. If no qualifying source exists for a required perspective, flag the gap rather than filling with noise.
Echo Chamber Reinforcement from Source Homogeneity
What to watch: When the retrieval corpus itself lacks diversity, the prompt forces selection from a homogeneous pool. The model fabricates distinctions between nearly identical sources to satisfy the diversity instruction. Guardrail: Add a pre-selection corpus diversity check. If the retrieved set has low domain or perspective variance, reduce the diversity requirement and flag the limitation in the output. Never force the model to invent differences that don't exist.
Diversity Metric Gaming Without Semantic Diversity
What to watch: The model optimizes for surface-level diversity metrics like unique domain counts or author counts while selecting passages that are semantically redundant. The eval passes but the answer quality doesn't improve. Guardrail: Use embedding-based semantic similarity checks between selected passages. Set a maximum pairwise similarity threshold. If passages are too similar, trigger re-selection with an explicit instruction to maximize information gain, not just metadata diversity.
Underrepresented Viewpoint Suppression in Ranking
What to watch: Minority or dissenting viewpoints get ranked low by relevance scorers, then excluded by top-K truncation before diversity enforcement runs. The diversity step never sees them. Guardrail: Run diversity-aware re-ranking before top-K truncation, not after. Reserve slots for underrepresented viewpoints early in the pipeline. Use a two-stage approach: diversity-preserving retrieval followed by diversity-constrained ranking.
Evaluation Rubric
Use this rubric to evaluate the quality of evidence sets produced by the Source Diversity Enforcement Prompt before integrating them into downstream answer synthesis. Each criterion targets a specific failure mode in single-source over-reliance or echo-chamber formation.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Minimum Source Count | Selected evidence set contains at least [MIN_SOURCES] distinct source documents or unique identifiers | Fewer than [MIN_SOURCES] sources present; all passages drawn from 1-2 documents despite broader retrieval set | Count unique source IDs in output; assert count >= [MIN_SOURCES] |
Domain Variety | Selected passages span at least [MIN_DOMAINS] distinct domains or organizational origins | All selected passages originate from a single domain or organization type; no cross-domain representation | Extract domain metadata from selected sources; count unique domains; assert count >= [MIN_DOMAINS] |
Perspective Coverage | Evidence set includes at least one passage representing each required perspective category specified in [PERSPECTIVE_CATEGORIES] | One or more perspective categories have zero representative passages; evidence set is lopsided toward a single viewpoint | Map each selected passage to perspective categories; assert all categories in [PERSPECTIVE_CATEGORIES] have count > 0 |
Exclusion Justification Quality | Every excluded passage from the top-K retrieval set has a concrete, non-generic exclusion reason | Exclusion reasons are vague, repetitive, or missing; high-relevance passages excluded without clear rationale | Parse exclusion_reasons field; assert length > 20 chars per reason; check for unique justifications; flag generic patterns |
Diversity Score Threshold | Computed diversity score meets or exceeds [DIVERSITY_THRESHOLD] using the defined diversity metric | Diversity score falls below threshold; evidence set is clustered around similar sources or perspectives | Calculate diversity score using [DIVERSITY_METRIC] function; assert score >= [DIVERSITY_THRESHOLD] |
Underrepresented Viewpoint Detection | Output explicitly flags any perspective categories or source types that are missing or underrepresented in the retrieval set | No mention of missing perspectives when retrieval set lacks coverage; system proceeds as if evidence is complete | Check for presence of missing_perspectives or underrepresented_viewpoints field; assert field is populated when retrieval set lacks category coverage |
Overlap with Full Retrieval Set | Selected evidence set is a proper subset of the full retrieval set; no fabricated or hallucinated sources appear | Selected passages contain source titles, URLs, or content not present in the original retrieval input | Cross-reference each selected passage ID against input retrieval set IDs; assert all selected IDs exist in input |
Selection Balance Ratio | No single source contributes more than [MAX_SOURCE_RATIO] proportion of total selected passages | One source dominates the selection with disproportionate passage count; diversity enforcement failed | Calculate passage count per source; divide by total selected count; assert each source ratio <= [MAX_SOURCE_RATIO] |
Implementation Harness Notes
How to wire the Source Diversity Enforcement Prompt into a production RAG pipeline with validation, retries, and observability.
The Source Diversity Enforcement Prompt is designed to sit between your retrieval step and your answer synthesis step. It accepts a set of candidate passages and a user query, then outputs a curated subset that meets explicit diversity constraints. In a production harness, this prompt is not a one-shot call—it is a structured component with a strict JSON output contract, schema validation, and a retry loop for malformed responses. The harness must enforce the minimum source count, domain variety, and perspective coverage rules defined in the prompt, and it must log every selection decision for downstream auditability.
To wire this into an application, wrap the prompt in a function that accepts retrieved_passages, user_query, min_sources, required_domains, and diversity_constraints as inputs. The function should call the model with response_format set to a JSON schema that matches the expected output: an array of selected passages, each with a source_id, domain, perspective_label, and selection_rationale. After receiving the response, validate the JSON structure, check that the number of selected sources meets or exceeds min_sources, verify that required_domains are represented, and confirm that perspective labels are not all identical. If validation fails, retry up to two times with the validation error message appended to the prompt as feedback. If the third attempt still fails, log the failure, fall back to a diversity-agnostic top-k selection, and raise an alert for manual review. This pattern prevents a single malformed output from breaking the entire RAG pipeline.
For high-stakes domains such as legal research or clinical evidence review, add a human-in-the-loop step after diversity enforcement but before answer synthesis. Present the curated evidence set to a reviewer with the selection rationales and any flagged underrepresented viewpoints. The reviewer can approve, reject, or add missing sources before the answer is generated. For observability, log every diversity enforcement call with the input passage count, the selected passage count, domain distribution, perspective distribution, validation pass/fail status, retry count, and model used. This trace data is essential for detecting drift in model behavior, identifying when diversity constraints are too strict for the available evidence, and tuning the prompt over time. Avoid using this prompt when the retrieval set is already small—if fewer than min_sources passages are retrieved, skip diversity enforcement and flag the evidence gap directly.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

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

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a simple JSON output contract and a minimum source count of 3. Skip complex diversity metrics during prototyping. Focus on getting the model to return a list of sources with a brief justification for each.
codeReturn a JSON object with a "selected_sources" array containing at least [MIN_SOURCES] sources. Each source must include "source_id", "domain", and "selection_reason".
Watch for
- Model selecting sources from the same domain despite instructions
- Missing domain variety when the retrieval set is homogeneous
- Overly verbose justifications that waste tokens

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