Icon

GPT4All - Extract Information from PDF Bank Statements into JSON

<p>Extract Data from Bank Statements (PDF) into JSON files with the help of GPT4All / Llama3 LLM</p><ul><li><p>List PDFs from your drive that roughly have a similar layout and you expect an LLM to be able to extract data in a systematic way</p></li><li><p>Formulate a concise prompt (and instruction) and try to force the LLM to give back a JSON file with always the same structure (Mistral seems to be very good at that)</p></li><li><p>Use GPT4All wrapper to put document and query before the LLM</p></li><li><p>Collect the responses</p></li><li><p>Extract the data from JSON files, either with the help of Regex or just convert the JSON with KKNIME nodes</p></li><li><p>Make sure they have the same structure<br><br>=&gt; you need to have GPT4All installed and a suitable model downloaded to your "gpt4all_models" folder. You can choose the model then in the component</p></li></ul>

URL: Medium - Ollama and Llama3 - A Streamlit App to convert your files into local Vector Stores and chat with them using the latest LLMs https://medium.com/p/c5340fcd6ad0
URL: Medium - Chat with local Llama3 Model via Ollama in KNIME Analytics Platform - Also extract Logs into structured JSON Files https://medium.com/p/aca61e4a690a
URL: GitHub - A Streamlit App to convert your files into Vector Stores and chat with them with LLMs https://github.com/ml-score/ollama
URL: KNIME Spaces: KNIME for Generative AI https://hub.knime.com/-/collections/~D4ckx2q_J5FPBQXu/
URL: Download the whole LLM workflow group in order to get the folder https://hub.knime.com/mlauber71/spaces/LLM_Space/~17k4zAECNryrZw1X/
URL: GPT4All - Run Large Language Models Locally https://www.nomic.ai/gpt4all
URL: Medium: Llama3 and KNIME — Build your local Vector Store from PDFs and other Documents https://medium.com/low-code-for-advanced-data-science/llama3-and-knime-build-your-local-vector-store-from-pdfs-and-other-documents-237eda761c1c

Extract Data from Bank Statements (PDF) into JSON files with the help of GPT4All / Llama3 LLM


(https://forum.knime.com/t/extract-data-from-invoices-to-xml-or-csv/80875/12?u=mlauber71)

  • Extract Data from Bank Statements (PDF) into JSON files with the help of GPT4All / Llama3 LLM

    • List PDFs from your drive that roughly have a similar layout and you expect an LLM to be able to extract data in a systematic way

    • Formulate a concise prompt (and instruction) and try to force the LLM to give back a JSON file with always the same structure (Mistral seems to be very good at that)

    • Use GPT4All wrapper to put document and query before the LLM

    • Collect the responses

    • Extract the data from JSON files, either with the help of Regex or just convert the JSON with KKNIME nodes

    • Make sure they have the same structure

      => you need to have GPT4All installed and a suitable model downloaded to your "gpt4all_models" folder. You can choose the model then in the component

This is an approach to just use KNIME nodes. You could try the workflows making use of Ollama and Python nodes that might currently offer greater flexibility

Maybe download the whole LLM workflow group in order to get all the the folders

(https://hub.knime.com/mlauber71/spaces/LLM_Space/~17k4zAECNryrZw1X/)

Ollama and Llama3 - A Streamlit App to convert your files into local Vector Stores and chat with them using the latest LLMs

https://medium.com/p/c5340fcd6ad0


Medium - Chat with local Llama3 Model via Ollama in KNIME Analytics Platform - Also extract Logs into structured JSON Files

https://medium.com/p/aca61e4a690a

Extract exactly these information from the document into a JSON file.

Do not add any information that is not there. Do not change the structure of the JSON file. Do not alter the names of the fields or the order! Double Check that the JSON file is syntactically correct and can be processed. Avoid nested JSON structures! Enclose Numbers in quotation marks. Make sure the quotation marks on the whole JSON are correct.

If information is missing just leave it empty! The JSON fields to give back:

Firma (Company) Depot (Depot) Bank (Bank) Transaktionsart (Transaction Type - Purchase / Sale) ISIN / Kenn-Nr. der Aktie (ISIN / Stock ID Number) WKN (WKN) Wertstellung (Valuta) (Value Date) Belegdatum (Document Date) WSL (Währung) (Currency) FW-Kurs (Devisenkurs) (Foreign Exchange Rate) Menge (Quantity) Kurs (Price) WSL Kurs (Währung) (Currency of Price) Kurswert (Price Value) WSL Kurswert (Währung) (Currency of Price Value)

"engineered_prompt"
LLM Prompter
scan folder forBank .pdf statements../documents/bank/bank_01
List Files/Folders
current time
Create Date&Time Range
ENDCollect the model'sAnswers
Loop End
../data/
Table Writer
Instruction
Java Edit Variable (simple)
escapedPromptData=> escape the text so it will fit into a JSON file
Java Edit Variable
escapedInstructionData=> escape the text so it will fit into a JSON file
Java Edit Variable
right click / Open View (F10)Promptyou might want to experiment with different versions
Enter the Prompt
../gpt4all_models/select the local GPT4All modellike Llama3"Meta-Llama-3-8B-Instruct.Q4_0.gguf"
prepare GPT4all model path
<...model name...>.ggufload the .gguf modelneeds KNIME 5.2+you can change settings like choosing GPU
Local GPT4All Chat Model Connector
Date&Time Part Extractor
RowID
RowID
Strip text from PDFs
PDF Parser
current time
Create Date&Time Range
Document Data Extractor
Question
Java Edit Variable (simple)
prompt engineeringcf. hints ->"engineered_prompt"
String Manipulation
Modle name
Constant Value Column
Variable to Table Row
regexReplace($Response$, "```", "~#")
String Manipulation
URL to File Path
Column Filter
START Loop
Table Row to Variable Loop Start
Create Temp Folder
Table Row to Variable
Transfer Files
regex_extract($["Response"], "~#json([\\s\\S]*?)~\\#", 1)New Column: Match
Expression
URI
Path to URI
Path to String (Variable)
Matchextract JSON structure
String to JSON
create file name to collect
Merge Variables
just convert the whole JSONelement to tableyou could also try and extractdata with individual paths
JSON to Table
1 -3!!! remove this restriction whenyou want to process more files
Row Filter

Nodes

Extensions

Links