Solution | Interactive Document Intelligence for ESG¶
Financial service firms have a large document corpus (both digitized and native images) with valuable opportunities from harnessing insights and trends within this unstructured data. Many organizations rely on individuals to read sections of these documents, or search for relevant materials in an ad hoc manner, with no systematic way of categorizing and understanding the information and trends.
This solution automatically consolidates unstructured document data into a unified, searchable and automatically categorized database, with insight accessible via a powerful and easy to use dashboard. The project accepts any document set as input, and each document is sent through a modular and reusable pipeline to automatically digitize documents, extract text, and consolidate data. Multiple NLP techniques are applied to this data based on theme of interest (in this project: ESG), with additional theme modules available. If interested, roll-out and customization services can be offered on demand.
To leverage this solution, you must meet the following requirements:
Have access to a Dataiku 11.0+ instance.
A Python 3.6 code environment named
solution_document-intelligencewith the following required packages:
PyMuPDF==1.18.19 regex==2022.10.31 pyldavis==3.2.2 dash==2.7.0 nltk==3.6.7 torch==1.10.2 transformers==4.16.2 weasyprint==54.3 seaborn==0.11.2 scikit-learn==0.24.2 wordcloud==18.104.22.168 tokenizers==0.10.3
When creating a new code environment, please be sure to use the name
solution_document-intelligence or remapping will be required.
When building the Python code env, an additional script must be run to provide code environment resources:
from dataiku.code_env_resources import clear_all_env_vars from dataiku.code_env_resources import set_env_path from dataiku.code_env_resources import set_env_var import os # Clears all environment variables defined by previously run script clear_all_env_vars() ## Hugging Face # Set HuggingFace cache directory set_env_path("HF_HOME", "huggingface") import transformers from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("ProsusAI/finbert") model = AutoModelForSequenceClassification.from_pretrained("ProsusAI/finbert") set_env_path("NLTK_DATA", "nltk_data") # Import NLTK import nltk # Download model: automatically managed by NLTK, does not download # anything if model is already in NLTK_DATA. nltk.download('punkt', download_dir=os.environ["NLTK_DATA"])
Tesseract must be installed on the server or machine running Dataiku.
Once your instance has been prepared, you can install this solution in one of two ways:
On your Dataiku instance click + New Project > Business solutions > Search for Interactive Document Intelligence for ESG.
Download the .zip project file and upload it directly to your Dataiku instance as a new project.
This solution uses SEC data pulled via the EDGAR API, but is not endorsed or certified by these organizations. By utilizing this solution, you agree to abide by the terms set forth on these data sources.
The project initially includes SEC data from EDGAR to demonstrate functionality. This can be replaced or supplemented by the document soure of choice by changing the flow. Roll-out and customization services can be offered on demand.
You can follow along with the sample project in the Dataiku gallery.
The solution has the following high level steps:
Pull public data and process documents
Extract Windows from documents and apply Sentiment Analysis
Unveil abstract “topics” occuring in the document corpus
Enable business users with Interactive Mode
Conduct real-world analysis with Demonstration Mode
In addition to reading this document, it is recommended to read the wiki of the project before beginning in order to get a deeper technical understanding of how this solution was created, the different types of data enrichment available, longer explanations of solution specific vocabulary, and suggested future direction for the solution.
Digitize, analyze and consolidate thousands of documents¶
To tailor the project to our own corpus of documents, we should use the Project Setup feature of Dataiku which can be found by navigating to the project’s home page and clicking the PROJECT SETUP button. Here we can upload our corpus of documents, document metadata, and keyword list before running the full flow and updating the dashboard.
The underlying flow upon which the interactive dashboards are built is comprised of 4 flow zones. The full flow and its individual flow zones can be cutomized based on the specific needs of the user. Specific details on how to change the flow and the impact of possible changes can be understood via the project wiki.
The SEC Data Pull flow zone is used to get sample documents from the EDGAR database to run through the flow. If you have your own corpus of documents to process, they can be subbed in to this section via Project Setup in lieu of the SEC data. The output of this zone, example_documents is passed along to the next flow zone for analysis.
Within the document pre-processing flow zone, the processed folder of documents is classified based on whether it is digital, a native image, or unable to be processed. Text is extracted from digital documents using PyMuPDF while the Tesseract Plugin is used to perform optical character recognition (OCR) on native images. This part of the flow can be changed to instead use your preferred OCR tool.
A unified data repository documents_processed_join is passed from the last flow zone to the window extraction and sentiment analysis flow zone. Here we search through the document to extract windows based on a key word list or a catagory list before applying FinBERT to analyze sentiment of the window. This project has been designed with keywords pertaining to Environmental, Social, and Governance.
Finally, the topic modeling flow zone unveils abstract “topics” that occur in the document corpus. This particular flow has ben built to run LDA topic modelling. Users of this solution should view this final flow zone as an example of an NLP downstream analysis that can be performed on a document database.
Interactive search and insight generation for Business users¶
Business users can easily and interactively consume the NLP module results with the pre-built Interactive Document Intelligence Dashboards consisting of 3 main features.
Users interested in analyzing high level trends and aggregated insights will benefit from the Interactive Dashboard: FinBERT Sentiment Analysis tab of the Dashboard. Here, we can search for a company name and select multiple categories from the initial category list to see the resulting Sentiment Analysis of each document in the corpus using the provided webapp. We can also drilldown even further from here into subcategories to view the extracted windows (on which sentiment analysis was applied) and their associated sentiment score. The solution also provides users with a document viewer in this tab so that we can easily refer back to the originating document when viewing sentiment scores.
The Time Series Frequency Analyis tab delivers several charts with which we can track the frequency of key words and sentiment over time. The charts includes all companies so they can be compared to one another by altering the filters.
Lastly, several important visualizations are made available in the Topic Modeling tab. From the topic modeling flow zone, a word cloud is generated for each topic found by the LDA model. With this cloud we can visualize the most common words per topic. Below the word clouds we can interactively visualize the top 30 words found per topic and conduct exploratory analysis in an easy-to-understand visual manner.
Reproducing these Processes With Minimal Effort For Your Data¶
The intent of this project is to enable financial experts to understand how Dataiku can be used to leverage ESG insights in decision making. By creating a singular solution that can benefit and influence the decisions of a variety of teams in a single organization, smarter and more holistic strategies can be designed to track ESG trends over time, inform ESG-integrated judgement, and scan through large corpuses of documents for ESG insights.
We’ve provided several suggestions on how to use public SEC data but ultimately, the “best” approach will depend on your specific needs and your data. If you’re interested in adopting this project to the specific goals and needs of your organization, roll-out and customization services can be offered on demand.