RAG · advanced
Multi-document compare-and-contrast
Synthesize three vendor quotes into a table plus a one-paragraph recommendation.
Procurement task: a buyer has three vendor proposals and wants a side-by-side comparison they can hand to their manager.
The prompt
Copy this verbatim. Replace the {{ … }} placeholders with your values.
<documents>
<document>
<source>doc-1: vendor-A-quote.pdf</source>
<document_content>{{ vendor_A_text }}</document_content>
</document>
<document>
<source>doc-2: vendor-B-quote.pdf</source>
<document_content>{{ vendor_B_text }}</document_content>
</document>
<document>
<source>doc-3: vendor-C-quote.pdf</source>
<document_content>{{ vendor_C_text }}</document_content>
</document>
</documents>
<instructions>
Compare the three vendor quotes. Produce:
1. A Markdown table with columns: Vendor, Price (USD), Support Tier, Notable Caveats.
Cite each cell with [doc-N].
2. A one-paragraph recommendation citing sources in [doc-N] format.
Rules:
- If a field is missing in a quote, write "not specified" — do not infer.
- Do not estimate prices that aren't stated.
- Keep tone neutral; no superlatives unless directly supported by a source.
</instructions>
Sample input
Three short PDF-extracted quotes from vendors A, B, C with prices, support tiers, and various caveats.
Expected output
A markdown table followed by a 4-sentence recommendation, all cells and claims tagged with [doc-1] through [doc-3].
Notes & tuning tips
- When passages are long (>5k tokens each), summarize them in a first pass and synthesize on the summaries.
- Citations only help if your source IDs map back to retrievable files. Use stable IDs.
- If you want a specific recommendation framing (cheapest, best-support, lowest-risk), spell it out in instructions.
What this example uses
Tags: <documents> <document> <source> <instructions>
Patterns: multi document
More like this
rag
RAG over docs with [doc-N] citations
Answer a question from retrieved passages and cite every claim by source ID.
ragHallucination guard: refuse when answer isn't in sources
Force a clean refusal when retrieval comes up empty instead of confabulating.
Cite this page
Multi-document compare-and-contrast. claudexml.com. https://claudexml.com/examples/multi-doc-compare/