FinReportAI is an on-device AI-powered financial report analysis tool designed for non-financial professionals. It extracts key data from lengthy financial reports using OCR, processes and visualizes the data, and generates an easy-to-understand financial analysis report using NLP and a local language model. This enables users to receive personalized financial insights and investment advice without needing extensive financial expertise.
Anqi Guan
Zhendong Yang
Jing Du
Sicheng Zhou
Rui Min
PDF to Image Conversion:
Uses pdf2image and PyMuPDF (fitz) to convert PDF pages to high-resolution PNG images.
OCR Processing:
Uses Tesseract OCR (via pytesseract and Pillow) to extract text from images.
Data Extraction & Parsing:
Processes the OCR output to detect date columns, extract financial field values, and capture company information.
Data Analysis & Visualization:
Uses pandas, matplotlib, and seaborn to analyze financial data and generate visualizations.
Report Generation:
Utilizes a language model (via llama-cpp-python or Hugging Face's transformers pipeline) to generate a comprehensive financial report.
Web UI:
A simple Flask-based file upload interface for users to upload PDFs and trigger processing.
brew install tesseractsudo apt-get install tesseract-ocrTo set up the project from scratch, follow these steps:
Clone the Repository:
git clone https://github.com/YourGitHubUsername/FinReportAI.git
cd FinReportAI
Create a Virtual Environment (Recommended):
python -m venv venv
source venv/bin/activate # On macOS/Linux
venv\Scripts\activate # On Windows
Install Dependencies:
pip install -r requirementss
Note: The requirements.txt file includes dependencies such as pdf2image, numpy, pillow, matplotlib, seaborn, pytesseract, pandas, flask, transformers, torch, and the appropriate LLM package (e.g., llama-cpp-python).
Or Install the required Python packages by running:
```bash
pip install pdf2image numpy pillow matplotlib llama-cpp-python pytesseract pandas flask seaborn transformers torch subprocess markdown2
```
Note: If you encounter issues installing
llama_cppor if you need a version that doesn't require AVX, consider usingllama-cpp-pythoninstead (see its GitHub repository for more details).
Set Up Tesseract:
brew install tesseract
sudo apt-get install tesseract-ocr
Configure the Application:
src/uploads folder.outputs folder exists (the application will create it automatically if it doesn't).your_project/
├── src/
│ ├── app.py # Flask file upload UI and main application
│ ├── advice_pipeline.py # Generate a financial advice report
│ ├── ocr_pipeline.py # PDF-to-image conversion, OCR extraction, and parsing OCR text into financial_data.csv
│ ├── visualization_pipeline.py # Visualization and analysis of financial data (e.g., plotting trends)
│ ├── report_pipeline.py # Generate a comprehensive financial analysis report using an LLM
│ ├── outputs/ # Automatically generated output files:
│ │ ├── extracted_text.txt # OCR results
│ │ ├── financial_data.csv # Parsed financial data CSV
│ │ ├── analysis_report.txt # Generated financial analysis report
| | └── advice_report.txt # Generated financial advice report
│ └── uploads/ # Directory for uploaded PDF files
├── examples/ # Example scripts or notebooks for testing/experiments
└── README.md # This file
cd src
python app.py
financial_report.pdf file from the examples folder.To run the OCR pipeline:
financial_report.pdf in the uploads folder.src folder, run:
python ocr_pipeline.py
This script will:
uploads/financial_report.pdf into PNG images stored in the outputs/ folder.outputs/extracted_text.txt.outputs/extracted_text.txt, detect date columns and extract financial fields (and company name), then write the parsed data into outputs/financial_data.csv.To generate a report based on the parsed CSV:
src folder, run:
python report_pipeline.py
python advice_pipeline.py
python visualization_pipeline.py
outputs/financial_data.csv, construct a prompt, and use the offline language model to generate a detailed financial analysis report.outputs/analysis_report.txt and outputs/advice_report.txt.OCR Preprocessing:
You can adjust the image preprocessing in the OCR script to improve recognition accuracy.
Parsing Logic:
Modify the regex patterns in the parsing scripts if your OCR output format changes.
Model & Prompt:
Adjust the prompt for the language model to fit your desired report style. If using a different LLM, update the model loading code accordingly.
Tesseract Not Found:
Make sure Tesseract is installed and its executable is in your PATH. You may specify the path in your script:
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
Dependency Issues:
Ensure all dependencies are installed in your virtual environment. Use pip freeze to verify package versions.
Model Compatibility:
If you face issues with the language model (e.g., AVX requirements on Snapdragon devices), consider using an ARM-compatible version like llama-cpp-python.
This project is licensed under the MIT License.
For help choosing an open-source license, visit choosealicense.com.
FinReportAI is an on-device AI-powered financial report analysis tool designed for non-financial professionals. It extracts key data from lengthy financial reports using OCR, processes and visualizes the data, and generates an easy-to-understand financial analysis report using NLP and a local language model. This enables users to receive personalized financial insights and investment advice without needing extensive financial expertise.
Anqi Guan
Zhendong Yang
Jing Du
Sicheng Zhou
Rui Min
PDF to Image Conversion:
Uses pdf2image and PyMuPDF (fitz) to convert PDF pages to high-resolution PNG images.
OCR Processing:
Uses Tesseract OCR (via pytesseract and Pillow) to extract text from images.
Data Extraction & Parsing:
Processes the OCR output to detect date columns, extract financial field values, and capture company information.
Data Analysis & Visualization:
Uses pandas, matplotlib, and seaborn to analyze financial data and generate visualizations.
Report Generation:
Utilizes a language model (via llama-cpp-python or Hugging Face's transformers pipeline) to generate a comprehensive financial report.
Web UI:
A simple Flask-based file upload interface for users to upload PDFs and trigger processing.
brew install tesseractsudo apt-get install tesseract-ocrTo set up the project from scratch, follow these steps:
Clone the Repository:
git clone https://github.com/YourGitHubUsername/FinReportAI.git
cd FinReportAI
Create a Virtual Environment (Recommended):
python -m venv venv
source venv/bin/activate # On macOS/Linux
venv\Scripts\activate # On Windows
Install Dependencies:
pip install -r requirementss
Note: The requirements.txt file includes dependencies such as pdf2image, numpy, pillow, matplotlib, seaborn, pytesseract, pandas, flask, transformers, torch, and the appropriate LLM package (e.g., llama-cpp-python).
Or Install the required Python packages by running:
```bash
pip install pdf2image numpy pillow matplotlib llama-cpp-python pytesseract pandas flask seaborn transformers torch subprocess markdown2
```
Note: If you encounter issues installing
llama_cppor if you need a version that doesn't require AVX, consider usingllama-cpp-pythoninstead (see its GitHub repository for more details).
Set Up Tesseract:
brew install tesseract
sudo apt-get install tesseract-ocr
Configure the Application:
src/uploads folder.outputs folder exists (the application will create it automatically if it doesn't).your_project/
├── src/
│ ├── app.py # Flask file upload UI and main application
│ ├── advice_pipeline.py # Generate a financial advice report
│ ├── ocr_pipeline.py # PDF-to-image conversion, OCR extraction, and parsing OCR text into financial_data.csv
│ ├── visualization_pipeline.py # Visualization and analysis of financial data (e.g., plotting trends)
│ ├── report_pipeline.py # Generate a comprehensive financial analysis report using an LLM
│ ├── outputs/ # Automatically generated output files:
│ │ ├── extracted_text.txt # OCR results
│ │ ├── financial_data.csv # Parsed financial data CSV
│ │ ├── analysis_report.txt # Generated financial analysis report
| | └── advice_report.txt # Generated financial advice report
│ └── uploads/ # Directory for uploaded PDF files
├── examples/ # Example scripts or notebooks for testing/experiments
└── README.md # This file
cd src
python app.py
financial_report.pdf file from the examples folder.To run the OCR pipeline:
financial_report.pdf in the uploads folder.src folder, run:
python ocr_pipeline.py
This script will:
uploads/financial_report.pdf into PNG images stored in the outputs/ folder.outputs/extracted_text.txt.outputs/extracted_text.txt, detect date columns and extract financial fields (and company name), then write the parsed data into outputs/financial_data.csv.To generate a report based on the parsed CSV:
src folder, run:
python report_pipeline.py
python advice_pipeline.py
python visualization_pipeline.py
outputs/financial_data.csv, construct a prompt, and use the offline language model to generate a detailed financial analysis report.outputs/analysis_report.txt and outputs/advice_report.txt.OCR Preprocessing:
You can adjust the image preprocessing in the OCR script to improve recognition accuracy.
Parsing Logic:
Modify the regex patterns in the parsing scripts if your OCR output format changes.
Model & Prompt:
Adjust the prompt for the language model to fit your desired report style. If using a different LLM, update the model loading code accordingly.
Tesseract Not Found:
Make sure Tesseract is installed and its executable is in your PATH. You may specify the path in your script:
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
Dependency Issues:
Ensure all dependencies are installed in your virtual environment. Use pip freeze to verify package versions.
Model Compatibility:
If you face issues with the language model (e.g., AVX requirements on Snapdragon devices), consider using an ARM-compatible version like llama-cpp-python.
This project is licensed under the MIT License.
For help choosing an open-source license, visit choosealicense.com.