Skip to content

Latest commit

 

History

History
136 lines (78 loc) · 6.4 KB

improving-accuracy.md

File metadata and controls

136 lines (78 loc) · 6.4 KB
description Enhance extraction accuracy with Retrieval-Augmented Generation (RAG) using your own documents.
icon layer-group

Continuous Learning (RAG)

Overview

When using an Extraction Model, sometimes the result accuracy is not satisfying on a given document or a particular template.

If you have already followed the data-schema-best-practices.md, and results are still not satisfactory, all hope is not lost.

You can reliably improve the performance of the model for the next inferences made by using the RAG feature.

{% embed url="http://app.supademo.com/demo/cmfb3c7166gdc39ozj39wogrz" %}

Basics of RAG Inner Workings

Retrieval-Augmented Generation or RAG, is an approach in artificial intelligence that combines the strengths of retrieval-based models with generative LLM text production.

Essentially, RAG leverages a rich database of source documents and embeddings to augment the knowledge base from which it draws responses. This means that the system retrieves specific and context-based data snippets and then uses them to generate semantic and fine-tuned responses that are both creative and factually accurate.

Overall Steps of RAG

  1. Annotating a given sample, which means giving the model the difference between the extracted data and the expected value(s). When activated, this example will be added to the RAG Database for the future.
  2. Retrieval: When a next document will be send with the RAG option activated, the model will try to search for a similar example in the existing database. The question here is : "Maybe there is an existing example where I need to follow the instructions so that I'm not doing a same mistake again". If no example found, no need to augment the prediction. If an examples is matched in the RAG Database, here comes step 3.
  3. Augmented Generation: A document was matched in the RAG Database. The model will use the instructions you gave on the RAG sample to make a better prediction this time. The prediction generated is augmented with an existing context helping the model to be better this time.

RAG process overview

Set Up the RAG Database

To use RAG on a given Extraction Model, you'll need to first set up the RAG database which will contain your documents and annotation data. You only need a single document to get started.

Access the database by clicking on the "Continuous Learning (RAG)" link in the model's configuration section.

From there, click the "Add a document" button to upload files to the RAG database. Only add files that have problematic responses which could not be resolved by improving the Data Schema.

When uploading the file, you can add free-form tags to help identify or classify the document. For example you could tag based on geography, provider, problem type, etc.

You need to annotate the document, selecting the fields you want to be covered by the RAG augmentation on this template. You can also add additional guidelines using plain language.

{% hint style="success" %} Most of the time, the annotation is sufficient to make the model understand the issue.
We recommend using the guideline only when the annotation doesn't solve the problem. {% endhint %}

Once this document is annotated, be sure to validate it.

Once validated, the document will be active. From now on, files sent for processing that match the document will have their results augmented with the annotations in the RAG database.

To test this, go to the Live Test page.

Ideally, find a document with the same template (another invoice from the same supplier for instance), but not the exact same one added to the RAG database.

Upload the document to the Live Test, leaving "Show RAG extraction" checked.

You will see the before/after predictions, this allows validating that the RAG annotations were taken into account when processing the document.

For documents that do not match the annotated document, the behavior remain the same, which means that RAG is improving the result with no regression on other documents.

To see which documents are being used, in the database the columns "Matched" and "Last Matched" indicate how many times the document was used and the last time it was used, respectively.

Activate RAG

{% include "../../.gitbook/includes/feature-need-good-data-schema.md" %}

Activate RAG on the Platform

{% include "../../.gitbook/includes/default-optional-features.md" %}

Click on "Data Schema" then "Optional Features" tab. There you can activate the "RAG Processing" feature.

Activate RAG via API Calls

{% include "../../.gitbook/includes/api-optional-features.md" %}

Searching for RAG Documents

You can filter the RAG documents displayed in the interface, based on a variety of criteria:

  • tags
  • filename
  • upload date
  • status

This is done through the "Filters" button at the top of the document list.

Frequently Asked Questions

How is my data protected during RAG processing?

Your data remains private and isolated within your model.

All documents and annotations added to your RAG database are encrypted in transit.

Is my RAG data shared with other users or sold to 3rd parties?

No, never.

RAG data is only accessible to the users of the organization that the model belongs to.

Mindee never sells data to 3rd parties.

All storage and retrieval of RAG data is done on Mindee's dedicated servers.

Does Mindee use my RAG data for training?

No, all documents are the property of their organization and are not used for training Mindee models.

We only use RAG data internally with your explicit knowledge and prior consent. This is limited to using your documents to help resolve a ticket you opened with our support team.

What happens to my RAG database if I downgrade my plan?

We won't delete any of the files you've uploaded into your RAG document database if you downgrade, however you will not be able to modify or validate them.

The guidelines you have given to your RAG documents will be taken into account in your inferences with the lower plan, even if that is above the plan's features.