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

Annotations and comments
  • 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
  • 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
  • Maybe download the whole LLM workflow group in order to get all the the folders (https://hub.knime.com/mlauber71/spaces/LLM_Space/~17k4zAECNryrZw1X/)
  • 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)
  • Modle name
  • current time
  • regex_extract($["Response"], "~#json([\\s\\S]*?)~\\#", 1) New Column: Match
  • just convert the whole JSON element to table you could also try and extract data with individual paths
  • escapedPromptData => escape the text so it will fit into a JSON file
  • escapedInstructionData => escape the text so it will fit into a JSON file
  • Question
  • "engineered_prompt"
  • scan folder for Bank .pdf statements ../documents/bank/bank_01
  • <...model name...>.gguf load the .gguf model needs KNIME 5.2+ you can change settings like choosing GPU
  • END Collect the model's Answers
  • Strip text from PDFs
  • URI
  • 1 -3 !!! remove this restriction when you want to process more files
  • RowID
  • prompt engineering cf. hints -> "engineered_prompt"
  • regexReplace($Response$, "```", "~#")
  • Match extract JSON structure
  • START Loop
  • ../data/
  • stamp_day_txt
  • stamp_time_txt
  • var_file_name
  • var_file_name_html
  • var_file_name_pdf
  • var_file_name_part
  • stamp_time
  • stamp_day
  • stamp_*
  • model-name
  • var_model_path
  • var_file_name_xlsx
  • model-title
  • var_name_vector_store
  • browse folder with .bin models
  • bin-models-path

Nodes

Extensions

Links