AI is a living thing. It learns and makes mistakes. This guide will show you how to integrate continuously learning AI into the existing workflow of your customers.

Why do you need continuously learning AI?

Business processes vary from one company to another, even from one department to another inside the same company. For example, when you are on-boarding a new supplier, you need to add it into your ERP system. You need to define how to pay, when to pay, contact person, etc. With all these parameters, you will set the process of business for it. Will, you set the same process for all suppliers? Probably not. Some of the suppliers will send you invoices daily, some weekly, some monthly. Some invoices are paid with a credit card, others with bank transfer, etc. Will every company have the same process for the same supplier? Probably not. Can it change once it’s set? Of course!

How to integrate data extraction to fit those prerequisites?

Firstly, you need a solution that will learn directly from your system. You don’t want to add new steps to the existing process.

Secondly, you need continuously learning AI. You want it to reflect changes in your system as fast as possible

Lastly, you need a service that speaks your language. Your supplier A has an ID 1234 in your database. It would be nice if AI would tell you: “It is an invoice from supplier 1234.”. It would eliminate OCR errors and at least one database query.

All of that can be achieved with typless – the continuously learning AI for data extraction.

Let’s take a look at the example.

Prerequisites

To easily follow, we suggest that, before reading further, you do these following steps:

  1. Register at typless
  2. Log in
  3. Click the Settings tab in the side navigation bar to get API key
  4. Create a new document type named example:
    • Click on the Documents tab in the side navigation bar
    • Click on the +New button
    • For the name set “example”
    • For the OCR language select “English”
    • Click on the Next button
    • Leave fields as they are and click on the Confirm button
  5. Get code of the example Django project from this Github repository
Copy to Clipboard
  • Set the API key:
Copy to Clipboard
  • To install requirements:
Copy to Clipboard
  • To run the development server:
Copy to Clipboard

Expenses tracking

Let’s say we, Awesome company Inc., track our expenses with a simple application which allows us to:

  • see the list of our suppliers
  • add a new supplier
  • see the list of received invoices
  • add a new received invoice
  • see details of the selected received invoice
  • confirm the received invoice

Although we are an Awesome company, we are still lazy. So we’ve decided to automate our data entry from received invoices. We want to keep our process the same, but we want to eliminate keystrokes. So what to do? We need a data extraction service. We’ve searched the web and decided to go with typless. So how to integrate it to meet the needs mentioned above?

Integrate into existing workflow

We don’t want to change our existing process. Nonetheless, we don’t want to mess our code too much. Before we added data extraction, our code in views looked like this:

Copy to Clipboard

Nothing special. When we added a newly received invoice file, we created a new ReceivedInvoice instance by calling form.save(). Then user was redirected to the details page to enter missing data and confirm the invoice. Therefore we’ve decided to added typless data extraction request after form.save(). Code now looks like this:

Copy to Clipboard

We’ve added a single API call in which we uploaded the invoice file and selected the document type. (We’ve created a document type named “example” following steps at the beginning of this guide.) After the response is returned, the ReceivedInvoice instance is updated with extracted data.

Test data extraction

If you haven’t already run the development server:

Copy to Clipboard

and visit localhost:8000.

There are no suppliers yet. So add two of them:

  • CircleCI with bank transfer as the payment method
  • ScaleGrid with a credit card as the payment method

You will find example invoices in the folder named examples. Click on Received invoices link in the navigation bar. Choose file circleci1.pdf and click Submit.

After clicking Submit, you will land on the received invoice details page.

But hey, invoice data fields are still empty! Didn’t we just add data extraction? Of course, they are, typless has never been learning from your data. Let’s do it.

Continuously learning AI

typless needs to learn to extract data. Similar to data extraction, we can add continuous learning into our process. Before we added typless, code looked like this:

Copy to Clipboard

Instance was just updated with the data from the request. As for data extraction, continuously learning of AI, needs a single REST API call. We’ve decided to insert it after instance update. Code now looks like this:

Copy to Clipboard

If we take a look we can see:

  • we added single API call
  • we used data from our instance which is saved in the database

Confirm values and test extraction again

Now enter missing data into the form at received invoice details page and click on the Confirmbutton. Return to received invoices list by clicking on link Received invoices in the navigation bar. Choose file circleci2.pdf and click on the Submit button.

You should see that the extracted data are full and correct. Why is that? Because typless have learned from you.

You can try the same flow with scalegrid1.pdf and scalegrid2.pdf from example invoices. You can even use your invoices.

Conclusion

We have learned how to integrate typless, the continuously learning AI, into the existing workflow.

What we’ve achieved:

  • workflow stays the same
  • typless is learning from values in our database
  • We have eliminated manual data entry
  • typless has learned to return the ID of supplier for a direct database update

To do that you need to integrate the following steps:

  • Request on data extraction endpoint when the user adds a new PDF invoice
    • Save extracted data
    • Save object_id from the response
  • Request on learning endpoint when the user confirms data
    • Use object_id from data extraction

That’s all! Happy OCRing!