XBSTACK XBSTACK
Xiaobai

Xiaobai

Developer · Builder

Building AI engineering systems, developer tools and long-term digital assets at XBSTACK.

About Xiaobai & XBSTACK →
7 Steps to Analyze Financial Reports with AI: From PDF to Risk Checklist

7 Steps to Analyze Financial Reports with AI: From PDF to Risk Checklist

7 Steps to Analyze Financial Reports with AI: Leverage OCR, Python, LLMs, and manual review workflows to convert PDF financial reports into structured fields, risk checklists.

Published · 2026-06-197 min readXBSTACK
#ai#financial reports#automation#LLMs

Preface

I’ve kept asking myself how to read financial reports quickly, accurately, and safely. Traditional manual review often takes hours, and fragmented information makes key risks easy to miss. The goal is not to let AI replace human judgment, but to combine PDF parsing, LLM reasoning, structured output, source_page, evidence, and human review in one workflow—making financial report analysis auditable, reproducible, and adjustable.

Boundary Note: This article documents the AI-driven financial report reading and R&D workflow; it does not provide stock buy/sell recommendations, target prices, position sizing advice, or short-term predictions. All AI outputs must be cross-referenced with the original financial reports and manually verified against source_page.

Who Should Read This

  • Financial analysts, investment researchers, and independent investors who want to spend their time on judgment rather than data extraction during busy earnings seasons.
  • Data scientists and full-stack engineers looking to embed open-source LLMs into internal enterprise workflows.
  • Startup teams and fintech entrepreneurs needing a reusable template for automated financial report auditing.

1. PDF Text Extraction (OCR + Structuring)

1.1 Why Not Use a PDF Parsing Library Directly?

Common libraries like pdfminer and pdfplumber yield almost zero output for scanned financial reports; only PDFs with a native text layer can be parsed directly. Most PDFs provided by publicly listed companies are scans containing only images. Therefore, I use OCR to convert the images to text first, then apply regular expressions to extract section headings, table titles, and key financial metrics.

1.2 Toolchain

  • Tesseract 5.3 (open-source OCR engine with --psm 1 parameter)
  • Poppler (pdftoppm converts PDF pages to high-resolution PNGs)
  • Python regex (extracts subsections like Balance Sheet, Income Statement, and Cash Flow Statement)
# Split the PDF into PNG files (300 DPI)
# 300 DPI ensures clear text
pdftoppm -r 300 annual_report.pdf page
# Run OCR and generate one TXT file per page
for f in page-*.png; do tesseract "$f" "${f%.png}" -l chi_sim; done

1.3 Example of Extraction Results

Page 1
Company Name: Huawei Technologies Co., Ltd.
Reporting Period: December 31, 2025
...
Balance Sheet (unit: RMB 10,000)
Total Current Assets 123,456
Total Non-current Assets 789,012
...
Income Statement (unit: RMB 10,000)
Operating Revenue 1,234,567
Operating Costs 987,654
...

After merging the text from each page, use regex to split the chapters and form a JSON structure:

{
  "company": "Huawei Technologies Co., Ltd.",
  "period": "2025-12-31",
  "balance_sheet": {
    "current_assets": 123456,
    "non_current_assets": 789012
  },
  "income_statement": {
    "revenue": 1234567,
    "cost": 987654
  }
}

2. Data Cleaning and Standardization

Financial report figures often contain thousand separators and inconsistent units (e.g., ten thousand yuan, hundred million yuan). I used pandas’ applymap to convert them all to floats and standardized every monetary value to RMB yuan.

def normalize_amount(val):
    if isinstance(val, str):
        val = val.replace(',', '').replace('ten thousand yuan', '').replace('hundred million yuan', '')
        if 'hundred million yuan' in val:
            return float(val) * 1e8
        return float(val) * 1e4
    return val

df = df.applymap(normalize_amount)

3. LLM Prompt Design

3.1 Objective

Enable the model to convert structured financial data into a risk checklist, including but not limited to:

  • Anomalies in key financial ratios (current ratio, quick ratio, return on equity)
  • Anomalies in expense ratios (R&D expense ratio, sales expense ratio)
  • Anomalies in related-party transactions and related-party proportion
  • Cash flow anomalies (negative net operating cash inflow)

3.2 Prompt Example

You are a professional financial analyst. Based on the structured financial data below, list all risk points worth noting. Each point should start with ”- ”, formatted as follows:

  • Risk Title: Brief description
    • Detailed Explanation: Include the specific figures that trigger this risk, corresponding industry benchmarks or historical comparisons, and the potential scope of impact.

3.3 Model Used

I deploy Ollama locally, select the llama3:8b model (low cost), and enable json mode to force the model to output only a JSON list.

ollama run llama3:8b -p "@prompt.txt" -i data.json -o result.json --json

4. Structured Risk List Generation

The JSON returned by the model is structured as follows:

[
  {
    "title": "Current ratio below the industry benchmark",
    "detail": "The current ratio for this period is 0.85, versus an industry average of 1.2, which may create short-term debt-servicing pressure."
  },
  {
    "title": "Unusual decline in the R&D expense ratio",
    "detail": "The R&D expense ratio fell from 12% last year to 5%, which may affect future innovation capacity."
  }
]

I’ve written it out in Markdown to form a risk checklist ready for direct use in reports.

Self-developed by Xiaobai Lab / TOOL CONVERSION

If you want to directly test the AI Financial Report Assistant, jump straight to the trial with one click

Supports financial report text parsing, core KPI extraction, risk factor localization, source_page / evidence logging, and manual review status tagging.

5. Automated Workflow (n8n)

5.1 Process Overview

  1. File Trigger: Monitors the /data/annual_reports/ folder and starts when a new PDF appears.
  2. PDF → PNG: Executes pdftoppm.
  3. OCR: Calls the local Tesseract service (Docker).
  4. Text Cleaning: Uses the Python script clean.py to output JSON.
  5. LLM Inference: Calls the local Ollama REST API.
  6. Result Writing: Writes the risk checklist to the enterprise internal knowledge base (Confluence) or sends it to Slack.

5.2 Key n8n Node Configuration Points

  • Execute Command: pdftoppmtesseract, ensure stderr captures errors.
  • HTTP Request (Ollama): POST https://localhost:11434/api/generate, Headers Content-Type: application/json.
  • If: Checks the model’s returned error field; if present, triggers the Error Workflow (DingTalk alert).
  • Slack: The Send Message node pushes the risk checklist as a code block.

6. Cost and Performance Evaluation

ItemMeasurement MethodDaily ConsumptionCost
OCR (Tesseract)50-page PDF100s CPU$0.001
LLM (llama3:8b)1 inference, 2 KB input5s GPU$0.005
n8n WorkflowOnce per report15s total$0.001
Total$0.007 (~¥0.05)

These costs and time estimates are merely approximations from a sanitized sample environment. Actual results will be affected by PDF page count, scan quality, OCR accuracy, model selection, queue load, and the ratio of manual reviews, so they should not be treated as fixed commitments.

7. Common Errors and Troubleshooting

  • Low OCR recognition rate: Ensure PDF-to-PNG conversion uses 300 DPI or higher. If garbled text persists, add --oem 2 to the tesseract parameters to use the LSTM engine.
  • Model output does not conform to JSON: Forcefully request “output only a JSON list” at the end of the prompt, and enable the json: true parameter during API calls. If text wrapping still occurs, use a regex in a post-processing Code node to extract the {} content.
  • n8n step timeout: Increase the Timeout field on each Execute Command node to 120000 (milliseconds) to prevent large-file OCR from hanging.
  • Incorrect calculation of related-party proportion: Related parties often appear in footnotes within financial reports. You must add matching for the “related party” keyword in your regex, otherwise they will be missed.

8. Complete Code Repository and Deployment Guide

  • Repository URL: https://github.com/xbstack/ai-financial-report-analyzer (also synced to our internal company GitLab)
  • Includes a Dockerfile (Tesseract + Ollama + n8n) and the complete n8n workflow export file financial-report-workflow.json.
  • Deployment Steps (only 5 required)
    1. Run docker compose up -d to start all services.
    2. Import financial-report-workflow.json in the n8n UI.
    3. Configure the folder monitoring path to /data/annual_reports/.
    4. Enter the corresponding Webhook URL in Slack or DingTalk.
    5. Drop PDFs into the monitored folder, and the risk checklist will be automatically generated.

9. FAQ (Frequently Asked Questions)

Q1: What if the company uses cloud PDF storage (e.g., S3)?

Replace Execute Command with an AWS S3 node in n8n, download the files first before performing OCR. The rest of the workflow remains unchanged.

Q2: What are the hardware requirements for model inference?

Local inference time depends on the model, quantization, context length, GPU/CPU, VRAM, and output length; do not treat “12GB VRAM = under 5 seconds” as a universal result. For a cloud API, record the actual input/output tokens and apply the provider’s current pricing instead of assuming a fixed cost per thousand requests.

Q3: Can the risk checklist be exported directly to Excel?

Add a Google Sheets node at the end of the workflow to write the JSON array into a new sheet, or use n8n’s Write Binary File node to generate an XLSX.

10. Conclusion

Turning a financial-report PDF into structured fields and then using an LLM to draft a risk checklist can reduce mechanical extraction work, but end-to-end time and cost depend on page count, scan quality, OCR, model choice, queue load, retries, and human review. Measure parsing/OCR time, model tokens, failures, and review effort per document and compare them with the equivalent manual workflow; there is no universal “30 minutes for pennies” result.

If you’d like to implement similar automation within your own organization, feel free to clone my repository and run it with one click following the deployment guide. If you encounter any technical details during implementation (OCR parameter tuning, prompt design, n8n node configuration), ask away in the comments section, and I’ll respond promptly.

Read the original article and full code 👉 https://www.xbstack.com/ai/ai-finance-report-7-steps/

Next Step / NEXT READING

Ready to analyze your first financial report?

You can test it with a sanitized financial report text to verify whether the tool outputs core KPIs, risk factors, source_page, evidence, and a checklist of items requiring manual review.

Continue Reading

Disclaimer: This article only discusses AI financial report processing, data extraction, and engineering implementation. It does not predict stock prices, provide securities trading advice, or constitute any investment recommendations. Financial data and model outputs should always be cross-referenced with the original reports and verified manually.

Tool / AI Finance

Run the financial-report workflow instead of only reading about it

The AI Finance tool turns report extraction, source-page evidence and review steps into an interactive workflow. It compresses information and does not provide investment advice.

More to Explore

Topic hub →
Practical Guide to AI Financial Report Assistant Task Queues: Designing PDF Parsing, LLM Calls, and Progress UpdatesPractical Guide to AI Financial Report Assistant Task Queues: This article breaks down the asynchronous task queue design for an AI financial report assistant, covering PDF uploadAI Financial Report Assistant Evaluation Framework: How to Use a Golden Dataset to Detect LLM Misreads?AI Financial Report Assistant Evaluation Framework: This article details the evaluation framework for an AI financial report assistant, covering how to leverage a Golden Dataset, hLLM JSON Schema for Financial Report Extraction: Stable Structured OutputUse LLM JSON Schema for financial report extraction to return stable metrics, cash flow, risks, source evidence, nulls, and review fields with validation.AI Financial Report Assistant: Converting PDFs into Structured Risk ChecklistsA detailed breakdown of the AI financial report assistant’s architecture, covering PDF parsing, section splitting, table extraction, LLM-driven structured extraction, JSON Schema f

AI Engineering Weekly

Production changes, real failures, experiments and new XBSTACK assets.

Comments & evidence

DISCUSSION

Questions, verification and corrections

Sign in to comment. Every new comment is reviewed before publication; while pending, it is visible only to you and the administrator.

Sign-in required Reviewed before public
Loading the discussion…