View this page in the latest version of Appian. Compare Multiple Documents Share Share via LinkedIn Reddit Email Copy Link Print On This Page When comparing multiple documents, the right approach depends on the size of the documents and the type of comparison you need. While a simple pair of invoices might only need a quick check of specific numbers, a set of long contracts requires a deeper search to find and compare the meaning of specific clauses. Use this recipe to: Select a comparison method based on document size and data structure. Automate validation tasks, such as cross-referencing a sales quote with a purchase agreement. Establish a transparent audit trail for document discrepancies. Note: If you're using plug-ins to convert documents from one format to another, refer to that plug-in's documentation in its AppMarket listing for more information. Comparison methods There are two ways to compare extracted values: logical operators in Appian expressions and AI-powered semantic matching. You can use one or both in the same workflow. Method Use case Requirements Logical operators in Appian expressions Strict, exact matches. For example, matching a quote total to a purchase order total. Data must be in a structured format, such as records or JSON. AI-powered semantic matching Fuzzy matching and reasoning. For example, "Net 30" compared to "Due in 30 days". Requires a Prompt Builder AI skill. When to use logical operators Use Appian expressions when values must match exactly, or when you need greater-than or less-than comparisons. This works when the data is already structured or can be converted to structured data, and when strict compliance requirements exist. When to use AI semantic matching Use a Prompt Builder AI skill or smart search when documents contain unstructured data, when human-like reasoning is required, or when values are similar but not exact. Design patterns Choose a design pattern based on the volume of data and the level of reasoning required. Design pattern 1: merge small documents Best for the simplest use cases and smallest PDF documents. Merge documents into a single PDF using an Appian plug-in and pass the combined document through a single AI skill for holistic analysis. All document content is included in the AI context window, and only one AI execution is required. Trade-offs: Troubleshooting becomes more complex since the entire process runs as a single step. The AI cannot distinguish document boundaries, potentially reducing comparison accuracy. Large or high-resolution PDFs may impact heap memory performance. Design pattern 2: field extraction + downstream comparison Best for medium sized documents focused on key-value pair or structured data comparison. Extract fields from each document individually, then run a downstream comparison. This approach can use DocCenter for both extraction and classification, and is easier to debug since the process is broken into multiple steps. Extract relevant fields: Use an extraction model to pull data from each document and convert it to structured data. Compare extracted data: Run a downstream Prompt Builder AI skill or use Appian expressions for logical comparisons. Trade-offs: Multiple processing steps create additional failure points that require individual monitoring and error handling. Design pattern 3: semantic retrieval + downstream comparison Best for large documents and semantic comparisons that analyze the meaning of the content. Use smart search to retrieve relevant content from each document, then run a downstream comparison. This approach scales well and is easier to debug since the process is broken into multiple steps. Classify the document type (optional): Use the classification model to identify the document category. Retrieve relevant content: Use smart search and query filters to pull back raw content from relevant documents. Compare retrieved content: Run a downstream Prompt Builder AI skill to analyze and validate the content. Trade-offs: Retrieval strategy must balance comprehensiveness with AI context limits to avoid overwhelming the model. Logical comparisons are not possible since this pattern works with unstructured text rather than structured data. Multiple processing steps create additional failure points that require individual monitoring and error handling. Implementation Completed in: prompt builder To illustrate AI-driven document comparison, consider the following scenario: a company receives a sales quote and a purchase agreement and needs to validate key details. The total price must match the contracted amount, and payment terms must be consistent across both documents. In this example, fields are extracted using extraction model (design pattern 2). For the total price comparison, logical operators handle the exact match. The following prompt shows how a downstream Prompt Builder AI skill can conduct the payment terms analysis. Sample prompt for document comparison 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 <role> You are an AI assistant comparing a sales quote and a purchase agreement. </role> <steps> 1. You will be provided the extracted key value data from each document type. 2. Extract key details based on the checklist provided below. 3. Compare extracted values and determine if they match. 4. Flag any discrepancies. </steps> <quoteData> { 'paymentTerms': 'Net 30' 'quoteNumber: '28374' 'isSigned: TRUE } </quoteData> <purchaseAgreementData> { 'paymentTerms': '30 Days After Invoice' 'isSigned': TRUE 'items': [] } </purchaseAgreementData> <checklist> 1. Confirm payment terms match. 2. <additional checks to perform> 3. <additional checks to perform> </checklist> <response> Output results in JSON format: [ { "checklistItemId": "" (integer | primary key of the check), "flagNotes": "" (text | thought process or analysis), "isFlagged": "" (boolean | TRUE if check passes) } ] </response> Test it out Configure an extraction model for each document type. Map the extracted fields to process variables so the data is available for comparison. Add an Execute Generative AI Skill smart service to your process model and pass the extracted data into a Prompt Builder AI skill for semantic comparisons. For exact-match fields, use logical operators in an XOR gateway. Add a Write Records smart service to save the comparison results, including any flagged discrepancies and the AI's reasoning, to a record type. Considerations Consider the following when building a document comparison workflow. Data normalization. Standardize values like date formats and currency symbols into consistent formats before comparison. Consider matching field names across document types, such as totalCost and totalDue, so the AI or logical operators can compare them directly. Missing data. Instruct the AI to return null when a value is missing or ambiguous. This reduces false positives and prevents hallucinations during the comparison phase. Memory for merged documents. For design pattern 1, monitor the impact on heap memory when processing multiple high-resolution PDFs. Consider the total file size before merging. Feedback Was this page helpful? SHARE FEEDBACK Loading...