Data Extraction

Retrieval-Augmented Generation (RAG) vs Data Extraction

While similar, RAG and Data Extraction are fundamentally different in their use cases and desired goals.

RAG is combines information retrieval with generative AI to create responses based on relevant context. RAG is ideal for answering specific questions or generating context-aware responses from a large corpus, like handling FAQs, policy summaries, or dynamic information.

Let’s consider a practical example using an employee policy document that contains information about work-from-home guidelines, employee benefits, and leave policies.

For a RAG-based system, the user might ask a question, such as:

How much paid time off does an employee with 5 years of service receive?

The system might then respond with an answer:

Employees with 5 years of service are eligible for 20 days of paid time off per year. Leave requests should be submitted at least two weeks in advance, and PTO is restricted during company-wide blackout periods

RAG provides contextual responses in natural language, suitable for conversational or FAQ-type applications.

Data extraction aims to extract structured data information from documents (e.g., names, dates, specific values) without generating responses. The goal is to capture and structure data for easier access and analysis.

Using the previous example when querying from an employee policy document containing work-from-home policy, an user might query the document for "PTO detail". After which, a data extraction system might give back a JSON data as follow:

"pto_details" : {
    "years_of_service": 5,
    "pto_amount": "20 days", 
    "notice_requirement": "2 weeks", 
    "black_out_applied?": true
}

Data Extraction gives structured data outputs, ideal for populating databases, automating forms, or generating reports where individual fields are needed without additional narrative context.


Data Extraction using ColiVara

Step 1: Client Setup

Install the colivara-py SDK library

If using Jupyter Notebook:

If using the command shell

Step 2: Prepare Documents

1

Download Files: Download the desired files to your machine. This code specifically will download them into your docs/ folder

2

Upload Files to be procesed: Sync documents to the ColiVara server. The server will process these files to generate the necessary embeddings

3

(Optional) Verify that documents have been processed by ColiVara: Documents have been convert into "screenshots" to generate embeddings

If using Jupyter Notebook:

If using the a Python code editor (such as VSCode):

Step 3: Extract data

1

Install the LLM of choice. Here, we are using OpenAI's GPT model

If using Jupyter Notebook:

If using the command shell:

2

Extract the JSON data

The result output data should be:

Last updated

Was this helpful?