Inferensys

Prompt

Multi-Document Quote Aggregation Prompt

A practical prompt playbook for using Multi-Document Quote Aggregation Prompt in production AI workflows.
Developer designing multi-agent workflow on laptop, architecture diagram on screen, casual home office setup with afternoon light.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the job, the user, and the boundaries before deploying multi-document quote aggregation.

This prompt is designed for the moment after retrieval, when your system has pulled back a set of candidate documents and needs to extract, deduplicate, and rank the most relevant verbatim quotes that support a single claim. The primary user is an engineering lead or AI builder integrating a citation-aware RAG pipeline into a product—think legal-tech platforms, enterprise knowledge-base search, or compliance review tools. The job-to-be-done is turning a noisy, multi-source retrieval set into a clean, ranked evidence bundle that downstream answer generation or a human reviewer can trust. You should use this prompt when you have a specific claim to ground, multiple source documents in context, and a need for transparent, auditable provenance tracking.

This prompt is not a general-purpose search or summarization tool. Do not use it when you lack a concrete claim to verify, when your retrieval set is empty or trivially small (fewer than two documents), or when the user expects a synthesized narrative answer rather than a structured evidence set. It is also a poor fit for real-time chat where latency budgets are under one second, because the aggregation, deduplication, and ranking steps require careful model reasoning over potentially large contexts. If your application needs a final answer with inline citations, pair this prompt's output with a downstream RAG Citation Answer Prompt. If you are in a regulated domain such as healthcare or finance, you must route the aggregated quotes through a human review step before they appear in a user-facing response.

Before wiring this into production, define your evaluation criteria clearly: coverage (did we miss a key quote?), redundancy reduction (did we collapse near-duplicates correctly?), and provenance accuracy (is every quote traceable to its source document and span?). The prompt template that follows expects you to supply the claim, the retrieved documents with identifiers, and an output schema. Start by testing it against a golden dataset of claims with known supporting quotes, and measure precision and recall before tuning the deduplication threshold or ranking instructions.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Multi-Document Quote Aggregation Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your pipeline before investing in integration.

01

Good Fit: Enterprise Knowledge Bases

Use when: You have multiple internal documents (policies, runbooks, product specs) and need a single, deduplicated evidence set for a claim. Why it works: The prompt's near-duplicate detection and source provenance tracking prevent answer bloat and make audit trails straightforward.

02

Bad Fit: Real-Time Fact Verification

Avoid when: You need to verify a breaking news claim against a live, open-domain web search. Risk: The prompt assumes a closed, pre-retrieved document set. It cannot assess source authority or temporal freshness for documents it hasn't seen, leading to false confidence in outdated or low-quality sources.

03

Required Inputs

Must have: A single, specific claim to verify, plus a pre-retrieved set of documents with unique IDs and full text. Guardrail: If the claim is vague or the document set is empty, the prompt will hallucinate support or fail silently. Validate both inputs upstream before calling this prompt.

04

Operational Risk: High Token Consumption

Risk: Aggregating quotes from dozens of long documents can consume significant context window space, increasing latency and cost. Guardrail: Implement a pre-filtering step (e.g., a lightweight relevance classifier) to limit the input document set to the top-N most promising candidates before aggregation.

05

Operational Risk: Source Bias Amplification

Risk: If the input document set is skewed toward one viewpoint, the aggregated evidence set will appear to have strong, unified support, masking a lack of diverse perspectives. Guardrail: Monitor the distribution of source documents fed into the prompt. Flag outputs where a single source or author dominates the final evidence set.

06

Bad Fit: Subjective or Interpretive Claims

Avoid when: The claim is a matter of opinion, sentiment, or complex interpretation (e.g., 'Company X is the market leader'). Risk: The prompt will extract quotes that mention the topic but cannot reliably judge if they constitute 'support.' This produces a high volume of false-positive evidence. Use a specialized sentiment or stance-detection model instead.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for aggregating, deduplicating, and ranking supporting quotes from multiple documents into a single evidence set.

This template is designed to be dropped directly into your application code. It expects a claim to support, a list of documents with their content and metadata, and a set of constraints that define how quotes should be selected, deduplicated, and ranked. The square-bracket placeholders represent variables your application must populate at runtime before sending the request to the model.

text
You are an evidence aggregation specialist. Your task is to extract, deduplicate, and rank supporting quotes from multiple source documents for a single claim.

## CLAIM
[CLAIM]

## SOURCE DOCUMENTS
[DOCUMENTS]
<!--
Each document must include:
- doc_id: unique identifier
- title: document title
- date: publication or revision date
- author: author or source name
- content: full document text or relevant passage
-->

## OUTPUT SCHEMA
Return a JSON object with the following structure:
{
  "claim": "[CLAIM]",
  "evidence_set": [
    {
      "quote_text": "exact verbatim text from source",
      "doc_id": "source document identifier",
      "span_start": character_offset,
      "span_end": character_offset,
      "relevance_score": 0.0_to_1.0,
      "support_strength": "directly_supports | partially_supports | provides_context",
      "deduplication_note": "original | near_duplicate_of_quote_id_X | merged_from_quotes_Y_and_Z"
    }
  ],
  "coverage_assessment": {
    "claim_aspects_covered": ["aspect1", "aspect2"],
    "missing_aspects": ["aspect3"],
    "sufficiency_verdict": "sufficient | partial | insufficient"
  },
  "deduplication_summary": {
    "total_candidate_quotes_found": integer,
    "quotes_after_deduplication": integer,
    "near_duplicate_clusters_merged": integer
  }
}

## CONSTRAINTS
[CONSTRAINTS]
<!--
Example constraints:
- Maximum 10 quotes in final evidence set
- Minimum relevance_score of 0.6 for inclusion
- Prefer quotes from documents published after [DATE_THRESHOLD]
- Prioritize quotes from sources with authority_level >= [AUTHORITY_THRESHOLD]
- Merge near-duplicate quotes when similarity > 0.85
- Flag but exclude contradictory quotes from final set
- Include at least one quote per document when multiple documents are relevant
-->

## DEDUPLICATION RULES
1. Identify quotes that convey the same factual information, even if wording differs.
2. When near-duplicates are found, keep the most specific and well-phrased version.
3. In the deduplication_note field, reference the doc_id of the kept quote for each removed duplicate.
4. If two quotes from different sources provide complementary details on the same point, merge them into a single entry with deduplication_note "merged_from_quotes_X_and_Y".

## RANKING RULES
1. Rank by support_strength first: directly_supports > partially_supports > provides_context.
2. Within the same support_strength tier, rank by relevance_score descending.
3. Break ties by preferring more recent documents, then by source authority.

## INSTRUCTIONS
- Extract only verbatim text. Do not paraphrase or summarize.
- Include character-level span offsets for every quote.
- If no quotes meet the minimum relevance threshold, return an empty evidence_set with sufficiency_verdict "insufficient".
- Do not fabricate quotes. If a document contains no relevant text, do not extract from it.

Before wiring this into production, replace each bracketed placeholder with real data from your retrieval pipeline. The [DOCUMENTS] placeholder is the most critical: your application must format each document with the required fields before insertion. If your retrieval system does not provide character offsets, modify the output schema to use paragraph or section references instead, but be aware that span-level provenance is essential for audit trails and inline citation rendering. For high-stakes domains such as legal or healthcare, add a [HUMAN_REVIEW_FLAG] field to the output schema and route any evidence_set with sufficiency_verdict "partial" or "insufficient" to a review queue before the evidence reaches end users.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Multi-Document Quote Aggregation 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 aggregation failures.

PlaceholderPurposeExampleValidation Notes

[CLAIM]

The target claim or statement that extracted quotes must support or refute

The new pricing model reduces costs for enterprise customers by 15%

Must be a single declarative sentence. Reject if empty, multi-claim, or interrogative. Parse check: ends with period, contains subject and predicate.

[DOCUMENTS]

Array of source documents with ID, text, and optional metadata fields

[{"doc_id":"doc-42","text":"Enterprise pricing...","source":"pricing_v2.pdf","date":"2025-03-01"}]

Must be valid JSON array with at least 2 documents. Each document requires doc_id and text fields. Reject if text fields are empty or doc_id values are duplicated. Schema check: required fields present, text length > 0.

[MAX_QUOTES_PER_DOC]

Upper limit on quotes extracted from a single document to prevent source dominance

3

Must be integer between 1 and 10. Reject if null, zero, or negative. Default to 3 when not specified. Parse check: integer coercion succeeds.

[DEDUP_THRESHOLD]

Similarity threshold for detecting near-duplicate quotes across documents

0.85

Must be float between 0.0 and 1.0. Higher values produce stricter deduplication. Reject if outside range. Default to 0.85. Parse check: float coercion succeeds.

[MIN_QUOTE_LENGTH]

Minimum character length for an extracted quote to prevent fragment extraction

50

Must be integer >= 20. Reject if lower. Default to 50. Prevents single-word or short-phrase extraction that lacks context. Parse check: integer coercion succeeds.

[OUTPUT_SCHEMA]

JSON schema definition for the expected output structure

{"type":"object","properties":{"claim":{"type":"string"},"ranked_quotes":{"type":"array","items":{"type":"object","properties":{"quote_text":{"type":"string"},"source_doc_id":{"type":"string"},"relevance_score":{"type":"number"},"dedup_group":{"type":"string"}},"required":["quote_text","source_doc_id","relevance_score"]}}},"required":["claim","ranked_quotes"]}

Must be valid JSON Schema draft-07 or later. Reject if schema parsing fails. Required fields must include claim and ranked_quotes. Each ranked_quotes item must require quote_text and source_doc_id. Schema check: validate with ajv or equivalent validator before prompt assembly.

[CONSTRAINTS]

Additional behavioral constraints such as deduplication rules, provenance requirements, or abstention conditions

Deduplicate quotes with cosine similarity above [DEDUP_THRESHOLD]. Retain the longest version. Require source_doc_id for every quote. Return empty ranked_quotes array if no quote meets relevance threshold of 0.5.

Must be non-empty string. Should reference other placeholders like [DEDUP_THRESHOLD] explicitly. Reject if constraints contradict OUTPUT_SCHEMA required fields. Human review required for production constraint changes.

PRACTICAL GUARDRAILS

Common Failure Modes

Multi-document quote aggregation fails in predictable ways. These are the most common production failure modes and the guardrails that catch them before they reach users.

01

Near-Duplicate Quote Flooding

What to watch: Multiple documents contain semantically identical passages, and the aggregator returns all of them as separate evidence items. This inflates the evidence set with redundant quotes, wastes context budget, and misleads downstream components into over-weighting a single source that appears many times. Guardrail: Add a deduplication step that computes embedding similarity or normalized text hashes across extracted quotes. Set a similarity threshold (e.g., cosine ≥ 0.92) above which only the highest-authority or most complete variant is retained. Log dropped duplicates for audit.

02

Source Provenance Collapse

What to watch: Quotes are aggregated but their source document IDs, timestamps, or retrieval ranks are lost or mismatched. Downstream citation rendering breaks, audit trails become invalid, and users cannot verify where evidence came from. This is especially dangerous in regulated domains where every claim must be traceable to a specific document and section. Guardrail: Enforce a strict output schema where every quote object requires non-nullable source_id, document_title, retrieval_rank, and span_location fields. Validate schema compliance in the harness before quotes enter the aggregation pipeline. Reject any quote missing provenance.

03

Claim Drift During Aggregation

What to watch: The aggregator starts with a specific claim but gradually includes quotes that support a related but different claim. This happens when the prompt does not re-anchor to the original claim text, and the model follows semantic associations into adjacent topics. The resulting evidence set looks relevant but actually supports a shifted or diluted version of the original claim. Guardrail: Include the exact claim text as a required field in every aggregation step. Add a verification pass that scores each aggregated quote against the original claim using a separate alignment check. Discard quotes below a minimum relevance threshold and log claim-drift warnings.

04

Confidence Inflation on Weak Evidence

What to watch: The model assigns high relevance or support scores to quotes that are only tangentially related to the claim. This produces an evidence set that looks well-supported but crumbles under human review. Common with verbose documents where keyword overlap creates false signals. Guardrail: Calibrate relevance scoring with a few-shot rubric that includes examples of strong support, weak support, and irrelevant passages. Require the model to output explicit reasoning for each relevance score. Add a secondary LLM judge pass that samples and re-scores a subset of high-confidence quotes, flagging discrepancies for human review.

05

Silent Omission of Contradictory Evidence

What to watch: The aggregator selects quotes that uniformly support the claim while ignoring passages from the same documents that contradict or qualify it. This produces a biased evidence set that misrepresents the source material and creates overconfidence in downstream answers. Guardrail: Add an explicit contradiction-hunting instruction: require the prompt to search for and report evidence that weakens, contradicts, or limits the claim. Output contradictory quotes in a separate counter_evidence field. If contradictions exist but none are found, flag the aggregation for human review rather than presenting a one-sided evidence set.

06

Context Window Truncation of Long Quotes

What to watch: Documents contain long passages where the supporting evidence spans multiple paragraphs, but the aggregator truncates quotes to fit token limits, losing essential qualifiers, caveats, or context. The truncated quote appears to support the claim but the full passage would reveal important nuance. Guardrail: Set explicit minimum and maximum quote length constraints in the prompt. When a quote exceeds the maximum, require the model to include ellipsis markers and a truncated flag. Add a post-extraction check that verifies quote boundaries align with sentence or paragraph boundaries, not mid-sentence cuts. Flag truncated quotes for optional full-passage retrieval.

IMPLEMENTATION TABLE

Evaluation Rubric

How to test output quality before shipping the Multi-Document Quote Aggregation Prompt. Use these criteria to evaluate whether the aggregated evidence set is complete, deduplicated, and properly sourced.

CriterionPass StandardFailure SignalTest Method

Coverage Completeness

All [CLAIM] sub-components have at least one supporting quote from the [DOCUMENT_SET]

Output contains fewer distinct claim aspects than input claim decomposition; missing evidence for a verifiable sub-claim

Compare extracted quote count against a pre-computed claim decomposition; flag any sub-claim with zero supporting quotes

Near-Duplicate Deduplication

Semantically equivalent quotes from different documents are collapsed into a single entry with merged provenance

Output contains two or more quotes with cosine similarity above 0.92 and overlapping source spans; duplicate count exceeds 10% of total quotes

Run pairwise cosine similarity on extracted quote texts; count clusters above threshold; verify provenance merging in output

Source Provenance Completeness

Every extracted quote includes [DOCUMENT_ID], [SECTION_REF], and [RETRIEVAL_RANK] fields

Any quote object missing a required provenance field; null or empty string in provenance fields

Schema validation against required fields; sample 100% of output rows for provenance field population

Quote Relevance to Claim

All extracted quotes have a direct logical connection to [CLAIM]; no tangential or off-topic passages included

Human reviewer or LLM judge flags more than 1 quote as irrelevant; quote discusses a different topic than the claim

LLM-as-judge evaluation with a calibrated relevance rubric; spot-check 20% of quotes with human review

Redundancy Reduction Ratio

Output quote count is at least 40% lower than input passage count while preserving coverage

Output contains more than 60% of the original passage count without clear justification; near-duplicates not collapsed

Calculate reduction ratio: (input_passages - output_quotes) / input_passages; fail if below 0.4

Confidence Score Calibration

All assigned confidence scores fall within 0.7-1.0 for included quotes; low-confidence quotes are excluded or flagged

Quote included with confidence below 0.5; confidence scores are uniform without differentiation

Check min and distribution of confidence scores; verify exclusion of sub-0.5 quotes; compare against human confidence judgments on a held-out set

Output Schema Compliance

Output matches [OUTPUT_SCHEMA] exactly: correct types, no extra fields, no missing required fields

JSON parse failure; type mismatch on any field; missing required array or object structure

Automated schema validation against the defined JSON Schema; run on every output before downstream consumption

Cross-Source Conflict Flagging

When two sources contradict each other on a claim, output includes a conflict flag and both quotes

Contradictory quotes present without conflict annotation; one side of a known conflict silently dropped

Inject a test document pair with known contradiction; verify conflict flag presence and both quotes retained

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Multi-Document Quote Aggregation Prompt into a production application with validation, deduplication, and source tracking.

This prompt is designed to be called after retrieval, not as a standalone tool. The application layer must first gather candidate quotes from multiple documents using a retrieval pipeline (vector search, keyword search, or hybrid). The prompt then acts as a re-ranking and deduplication engine, consuming a batch of candidate quotes and producing a cleaned, ranked evidence set. The harness is responsible for assembling the input payload, enforcing the output schema, and deciding what to do when the model returns incomplete or low-confidence results.

The input payload should include the target claim in [CLAIM], an array of candidate objects in [CANDIDATE_QUOTES] (each with quote_text, source_document_id, source_span_start, source_span_end, and optional retrieval_score), and a [DEDUPLICATION_THRESHOLD] for near-duplicate detection. The output schema must be enforced at the application level: expect a JSON object with a ranked_quotes array, where each entry contains quote_text, source_document_id, source_span, relevance_score (0-1), is_near_duplicate_of (nullable, referencing another quote ID), and deduplication_rationale. Validate that every returned quote maps back to a provided candidate, that relevance scores are within range, and that deduplication references are self-consistent. If the model returns quotes not present in the input, discard them and log a grounding failure.

For production wiring, implement a retry loop with a maximum of two attempts. On the first failure (malformed JSON, missing fields, or invalid scores), send the raw output and validation errors back to the model in a repair prompt. If the repair also fails, fall back to a deterministic deduplication method (e.g., cosine similarity on embeddings) and return the unranked deduplicated set with a warning flag. Log every aggregation call with the claim hash, input quote count, output quote count, deduplication rate, and any repair attempts. For high-stakes domains like legal or compliance, route outputs with low average relevance scores (below 0.5) or high deduplication rates (above 50%) to a human review queue before the evidence set is used downstream.

Model choice matters here. Use a model with strong instruction-following and JSON output capabilities (GPT-4o, Claude 3.5 Sonnet, or equivalent). Avoid smaller models for this task because near-duplicate detection across document boundaries requires semantic comparison that degrades quickly with weaker models. If latency is critical, consider batching: split large candidate sets (over 20 quotes) into overlapping windows of 10-15 quotes, aggregate independently, then run a final deduplication pass across windows. Always include the source_document_id in every output record—this is non-negotiable for audit trails and downstream citation rendering.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single document source. Remove deduplication logic and source provenance tracking. Focus on quote extraction and relevance scoring only. Use a simple JSON output schema with quotes array containing text and score fields.

code
Extract supporting quotes from [DOCUMENT] for this claim: [CLAIM].
Return JSON: {"quotes": [{"text": "...", "score": 0.0-1.0}]}

Watch for

  • Near-duplicate quotes inflating evidence counts
  • Missing source attribution when you add more documents later
  • Overly broad relevance scoring without calibration against human judgments
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.