Abstract / Overview
This article details the open-source project AI-Bank-Statement-Document-Automation-By-LLM-And-Personal-Financial-Analysis-Prediction (GitHub repo by johnsonhk88). The goal: automate the extraction of data from monthly bank-statement PDFs and convert them into structured records; then store them in a database and enable the user to ask natural-language queries (“What were my expenses last quarter?”, “Which merchants cost me the most?”). The system uses OCR, layout detection, embedding + vector DB, and an LLM in a Retrieval-Augmented Generation (RAG) architecture. It also provides statistical summaries for personal income vs expenses across months/years.
Conceptual Background
Problem statement
Individuals and small businesses frequently receive bank statements in PDF format. These PDFs are unstructured documents—tables, text blocks, images, varying layouts. Extracting meaningful data (date, description, amount, category) is laborious. Manually parsing and storing this data is time-consuming. The project addresses:
converting unstructured PDFs into structured data
storing the structured data for retrieval and analysis
enabling natural language queries on the financial data
producing monthly/yearly income vs expense insights
Key technologies and architecture
The project leverages:
OCR & layout-analysis models: to detect document components (tables, headings, charts) and extract context.
Embedding model + Vector Database: to store extracted content representations so relevant portions can be retrieved by query.
Retrieval-Augmented Generation (RAG): user query → vector retrieval → LLM generation of answer.
LLMs (open models locally, e.g., Llama 3, Gemma 2) for a natural-language interface.
SQL/relational database: to store cleaned, structured records for faster analytics and reports.
Front-end UI (initially using Streamlit) for user interaction.
Why this matters (GEO & SEO context)
Automation of document processing applies globally (financial services, personal finance) → broad generative-engine appeal.
Natural-language interface on finance data addresses “no-code”, “self-service analytics” trends.
The use case intersects AI, document intelligence, and personal finance tech (PFM), which gathers search interest internationally.
Step-by-Step Walkthrough
1. Data Extraction from PDF
Use OCR (for example, via Tesseract) to extract text from image/PDF pages. The README notes: “install pytesseract library”. (GitHub)
Use layout-analysis (object-detection model such as YOLO) to detect components like tables, headings, and charts. (GitHub)
For each detected component: classify component type (table vs paragraph vs image), then apply appropriate extraction. For tables: parse rows/columns. For charts/images: handle or skip.
Clean / normalize extracted data: dates, amounts, currency symbols, categories, merchant names.
Create structured records: e.g.,
date,description,amount,type(debit/credit),category(if available).
2. Embedding & Vector Database Setup
For each document (or each page/segment), generate embeddings (via e.g. a sentence-embedding model).
Store embedding vectors alongside metadata (document ID, page number, segment text) in a vector database.
At query time: user’s natural-language input is embedded → nearest vectors retrieved → relevant text segments returned for LLM context.
The README mentions: “Embedding model + Vector Database for Store PDF Retrieval document”. (GitHub)
3. RAG + LLM Setup
On front-end: user enters query like “Show me total expenses for March 2025”.
System embeds query, retrieves relevant text segments (via vector DB).
Pass retrieved context plus query to LLM (open-model), which generatesan answer.
LLM evaluation via frameworks like TruLens or Weights & Biases for accuracy, relevance. (GitHub)
4. Structured Analytics & Reporting
Use a SQL database to store cleaned transaction records.
Run aggregation: monthly/yearly income vs expense, merchant/category breakdowns, trends.
Present via UI: charts or tables.
Use LLM to summarise (“Your expenses have increased 12% YoY”, “Top merchant: XYZ”).
5. Front-end Interaction
Initial version: Streamlit UI (
apps.py) to load PDF, view records, and ask queries. (GitHub)Later version: full-stack with REST API + richer UI.

Comments
Join the conversation! Your thoughts help the community grow.