Unlock Unstructured Data with Snowflake Document AI (DocAI)

Updated on Jul 13,2025

Table of Contents

In today's data-driven landscape, organizations are constantly seeking ways to extract valuable insights from their data. A significant portion of enterprise data remains unstructured, residing in formats like PDFs, images, and emails. Snowflake's Document AI (DocAI) offers a revolutionary solution to this challenge, transforming unstructured data into actionable knowledge. This article explores how to leverage Snowflake DocAI to unlock the potential hidden within your organization's documents, enabling better decision-making and fostering innovation with AI.

Key Points

80% of enterprise data is unstructured, hindering analysis.

Snowflake DocAI extracts insights from PDFs, images, and emails.

DocAI uses zero-shot learning models for easy data extraction.

DocAI transforms unstructured data into queryable tables within Snowflake.

DocAI empowers data-driven decisions across various industries.

Understanding the Unstructured Data Challenge and Document AI

The Prevalence of Unstructured Data

It's commonly acknowledged that a staggering 80% of enterprise data exists in an unstructured format.

This data often resides in PDFs, images, videos, and emails, making it difficult for traditional data processing tools to extract meaningful insights. This vast reservoir of untapped information sits idle, representing a significant bottleneck for organizations across industries. The challenge lies in the inability to easily search, analyze, and integrate this data with structured information, hindering decision-making and stifling innovation. Understanding Snowflake and it's possibilities with AI is very useful and powerful with data.

Without Document AI, accessing crucial insights from these sources requires manual effort, which is time-consuming, prone to errors, and costly. DocAI revolutionizes this process by providing an automated solution to unlock access to this previously inaccessible data.

Introducing Snowflake Document AI (DocAI)

Snowflake DocAI emerges as a powerful solution to address the unstructured data challenge.

It leverages cutting-edge artificial intelligence (AI) to extract meaningful information from documents, regardless of their format. Snowflake DocAI excels in processing PDFs, receipts, inventory specifications, and other document types, transforming them into structured data ready for analysis. DocAI leverages zero-shot learning models. Zero-shot learning enables DocAI to extract data without extensive training on specific document types, making it highly adaptable and efficient. Snowflake's Document AI offering is incredibly powerful for turning unstructured data into useful information.

Use Cases Across Industries

Use Cases Across Industries

Snowflake Document AI is poised to transform various industries by unlocking the potential of unstructured data:

  • Healthcare: Automate the extraction of patient data from medical records, improving efficiency and accuracy in patient care.
  • Finance: Streamline the processing of loan applications and financial documents, reducing turnaround time and enhancing decision-making.
  • Insurance: Accelerate claims processing by automatically extracting relevant information from claim forms and supporting documents.
  • Retail: Gain insights from customer feedback forms and product reviews, enabling businesses to improve product offerings and customer experiences.
  • Manufacturing: Extract key details from all engineering documentation to improve time to delivery.
  • Legal: Analyze contractual data at scale and extract critical clauses.

Step-by-Step Guide to Using Snowflake Document AI

Setting the Stage and Access Control for Document AI

Before diving into DocAI, it’s necessary to set up the Snowflake environment.

This involves creating a dedicated database, like invoicesdb, to keep the process organized. Setting up access controls for Document AI is crucial for granting the necessary permissions to the roles or users who will be working with it.

Here's how you can set it up:

USE ROLE accountadmin;

CREATE OR REPLACE ROLE doc_ai_role;
GRANT DATABASE ROLE SNOWFLAKE.DOCUMENT_INTELLIGENCE_CREATOR TO ROLE doc_ai_role;
GRANT USAGE ON DATABASE invoicesdb TO ROLE doc_ai_role;
GRANT USAGE ON DATABASE SNOWFLAKE_SAMPLE_DATA to ROLE doc_ai_role;
GRANT USAGE ON SCHEMA invoicesdb.public TO ROLE doc_ai_role;
GRANT USAGE, OPERATE ON WAREHOUSE demo_wh TO ROLE doc_ai_role;

GRANT CREATE STAGE ON SCHEMA invoicesdb.public TO ROLE doc_ai_role;
GRANT CREATE SNOWFLAKE.ML.DOCUMENT_INTELLIGENCE ON SCHEMA invoicesdb.public TO ROLE doc_ai_role;

GRANT CREATE STREAM, CREATE TABLE, CREATE TASK, CREATE VIEW ON SCHEMA invoicesdb.public TO ROLE doc_ai_role;
GRANT EXECUTE TASK ON ACCOUNT TO ROLE doc_ai_role;

GRANT ROLE doc_ai_role TO USER demo_user; -- Replace 'demo_user' with your Snowflake username

Storing and Preparing Invoice Data

For this demonstration, a sample invoice dataset is utilized, obtained from a GitHub repository.

These invoices vary in layout and format, allowing us to demonstrate how Snowflake AI can adapt to different document structures. Preparing this invoice data involves creating an external stage and then a Snowflake stage to load the data into your Snowflake environment.

  • Create External Stage: Use the following script to create an external stage:

    CREATE OR REPLACE STAGE DEMOHUB_S3_STG
    URL = 's3://demohubpublic/data/invoices/'
    DIRECTORY = (ENABLE = TRUE)
    COMMENT = 'Demohub S3 datasets';
  • Create Snowflake Stage: Next, create a Snowflake stage:

    CREATE OR REPLACE STAGE invoices_stg
    DIRECTORY = (ENABLE = TRUE)
    ENCRYPTION = (TYPE = 'SNOWFLAKE_SSE');
  • Copy Data: Copy data from the S3 stage to the Snowflake stage:

    COPY FILES INTO @invoices_stg
    FROM @DEMOHUB_S3_STG;
  • Refresh the Snowflake stage:

    ALTER STAGE invoices_stg REFRESH;

Pro Tip: Enable encryption (Server-Side Encryption) for added security

Training Custom AI Models in Snowsight

Although Snowflake Document AI provides a powerful pre-trained model, fine-tuning it to specific document types and extraction needs is crucial for optimal performance.

Here is how you do it. Snowsight’s intuitive web interface provides a streamlined way to train, version, and publish models.

  1. Access Document AI: In Snowsight, navigate to AI & ML > Document AI.
  2. Select Your Model: Choose the model you want to train from the list of existing builds.
  3. Upload Documents: Upload a set of representative documents for training. Ensure these documents are labeled with the correct information you want to extract.
  4. Label Fields (Optional): If your model requires more specific training, manually label the relevant fields in the documents within Snowsight.
  5. Start Training: Click the “Train Model” button. Snowflake will process your labeled documents and fine-tune the model’s parameters.
  6. Monitor Progress: Monitor the training progress in Snowsight. This typically involves evaluating the model’s performance on a separate set of validation documents.
  7. Iterate (Optional): If the model’s accuracy isn’t satisfactory, iterate on the training process by adding more labeled documents, refining labels, or adjusting model parameters.

Pro Tip: Prompt Design is crucial for accurate and effective data extraction, you can either use

  • Direct Prompts: Concise questions like “What is the bill to name?” or “What is the invoice Number?
  • Elaborate Prompts: More natural language-oriented questions like “Who is the billing being sent to?” or “What is the reference number for this invoice?

Testing Document AI Predictions

With the data in place, you can test Document AI’s predictions on a few sample invoices.

SELECT invoicesdb.public.DocAI:predict(
get_presigned_url(@invoices_stg, relative_path, 1), 1)
FROM DIRECTORY(@invoices_stg) limit 2;

This is just a test of the out of the box model. Snowflake gives you complete flexibility for your data analysis.

Storing and Processing Predictions

Here is how to store and process the predictions:

CREATE OR REPLACE TABLE Invoices_fields AS
SELECT *,
invoicesdb.public.DocAI:predict(
get_presigned_url(@invoices_stg, relative_path), 1) as predictions
FROM DIRECTORY(@invoices_stg) limit 10;

Flatten the JSON results into a usable table by using the following SQL code.

CREATE OR REPLACE TABLE Invoices AS
SELECT
predictions:ORDER_ID:value::STRING as ORDER_ID,
predictions:BILL_TO:value::STRING as BILL_TO,
predictions:SHIP_TO:value::STRING as SHIP_TO,
predictions:DATE:value::STRING as DATE,
predictions:INVOICE_NUMBER:value::STRING as INVOICE_NUMBER,
predictions:ITEM_NAME:value::STRING as ITEM_NAME,
predictions:QUANTITY:value::STRING as QUANTITY,
predictions:ITEM_RATE:value::STRING as ITEM_RATE,
predictions:SUBTOTAL:value::STRING as SUBTOTAL,
predictions:DISCOUNT_AMT:value::STRING as DISCOUNT_AMT,
predictions:ITEM_AMT:value::STRING as ITEM_AMT,
predictions:SHIPPING_AMT:value::STRING as SHIPPING_AMT,
predictions:TOTAL_AMOUNT:value::STRING as TOTAL_AMOUNT,
predictions:BALANCE_DUE:value::STRING as BALANCE_DUE,
predictions:SHIP_MODE:value::STRING as SHIP_MODE,
predictions:NOTES:value::STRING as NOTES,
FILE_URL
FROM invoices_fields;

Creating Views for Analysis

Let’s create a view to focus on high-value invoices shipped via “First Class”:

CREATE OR REPLACE VIEW high_value_invoices AS
SELECT
ORDER_ID,
ITEM_NAME,
TOTAL_AMOUNT,
BALANCE_DUE,
SHIP_MODE,
QUANTITY,
ITEM_RATE
FROM Invoices
WHERE SHIP_MODE = 'First Class'
AND CAST(TOTAL_AMOUNT AS DECIMAL) > 100;

This view allows to easily query and analyze these specific invoices.

Pros and Cons of Snowflake Document AI

👍 Pros

Automated Data Extraction: DocAI automates the process of extracting data from unstructured documents, reducing manual effort and saving time.

High Accuracy: Leverages advanced AI models to achieve high accuracy in data extraction, even from complex layouts.

Zero-Shot Learning: Adapts to new document types without extensive training, making it efficient and scalable.

Seamless Integration: Integrates seamlessly with Snowflake's data platform, enabling end-to-end data management.

Enhanced Decision-Making: Unlocks valuable insights from unstructured data, empowering organizations to make better decisions.

Improved Compliance: Snowflake ensures compliance to industry standards.

👎 Cons

Model Accuracy: AI model, although it may not have the needed data.

Data Volume: Organizations need to upload +20 sample documents for more accurate results.

Cost: Snowflake resource costs may increase.

Frequently Asked Questions (FAQs)

What types of documents can Snowflake DocAI process?
Snowflake DocAI is designed to process a wide range of document types, including PDFs, receipts, contracts, invoices, and more. Its adaptable AI models can be trained to handle various document formats and layouts.
Does DocAI require extensive training data for each document type?
No, DocAI leverages zero-shot learning models, enabling it to extract data without extensive training. This makes it highly efficient and adaptable to new document types.
How does DocAI ensure data security and compliance?
Snowflake's robust security features protect DocAI, ensuring data encryption, access control, and compliance with industry regulations. Data privacy is a top priority.
Can DocAI integrate with existing data pipelines and workflows?
Yes, DocAI seamlessly integrates with Snowflake's data platform, allowing organizations to incorporate extracted data into existing pipelines and workflows, facilitating end-to-end data management.

Related Questions

How Does Snowflake's Document AI Compare to Traditional OCR Solutions?
Traditional Optical Character Recognition (OCR) solutions often struggle with the variability of real-world documents, requiring extensive manual intervention and pre-processing to achieve acceptable accuracy. Snowflake Document AI, on the other hand, leverages advanced deep learning models that are pre-trained on vast datasets of documents. This enables DocAI to automatically adapt to different layouts, fonts, and image qualities, significantly reducing the need for manual effort and improving the accuracy of data extraction. DocAI is more robust and accurate. Traditional OCR systems typically rely on fixed templates and rule-based algorithms. This can lead to failures when encountering document layouts that deviate from the pre-defined templates. Document AI, with its sophisticated AI models, can learn patterns and relationships within the document structure, enabling it to accurately extract data even from complex and variable layouts. This is particularly advantageous when dealing with diverse document types like invoices from different vendors or handwritten forms. DocAI offers a zero-shot learning advantage. Traditional OCR solutions often require manual labeling and training for each specific document type, consuming significant time and resources. DocAI’s zero-shot learning capabilities enable it to extract relevant information from unseen document types without any prior training, drastically accelerating the deployment process. DocAI makes unstructured data easy to query at scale.

Most people like