AI Document Comparison: Next Level PDF Document Analysis with Power Automate and AI Builder

30 Jan, 2024 | 5 minutes read

Efficiency is the cornerstone of operational success, especially regarding the intricate task of PDF document comparison. In today’s fast-paced business world, where every second counts, the strategic utilization of tools is essential. The digital age highlights the importance of solutions focusing on customers, where personalized communication is key to success. Our solution centers on making the PDF document comparison process simpler and more effective, a crucial element in various business workflows. Many times, companies need to compare two documents for similarities or differences. This is a great way to avoid manual document comparison since it can compare two documents or however many you want in any format. 

Let’s dive into a real-world use case from the insurance industry we recently faced. Consider a scenario where there are three distinct document types, referred to in this study as Document A, Document B and Document C. The goal is to compare Document A with Document B and then with Document C. Sounds simple enough. You need to compare three documents. However, the challenge intensifies due to the diverse document structures expected for each document type – almost 1000 different combinations overall. So, while a solution like AI Builder’s custom model might seem suitable for such a scenario, the number of various document structures that must be considered during the training of the models dramatically increases the required time to develop the document comparison solution. Many document comparison solutions are already available in the current market, in the form of tools like Draftable, Diffchecker and Araxis to name a few. However, these tools fall short in providing the requisite variety of features essential for addressing the intricacies inherent in such complex scenarios.

Enter AI Builder GPT Prompt, a powerful tool that reshapes how we extract data from documents. Unlike traditional approaches requiring training multiple models with various examples, AI Builder GPT Prompt proves to be a simpler and quicker solution. By leveraging its capabilities with Power Automate, we can streamline this complex process and generate an output spreadsheet highlighting the differences between each document pair. In this exploration, we spotlight how these advanced tools, particularly AI Builder GPT Prompt, revolutionize the landscape of document comparison, providing a swift and efficient solution to intricate challenges. AI technology helped us perform next-level PDF analysis and find similarities and differences. 

How does AI-powered document comparison work?

The Power Automate solution begins with a trigger activated when a file of type A is created, setting the stage for subsequent actions. The process proceeds by extracting text from PDF documents for all three document types, labeled as A, B, and C. Subsequently, the ‘Create text with GPT using a prompt’ action extracts essential information from each document. This is where the GPT Prompt comes into play:

“Can you extract the following fields <fieldValues> as key-value pairs and the following fields <fieldTables> as tables from the following text <fullText>. Output just the extracted data in JSON format.”

In this context, <fieldValues>, <fieldTables>, and <fullText> serve as arguments that will be supplied from the flow’s context. The <fullText> argument represents the text extracted from PDF documents, while <fieldValues> and <fieldTables> denote the fields and tables to be extracted, respectively.

The prompt was crafted to extract specific information from a given text efficiently, adhering to prompt engineering guidelines prioritizing clarity, context, and well-defined expectations. In addition to this, we ensured the prompt’s versatility, making it generic enough to accommodate various document structures. We fine-tuned the prompt to refine its capabilities further, optimizing performance for our specific document extraction needs. Undoubtedly, as we encounter different documents during testing and grow more comfortable with the technology, there will be ongoing fine-tuning to enhance the prompt’s adaptability and effectiveness.

Going back to the Power Automate flow, a comparison between the outputs of document types A and B is performed once the extraction output is received, using a mapping file to identify corresponding fields. This mapping approach ensures the adaptability of the flow to varying document structures in the future, enhancing its reusability and scalability, which is crucial in a scenario with a wide variety of documents. Although this solution is designed to extract text from PDF documents, it can easily be adjusted to different document types, such as Word, Excel, etc. The same methodology is applied to compare the output of document type A with document type C. The final result is an Excel file highlighting unmatched fields and a status report email notifying specified email addresses of the successful completion of the process.

Please refer to the accompanying diagram (figure 1) to gain a clearer insight into the flow.

Insurance document comparison flow diagram

Figure 1. Insurance document comparison flow diagram

The possibilities, challenges and areas of improvement when comparing multiple documents 

When utilizing AI Builder GPT Prompt in our scenario, it is paramount to acknowledge the remarkable advantages it brings to the table. For starters, using this technology has significantly reduced the development time required for our solution. Unlike the intricate process of training custom models, the versatility of GPT prompts allows for streamlined development, easily adapting to various document structures while using our document comparison feature. This accelerates the implementation process and ensures adaptability without the need for extensive model training.

In addition to this, the technology’s robust underlying model ensures that the extracted information is consistently accurate, meeting the demands of our document extraction requirements with a high degree of precision. While testing our solution, we observed an accuracy of about 92.65%. Still, this percentage will likely change once we receive a greater variety of documents and fine-tune our prompt to fit our needs better.

However, venturing into the AI Builder GPT Prompt realm has its challenges. Being a relatively new technology, its usage brings uncertainties and a limited corpus of online information about potential issues and solutions. The constant evolution of this technology also introduces the need for adaptation to changes in document comparison features, emphasizing the importance of staying informed and agile in our approach.

It is also important to note that currently, a crucial aspect of applying AI Builder GPT Prompt is the importance of human review. This is particularly evident in addressing challenges such as prompt injection attacks and potential information fabrication by AI models. Prioritizing responsible AI practices, including rigorous testing, careful prompt examination, and a robust system of human oversight, is essential. These practices not only protect against potential risks but also emphasize our commitment to responsible AI integration in our document comparison workflow.

Conclusion

In conclusion, our journey with AI Builder GPT Prompt leads us to the intersection of innovation and responsibility. We commit to an ongoing improvement journey as we appreciate its benefits and tackle challenges. We are excited to witness the technology’s growth and the myriad possibilities it brings regarding document comparison and automated document comparison, to be more specific, in combination with AI and power automation.