This prompt is designed for a specific job-to-be-done: generating a structured, side-by-side markdown comparison table from a set of retrieved documents. The ideal user is a product team, analyst, or engineer building a RAG pipeline where a user asks to compare two or more entities—such as software frameworks, vendors, protocols, or product tiers—and the system must produce a decision-support artifact. The core requirement is that every cell in the generated table must be directly traceable to source evidence, making the output auditable and defensible. This is not a prompt for generating subjective opinions or creative comparisons; it is a tool for synthesizing documented facts into a structured format that fits into comparison UIs, dashboards, or analyst briefs.
Prompt
Comparison Table Prompt for Retrieved Evidence

When to Use This Prompt
Defines the ideal job-to-be-done, user, and required context for the comparison table prompt, and clarifies when not to use it.
Use this prompt when your application has successfully retrieved a set of documents that contain comparable information about the entities in question. The prompt assumes that the retrieval step has already occurred and that the provided context contains sufficient evidence to populate the requested comparison dimensions. It works best when you can supply a clear list of dimensions (e.g., 'Pricing Model', 'Security Certifications', 'API Limits') and a defined output schema. The prompt is particularly effective when paired with a validation layer that checks for missing cells, unsupported claims, and false equivalences before the table reaches the user. For high-stakes domains like vendor due diligence or compliance comparisons, you should always route the generated table through a human review step and log the source evidence for each cell.
Do not use this prompt when the retrieved evidence is insufficient to populate the requested dimensions, or when the comparison requires subjective judgment beyond what the documents support. If the source documents lack comparable data points, the model may hallucinate to fill gaps or create false equivalences. In these cases, the system should either abstain from generating the table, flag missing dimensions explicitly, or trigger additional retrieval. This prompt is also not suitable for generating real-time pricing comparisons, live inventory checks, or any data that requires API calls to external systems—it operates strictly on the provided context. For comparisons that require numerical analysis or calculations (e.g., total cost of ownership over time), pair this prompt with a tool-use step that performs the computation separately and injects the results into the context before table generation.
Use Case Fit
Where the Comparison Table Prompt delivers reliable, grounded output and where it introduces unacceptable risk. Use these cards to decide if this prompt fits your evidence, workflow, and tolerance for error.
Good Fit: Multi-Option Analysis
Use when: you need to compare 2–5 options across consistent dimensions from retrieved documents. Why: the prompt excels at extracting parallel attributes and aligning them into a table. Guardrail: pre-define the comparison dimensions in the prompt schema to prevent the model from inventing its own axes.
Bad Fit: Single-Entity Deep Dive
Avoid when: the task is to analyze one product, protocol, or vendor in depth. Why: the comparison structure forces false equivalences or creates empty cells. Guardrail: route single-entity analysis to a dedicated diligence prompt, not a comparison table.
Required Input: Dimension Schema
Risk: without explicit comparison dimensions, the model selects arbitrary or surface-level attributes. Guardrail: provide a fixed list of dimensions (e.g., 'Pricing Model', 'Data Residency', 'SOC 2 Status') in the prompt's [DIMENSIONS] variable. Validate that every cell maps to a provided dimension.
Required Input: Source-Aligned Evidence
Risk: the model hallucinates comparisons when evidence is missing or uneven across options. Guardrail: only pass retrieved chunks that explicitly mention the options being compared. Implement a pre-check that each option has at least one evidence chunk before calling the prompt.
Operational Risk: False Equivalence
Risk: the table format implies options are comparable even when they serve different use cases or operate at different scales. Guardrail: add a 'Comparability Caveat' row or footnote field in the output schema. Use an eval to detect when the model fails to flag incommensurate comparisons.
Operational Risk: Stale Evidence Drift
Risk: comparison tables embedded in UIs or docs go stale as source documents update. Guardrail: attach a 'Generated At' timestamp and source document version to every table. Build a regeneration trigger that fires when underlying documents change.
Copy-Ready Prompt Template
A reusable prompt template for generating comparison tables from retrieved evidence with source grounding per cell.
This template produces a markdown comparison table from retrieved documents. It forces the model to extract dimensions, populate cells with evidence-backed values, and cite sources per cell rather than per row or per answer. Use it when you need side-by-side analysis of options, products, protocols, or approaches where each claim must be traceable to a specific passage. The template includes placeholders for your retrieved context, comparison subjects, output constraints, and evaluation criteria.
codeYou are a precise comparison analyst. Your task is to generate a comparison table from the provided evidence only. ## INPUTS - Retrieved Evidence: [RETRIEVED_DOCUMENTS] - Subjects to Compare: [COMPARISON_SUBJECTS] - Comparison Dimensions: [DIMENSIONS] - Output Format: [OUTPUT_FORMAT] - Constraints: [CONSTRAINTS] ## INSTRUCTIONS 1. Extract comparison dimensions from [DIMENSIONS]. If not provided, infer the most relevant dimensions from the evidence. 2. For each subject in [COMPARISON_SUBJECTS] and each dimension, populate the cell using only information present in [RETRIEVED_DOCUMENTS]. 3. For every cell, include a source citation in the format [Source: document_id, section/paragraph]. If multiple sources support a cell, cite the most specific one. 4. If evidence is missing for a cell, enter "No evidence found" and do not fabricate. 5. If evidence conflicts across sources for a cell, note the conflict: "Conflicting evidence: [summary]" with citations for both sources. 6. Do not add dimensions, subjects, or values not present in the evidence. 7. Do not summarize, recommend, or draw conclusions. Produce only the comparison table. ## OUTPUT SCHEMA Generate a markdown table with: - Header row: Dimension | [Subject 1] | [Subject 2] | ... - One row per dimension - Each cell contains: value + source citation - After the table, add a "Coverage Notes" section listing any dimensions where evidence was missing or conflicting. ## EXAMPLE OUTPUT STRUCTURE | Dimension | Subject A | Subject B | |-----------|-----------|----------| | Price | $10/user/month [Source: doc_3, para 12] | $15/user/month [Source: doc_7, para 4] | | Uptime SLA | 99.9% [Source: doc_3, para 18] | No evidence found | ## CONSTRAINTS - [CONSTRAINTS] - Maximum table width: [MAX_COLUMNS] subjects - Maximum dimensions: [MAX_DIMENSIONS] - If evidence exceeds [MAX_TOKENS], prioritize the most recent and authoritative sources.
Adapt this template by replacing each square-bracket placeholder with your specific inputs. For [RETRIEVED_DOCUMENTS], include document IDs or chunk references so citations are traceable. For [DIMENSIONS], provide an explicit list when you need consistent comparisons across multiple runs; omit it when you want the model to discover dimensions from evidence. The [CONSTRAINTS] field should include domain-specific rules such as 'prefer GA features over beta', 'use list prices not negotiated rates', or 'flag deprecated versions'. Always test with a golden set of documents where you know the correct comparison values before deploying. If the output will feed into a UI component, add a [OUTPUT_SCHEMA] that specifies exact field names and types for programmatic consumption.
Prompt Variables
Required and optional inputs for the comparison table prompt. Validate each variable before assembly to prevent runtime failures and hallucinated dimensions.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[RETRIEVED_CONTEXT] | Source documents or passages containing the entities and attributes to compare | Chunks from product datasheets, API docs, or competitor pages | Must be non-empty array of strings. Reject if all chunks are under 50 tokens combined. Check for duplicate passages. |
[ENTITIES_TO_COMPARE] | The specific items, products, or options the user wants compared | Product A vs Product B; Python 3.11 vs 3.12; Vendor X, Vendor Y, Vendor Z | Must contain at least 2 distinct entities. Normalize names to avoid fuzzy matching failures. Reject single-entity requests. |
[COMPARISON_DIMENSIONS] | The attributes, features, or criteria to compare across entities | Pricing, latency, SLA, supported regions, compliance certifications | Must be explicit list. If null, prompt should infer from context. Validate inferred dimensions against evidence coverage before table generation. |
[OUTPUT_SCHEMA] | Expected structure for the comparison table output | Markdown table with columns for dimension, entity values, source citations, and confidence | Must specify required columns and cell format. Reject outputs missing source citations per cell. Schema check before returning to caller. |
[CONSTRAINTS] | Rules for evidence use, missing data handling, and output boundaries | Only use retrieved context; mark missing data as 'Not found in sources'; no external knowledge | Must include evidence boundary rule. Validate output does not contain facts absent from [RETRIEVED_CONTEXT]. Flag violations for human review. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score for including a dimension-value pair in the table | 0.7 on a 0-1 scale; 'high' for regulated domains | If below threshold, cell must display 'Insufficient evidence' or trigger abstention. Threshold should be adjustable per domain risk profile. |
[MAX_DIMENSIONS] | Upper limit on number of comparison dimensions to prevent table bloat | 10 for UI display; 20 for detailed reports | Truncate to top-N dimensions by evidence strength if count exceeds limit. Log dropped dimensions for review. Never fabricate to fill rows. |
[CITATION_FORMAT] | How source references appear in table cells | Inline [DocID, Section]; footnote markers; hyperlinked source names | Must match downstream UI or document format. Validate every citation resolves to a passage in [RETRIEVED_CONTEXT]. Broken citations fail eval. |
Implementation Harness Notes
How to wire the comparison table prompt into a reliable application pipeline with validation, retries, and human review.
The comparison table prompt is not a standalone artifact—it is a component inside a larger RAG pipeline. Before the prompt executes, your application must retrieve and deduplicate evidence chunks, assemble them into the [CONTEXT] placeholder, and decide whether enough evidence exists to attempt a comparison. After the prompt returns a markdown table, the application must validate the output, handle failures, and route the result to the correct downstream consumer, whether that is a UI component, an API response, or a human review queue.
Wire the prompt into a structured workflow with clear pre- and post-processing steps. On the input side, implement a context gate that checks whether the retrieved evidence contains at least two distinct entities to compare and covers the requested dimensions. If the gate fails, return a controlled abstention response rather than forcing the model to fabricate a comparison. On the output side, parse the markdown table into a structured object that your application can validate. Check for: (1) dimension coverage—does the table include all requested comparison dimensions? (2) evidence alignment—does each cell contain a source citation or reference? (3) false equivalence detection—are two options presented as comparable when they operate at different abstraction levels or scopes? (4) schema compliance—does the output match the expected column structure and data types? Run these checks programmatically before the response reaches a user.
For production reliability, implement a retry-and-escalate pattern. If validation fails on dimension coverage or schema compliance, retry the prompt once with the validation errors appended to the [CONSTRAINTS] placeholder. If the second attempt also fails, escalate to a human review queue with the original context, the failed output, and the specific validation errors. Log every comparison request with the prompt version, model, retrieved context IDs, output table, validation results, and escalation decision. This trace data is essential for debugging dimension drift, evidence gaps, and model behavior changes across prompt iterations. For high-stakes domains—such as vendor selection, clinical comparisons, or compliance decisions—require human approval before the comparison table is consumed by downstream systems or shown to end users.
Common Failure Modes
Comparison tables generated from retrieved evidence often fail in predictable ways. These cards cover the most common failure modes and the specific guardrails to prevent them.
False Equivalence
What to watch: The model creates a row-by-row comparison that implies two options are equally valid when the evidence strongly favors one. This often happens when the prompt forces symmetry. Guardrail: Add a [DOMINANT_OPTION] field to the output schema and instruct the model to declare if one option is clearly superior based on the evidence.
Missing Dimension Coverage
What to watch: The generated table omits a critical comparison dimension because it was not explicitly present in the retrieved chunks, even if it is a standard dimension for the domain. Guardrail: Provide a [REQUIRED_DIMENSIONS] list in the prompt. If evidence for a required dimension is missing, the model must fill the cell with 'Insufficient evidence' rather than dropping the row.
Hallucinated Cell Values
What to watch: The model fills a table cell with a plausible but fabricated value when the source evidence is silent on that specific intersection. This is the most dangerous failure mode for decision-support tables. Guardrail: Enforce a strict 'No evidence, no entry' rule. Every cell must contain an inline citation tag like [src: chunk_id]. Post-process the output to strip any cell lacking a citation.
Temporal Context Collapse
What to watch: The evidence contains data from different time periods (e.g., Q1 vs. Q4 pricing), but the table presents values as if they are concurrently true, creating a misleading comparison. Guardrail: Add a [TEMPORAL_SCOPE] constraint to the prompt. Require the table to include a 'Valid As Of' column or to discard evidence outside a specified date range.
Schema Drift Under Retrieval Gaps
What to watch: When the retriever fails to find evidence for one of the entities being compared, the model often changes the table structure (e.g., dropping a column) to compensate, breaking the downstream parser. Guardrail: Use a strict [OUTPUT_SCHEMA] with a fixed number of columns. Instruct the model to keep the column and fill all cells with 'NO_DATA' if an entity is missing from the retrieved context.
Narrative Bias in Row Headers
What to watch: The model generates subjective or leading row headers (e.g., 'Superior Performance' instead of 'Performance') based on the tone of the source evidence, turning the comparison into an editorial. Guardrail: Provide a controlled vocabulary for dimension names in the prompt. Use a post-generation validator to flag any row header that contains adjectives or sentiment-bearing words not present in the approved list.
Evaluation Rubric
Use this rubric to test the comparison table prompt before shipping. Each criterion targets a specific failure mode common in evidence-synthesis tasks. Run these checks against a golden dataset of 10-20 document sets with known comparison dimensions.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Dimension Coverage | All comparison dimensions present in source documents appear in the table. No fabricated dimensions. | Missing a dimension that exists in at least one source document. A dimension appears that has zero supporting evidence across all sources. | Parse table headers. Compare against a pre-labeled set of expected dimensions from the golden dataset. Flag missing and extra dimensions. |
Evidence Alignment Per Cell | Every cell value is directly supported by at least one retrieved passage. No hallucinated values. | A cell contains a claim, number, or feature that cannot be traced to any passage in the provided context. | For each cell, run an NLI model or LLM-as-judge check: does the cell content logically follow from the cited passage? Flag cells with no supporting passage. |
Source Citation Completeness | Every row has a citation for each cell, or a single row-level citation covering all cells. Citations map to valid passage IDs. | A row or cell has no citation. A citation references a passage ID not present in the provided context. | Parse citations from the output. Validate each citation ID against the input passage list. Flag rows with zero citations. |
False Equivalence Detection | The table does not imply two options are comparable on a dimension when source evidence is missing for one side. | A row compares Option A and Option B on a dimension where only one option has evidence. The empty cell is filled with a guess or misleading placeholder. | For each row, check if both compared entities have at least one cited passage. Flag rows where one entity has zero evidence for that dimension. |
Schema Compliance | Output is valid markdown with exactly the requested table structure. No extra commentary before or after the table. | Output includes conversational text, disclaimers, or markdown elements outside the table. Table has inconsistent column counts. | Validate markdown table syntax. Check column count consistency across all rows. Assert output starts and ends with table markdown. |
Abstention on Missing Data | Cells where no evidence exists contain an explicit indicator such as 'Not specified' or 'No data'. No fabricated content. | An empty cell is filled with plausible-sounding but unsupported content. A missing-data cell is left blank without explanation. | Search output for common abstention markers. For cells without citations, verify the content is an abstention string, not a claim. Flag blank cells. |
Row Label Specificity | Row labels are specific and distinguishable. No two rows have identical or near-identical labels. | Two rows describe the same dimension with slightly different wording, causing duplication. Row labels are vague like 'Feature 1'. | Extract all row labels. Check for exact duplicates and near-duplicates using cosine similarity on embeddings. Flag pairs above 0.85 similarity. |
Confidence Indicator Accuracy | If the prompt requests confidence scores, high-confidence cells have multiple corroborating passages. Low-confidence cells have thin or conflicting evidence. | A cell with a single weak passage gets a high confidence score. A cell with conflicting evidence gets a high confidence score. | For cells with confidence scores, count the number of supporting passages and check for conflicts. Flag mismatches between evidence quantity/quality and confidence level. |
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 frontier model (GPT-4o, Claude 3.5 Sonnet). Accept raw markdown output without strict schema validation. Focus on getting the comparison structure and source grounding right before adding production constraints.
Prompt modification
- Remove or soften [OUTPUT_SCHEMA] constraints; accept any markdown table
- Set [CONSTRAINTS] to minimal: "Cite sources per cell. Flag missing evidence."
- Use a small [CONTEXT] with 2-3 documents to test dimension extraction
Watch for
- Missing source citations in individual cells
- False equivalence when evidence is thin on one side
- Dimension drift where the model invents comparison axes not in the evidence

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