LLM
  • Overview
    • LLM
  • Key Concepts
    • Models
    • Key Concepts
  • Quckstart
    • Jan.ai
    • 🦙Ollama & Chatbox
  • Playground
  • Workflows
    • n8n
    • Flowise
      • Basic Chatbot
      • Research Agent
      • Company Information Agent
      • PDF Parser
      • Knowledge Base
      • Lead Gen
    • Agno
  • LLM Projects
    • RAG + ChainLit
  • Model Context Protocol
    • Claude + MCPs
    • Flowise + MCPs
  • Knowledge Graphs
    • neo4j
    • WhyHow.ai
  • Setup
    • WSL & Docker
    • 🦙Quickstart
    • Key Concepts
    • Workflows
    • Model Context Protocol
Powered by GitBook
On this page
  1. Workflows
  2. Flowise

PDF Parser

PreviousCompany Information AgentNextKnowledge Base

Last updated 25 days ago

x

x

x

At some stage you will have to deal with unstructured data. This can be tricky especially if you need to output the results in a specific format - csv, json, etc ..

In Open WebUI download the mistral:7b model

  1. Let's create a new Chain. Click on: '+ Add New' blue button in top right.

  2. Save as: 'PDF Parser'.

  1. Add a Tool Agent. Click on the blue + sign and select Chains > LLM Chain.

  2. Drag & drop onto the canvas.

Note that the LLM Chain has an option to define the Output Parser

  1. Next add a Chat Model. Again, Click on the blue + sign and select Chat Models > ChatOllama.

  2. Connect the ChatOllama to the LLM Chain, by dragging a connector from ChatOllama to LLM Chain.

  3. Configure the model as illustrated.

The ChatOllama has an option to upload images. Check that the model has reasoning image capabilities: mistral:7b

Use the options at the bottom to resize canvas.

  1. Let's add a Prompt Template: Prompts > Prompt Template, and connect to LLM Chain.

A Prompt Template is similar to the System Prompt in the Chat Model.

  1. Before we progress any further, lets Save.

  2. In the Prompt Template, expand the Template. Were going to add some instructions based on the PDF.

Take a look at the main section of the sample-invoice.pdf:

Invoice Number

Order Number

Invoice Date

Due Date

Tax

Total

and so on ...

We can instruct the model to extract the required information.

To include the invoice content within the prompt we need to add a variable: {invoice}. It can be anything that makes sense..!

  1. In the Template lets add some instructions.

  1. Save .. now we need to associate the PDF with the {invoice} variable. Click on Format Prompt Values.

  1. Save .. To enable the file to be uploaded into the chat: Settings > Configuration.

  1. Enable File Upload .. and Save.

  1. Let's give it a go ..!

The sample-invoice.pdf is located in: Workshop--LLM/ Data folder.

The purpose of this Chain is to be called from some external system to parse the unstructured data source, extract the required information to be consumed further downstream - JSON Object.

  1. Add the Structured Output Parser: Output Parsers > Structured Output Parser

  1. Enable Autofix and click on: 'Additional Parameters'.

The Additional Parameters setting enables you to define the fields and data type in the JSON object. The model uses the description to map the value to the 'Property'.

  1. Double-click in the Property / Type / description field to edit and select the type.

Property
Type
Description

invoice_id

string

Invoice Number

order_id

number

Order Number

service_type

string

Service

due_date

string

Due Date

total

number

Total

  1. And finally ..

This workflow could be in a number of use cases: from document classification to

PDF Parser
Add Chains > LLM Chain
Add Ollama Model
Add Prompt Template
Add instructions
Associate PDF with {invoice}
Configuration
File Upload
Execute Chain ..
Add Structured Output Parser
Set Property - Data Type
JSON output