A fresh take on risk and valuation

Start receiving our RegBrief straight to your inbox!


Subscribe

Back
Article

Process Automation in Insurance Blog post series #2: Automation of financial reporting with Python and AI

Bence Zaupper
Managing Consultant - Expert in BMA, Solvency II / ICS / Market Risk / Actuarial and Risk Modelling / Internal Models Approval and Validation / Risk Appetite

Bence is a senior actuary with 20+ years of experience in life actuarial science and reporting in Solvency II, IFRS, BMA EBS and ICS regulations. His focus has been on actuarial and risk modelling - including capital projections, market risk management and internal model validation – and ERM framework design. Bence delivers business transformation, reinsurance, new authorisation and M&A projects and is keen on applying machine learning and data analytics for actuarial use cases.

Introduction

This article presents a case study on how insurance reporting can be revolutionised with Python and AI via automation.

Financial reporting in insurance is the process of documenting and communicating the financial position and profitability of the company over specific periods, typically on a quarterly or yearly basis. Insurance companies must prepare a range of reports across multiple accounting standards and regulatory regimes causing significant overhead.

Despite the high volume and complexity of reporting, most companies adopted a manual workflow consisting of spreadsheets and text editors such as MS Excel and Word. This approach is error prone, inefficient and requires excessive effort.

Process automation offers an opportunity to reduce the time spent on preparing financial reports and free up time for more value-adding analysis.

The interactive application we built for this case study performs the end-to-end solvency reporting process instantly and generates a validation report to verify the internal consistency of the results. Also, it enables the user to use AI to write commentary on the results, further reducing the effort.

Manual spreadsheet based processes

A spreadsheet-based reporting process creates a significant operational burden, requiring manual tasks such as transferring data, updating tables and charts, inserting them into reports, and adding commentary. While these tools are flexible and intuitive, enabling collaboration within and across departments, using them as part of a reporting process is time-consuming and risky.

Performing calculations in spreadsheets and manually copying over result summaries (tables and charts) to text editors can become inefficient, diverting time away from strategic and value-adding analysis. Multiple iterations of checks and review cycles further exacerbate inefficiencies, while the inability to perform real-time updates can delay decision-making.

The growing complexity of the reporting landscape compounds these challenges. Recent examples include the introduction of IFRS 17 for insurance accounting or the review of the Solvency II prudential regime. Simultaneous regulatory and internal reporting under tight deadlines adds pressure, increasing the risk of inconsistent results, missing deadlines, or strained relationships with the regulator.

Automating reporting processes is essential to reduce costs, improve efficiency and accuracy.

Automated reporting process

Several toolkits are available for process automation. We selected Python, an open-source general purpose programming language that enables the automation of end-to-end workflows from data imports and transformations to performing complex calculations and generating reports.

We used the following libraries for data analysis:

  • Pandas                Data imports and manipulations
  • Matplotlib          Data visualisation, charts

Other libraries were applied to generate HTML, PDF and MS Word reports:

  • HTML
    Python supports the creation of HTML reports via program code which can be accessed in a browser. Users have control over the design of their reports via program code and can embed tables, charts and text into their reports. The jinja2 library enables the creation of reusable HTML reporting templates to offer greater adaptability and efficiency.
  • PDF      
    The pdfkit library allows quick conversion of HTML reports into pdf files while preserving the format. It requires the installation of a free tool called wkhtmltopdf outside of Python.
  • MS Word           
    The python-docx library can be used to convert HTML files to MS Word reports. Using Word outputs makes the report editable and easily accessible.

Finally, we used the following libraries to create the interactive app and to connect to AI powered chatbots for text generation and reasoning:

  • streamlit                           Interactive app with real-time updates triggered by user inputs
  • openai                              Connect to ChatGPT via Python to generate report commentary
  • google.generativeai        Connect to Gemini via Python to generate report commentary

We used a free version of Gemini (v1.5-pro) and a chargeable version of ChatGPT (v3.5-turbo) via an API which means that they run in the cloud on the provider’s systems. The app enables the user to choose between the two models or turn off AI commentary.

Figure 2 shows the end-to-end report automation process powered by Python and AI.

For our case study we used a brief, two pages report that summarises the solvency position of a hypothetical company under Solvency II, the prudential regime applicable for insurers in the European Union.

The original report was created in Word and included a table, two charts and was divided into two sections and the first section to three subsections. The underlying result tables and charts were created in Excel and copied over to Word mimicking a manual spreadsheet based process.

As part of the automation, we created layout files in HTML for the solvency report and the validation report. This took a bit of time, but it is a once-off effort that enables repeating the process in future reporting periods instantly. The new automated Python based process uses the Excel table as the single input and performs the following ten steps in one second:

  1. Import the Excel table into Python
  2. Create charts
  3. Perform interim calculations for report commentary
  4. Perform validation of the result inputs for internal consistency
  5. Update layout file based on the results
  6. Create wording for movement analysis with Python code
  7. Generate report commentary and movement analysis using AI via an API
  8. Insert commentary to the report based on the user’s choice (program code or AI generated)
  9. Export solvency report in three formats (.html, .pdf and .docx)
  10. Export validation report in two formats (.html and .pdf)

The initial effort invested in designing the layout and program code pays off quickly as a repeatable, automated process is created that generates the reports for each period in an instant. The validation report uses colour codes, flags any inconsistencies clearly with red colour above a prespecified threshold (all specified in the Python code).

Please click on the links below to take a look at the reports generated:

To make the code accessible for users without programming knowledge, we created an interactive Streamlit application in Python to run the process. The app runs in browser and all you need to do is to specify your choices in the sidebar on the left hand side and press the “Generate Report” button on the top. The inputs in the sidebar are:

  • Reporting period
  • Target solvency ratio
  • If AI should be used to generate commentary and if yes:
    • API to be used for AI commentary (ChatGPT or Gemini)
    • Desired length of Background section
  • Optional text to be added to the Conclusion section at the end of the report (e.g. if solvency falls below target)

The screenshot of the application is shown on Figure 3 below.

Benefits and risks of AI commentary

Obviously, the comfort of using AI commentary poses risks as well.  Overreliance on AI generated wording can be problematic. Also, the response depends on the prompt given and may be inaccurate. For example, it took a few iterations for us to refine our prompt for the movement analysis via the Python code. Originally the AI generated text referred to diversification or BSCR as individual risks or Deferred Tax Adjustment as a BSCR component, both are incorrect. But once the prompt included an explanation of the SCR components, the AI generated movement analysis was accurate and of high quality.

Still, the automated process was designed to enable the user to handle AI related risks as follows:

  • Option to turn off AI commentary.
  • Generate report in editable format (Word document) so that the user can amend it

In case the AI commentary is turned off, the report will still be accurate as in this case the result commentary is generated by the Python code in a prescribed format stating the movement in key items in monetary amounts and as a percentage and the BSCR component with the largest contribution. The user can then add further commentary based on their own analysis and judgement.

In a real-world setting, data privacy has to be addressed to avoid sharing sensitive information externally. The safest way to achieve this is to use install a freely available AI model (e.g. Llama) locally instead of using APIs. With this approach, the model operations on premise and data does not leave the company’s systems.

Further enhancements

The functionality of the app can be enhanced further to improve user experience, examples include:

  • Make report text editable directly in the app
  • Add functionality for comments and logging
  • Add time stamp and record creator of report for audit trail
  • Extend app to handle multiple reports and handle sections separately in the app

Scalability

Once the automated workflows is set up for a specific report, the next step natural idea is to extend the automation  to other reports. To achieve this, the layout and Python code have to amended but otherwise the process is the same.

This can be accelerated with the following Python libraries:

  • Extract report structure, text and report components from existing Word document (python-docx)
  • Extract report structure, text and report components from existing pdf documents (pdfminer or pdfplumber)

Furthermore, the AI chatbots already used can be used to help with amending the layout and the Python code although this is likely to require a few iterations and human in the loop.

A summary of the steps mentioned above is shown on Figure 4. Once the process is set up for the new report, it can be executed in the same way as for the previous example (see Figure 2).

Pros and cons of adopting a Python-based automation toolkit

As shown in our case study, Python has powerful capabilities for the automation of financial reporting. However, not all organisations are prepared to adopt such an open-source toolkit and prefer to stick with spreadsheets and text editors due to their wide availability, transparency and flexibility.

The pros and cons of adopting a Python based automation toolkit for financial reporting are summarised below.

Pros

Cons

Automation: Python excels at automating repetitive tasks resulting in reduced runtime.

Steep Learning Curve: Python requires programming knowledge, which can be a barrier for those without a coding background.

Integration: Python can easily integrate with databases, web services, and other programming languages, providing flexibility in accessing and manipulating data.

Setup and Maintenance: Setting up the Python environment and managing dependencies can be complex.

Reproducibility: Python scripts can be version-controlled using tools like Git, ensuring that workflows are reproducible and changes are trackable.

Error Handling: Python scripts can be less forgiving with errors, requiring debugging and thorough testing to ensure accuracy.

Advanced Analytics and AI: Python facilitates complex data analysis, insightful data visualisations and is the go to language for AI and Machine Learning models that can be leveraged seamlessly.

User Interface: Python scripts may be perceived as less user-friendly and intuitive for non-technical users.

Scalability: Python handles large datasets efficiently. Cloud solutions and parallel computing can add further scale and computing power.

 

Cost: As an open-source tool it is free to use, making it a cost-effective option.

 

 

Conclusion

The benefits of using a Python-based process automation toolkit are significant and include:

  • Radically reduced runtime
  • High accuracy
  • Scalability and reproducibility
  • Produce reports in various output formats instantly (e.g. HTML, PDF,  MS Word)
  • Visually appealing reports with professional design and reusable templates
  • Seamless integration of cutting-edge AI models

Still, the adoption of such toolkits has been slow in insurance and the wider financial services industry. This is largely due to obstacles such as the steep learning curve associated with coding and the perceived lack of user-friendliness, flexibility and transparency. These obstacles can be addressed by:

  • A carefully designed training and implementation programme
  • Outsourcing the setup, maintenance and error handling to specialist providers
  • Low/no-code solutions, such as interactive apps (e.g. Streamlit) remove the need for programming knowledge

Embracing technological change calls for a shift in mindset and buy-in from reporting teams is essential for the success of any transformation project. As the insurance industry continues to evolve, automation will no longer be optional but essential. With advancements in automation and AI technology, financial reporting can be faster, smarter, and more accurate. Now is the time to lead this transformation.

If you found this post insightful, you may also be interested in the previous issue of this series Finalyse: Process Automation in Insurance Series #1 : Workflow optimisation with automated process mapping

How Finalyse can help?

We would be happy to walk you through our interactive Streamlit application to showcase how it can revolutionise financial reporting.

Furthermore, we can help you with the following on your process automation journey:

  • Perform an assessment on the effectiveness of your current reporting process, identify bottlenecks and inefficiencies
  • Support end-to-end transformation projects in financial reporting with process mapping, design and implementation of the target operating model
  • Design and implement process automation tools to streamline your data management, modelling or reporting processes
  • Build interactive, no code applications that do not require programming knowledge and still enhances productivity
  • Develop applications that leverage cutting edge AI technology in a safe, controlled manner
  • Support your model risk management framework by preparing or reviewing your policies and documentation
  • Prepare or review your AI Risk Management Policy to ensure compliance with regulations

Please sign up for a complimentary process automation workshop (virtual or in person) so that we can help identify and prioritise your uses cases. To find out more about our process automation offering please visit our service page at process automation for (re)insurers.

For further support or to request a demo please reach out to Bence Zaupper or your regular Finalyse contact.

Share this article: