Snowflake Gen AI Functions · Topic 15 of 26
Unstructured Data Analysis with AI_PARSE_DOCUMENT, AI_EXTRACT, AI_SIMILARITY and AI_COMPLETE
Choose between AI_PARSE_DOCUMENT, AI_EXTRACT, AI_SIMILARITY and AI_COMPLETE to analyze documents, text and images stored on a Snowflake stage.
- 4 min
AI_PARSE_DOCUMENTmodes:OCR(default),LAYOUT(Markdown with tables),AGENTIC(Preview).AI_EXTRACTreturnsresponseanderror, with 125 pages per file without cross region inference.AI_SIMILARITYreturns -1 to 1 and needs two inputs of the same type.
What it is
Unstructured data is files and free text: PDFs, scans, images, emails and notes. Snowflake analyzes it with Cortex AI functions that you call from SQL. Files stay on a stage and you point to them with a FILE value made by TO_FILE.
The four functions in this topic solve four different problems, and the exam asks you to choose.
| Function | Job | Returns |
|---|---|---|
AI_PARSE_DOCUMENT | Turn a document into text or Markdown | JSON string with content |
AI_EXTRACT | Pull specific fields, lists or tables | JSON with response and error |
AI_SIMILARITY | Score how alike two texts or two images are | FLOAT from -1 to 1 |
AI_COMPLETE | Free form reasoning over text, images or documents | Text or structured object |
How it works
AI_PARSE_DOCUMENT
It reads a document on a stage and returns its content. The call is AI_PARSE_DOCUMENT(<file>, <options>).
| Option | Values and default |
|---|---|
mode | OCR (default, text only), LAYOUT (text plus structure such as tables, output as Markdown), AGENTIC (Preview, interprets charts and diagrams) |
page_split | TRUE or FALSE (default FALSE); works only for PDF, .pptx and .docx |
extract_images | Needs LAYOUT mode |
page_filter | Array of start and end page objects, zero based, end exclusive |
SELECT PARSE_JSON(
AI_PARSE_DOCUMENT(TO_FILE('@docs', 'contract.pdf'), {'mode': 'LAYOUT'})
):content::STRING AS markdown;
The result is a JSON string, so wrap it in PARSE_JSON. A failed row returns NULL and does not stop the query. Use LAYOUT when tables matter and when the text will be chunked for search.
AI_EXTRACT
Use it when you know what you want out of the document: an invoice number, a date, a table of line items. You pass the file and a responseFormat.
SELECT AI_EXTRACT(
file => TO_FILE('@docs', 'invoice.pdf'),
responseFormat => {'invoice_no': 'What is the invoice number?',
'total': 'What is the total amount?'}
) AS result;
The result is a JSON object with a response key holding your fields and an error key. The responseFormat can be an object of label to question, an array of questions, or a JSON schema for lists and tables. Limits from the docs: files under 100 MB, 125 pages per file (1,000 with cross region inference), up to 100 entity questions per call, and 10 table questions. It accepts PDF, Word, PowerPoint, images, HTML, text and more. AI_EXTRACT replaces the older EXTRACT_ANSWER.
Fixed fields from a document point to AI_EXTRACT. A summary or an opinion about a document points to AI_COMPLETE.
AI_SIMILARITY
It compares two inputs by the cosine similarity of their embeddings and returns a FLOAT from -1 to 1. Both inputs must be text, or both must be images. Text and image cannot be mixed.
The default model is snowflake-arctic-embed-l-v2.0 for text and voyage-multimodal-3 for images. An optional config object sets the model. Typical uses are duplicate detection, matching a product photo to a catalog photo, and ranking candidates against a reference.
AI_COMPLETE on unstructured data
AI_COMPLETE accepts text, and for models that support it also images and documents (for example .pdf, .txt and .md). With files you build the prompt with PROMPT and refer to files by {0}, {1}:
SELECT AI_COMPLETE('claude-sonnet-4-5',
PROMPT('Summarize this report: {0}', TO_FILE('@docs', 'report.pdf')));
Not every model accepts images or documents, so check the model list before choosing. Audio and video are not accepted by AI_COMPLETE.
Choosing quickly
- Need text out of a scan or PDF for later steps:
AI_PARSE_DOCUMENT. - Need known fields, lists or tables:
AI_EXTRACT. - Need "how close are these":
AI_SIMILARITY. - Need judgment, summary or classification in free text:
AI_COMPLETE.
Common mistakes
Using AI_COMPLETE where AI_EXTRACT is built for the job. Extraction gives a predictable JSON shape.
Forgetting PARSE_JSON on the parse result. It is a JSON string, not a VARIANT.
Setting page_split on a plain image or text file. It supports only PDF, .pptx and .docx.
Comparing a text with an image in AI_SIMILARITY. That is not supported.
FILE values do not work for files on internal stages with SNOWFLAKE_FULL encryption, on user or table stages, or on stages with client side encryption. Use a server side encrypted stage.
What to remember for the exam
AI_PARSE_DOCUMENTmodes:OCR(default),LAYOUT(Markdown with tables),AGENTIC(Preview).AI_EXTRACTreturnsresponseanderror, with 125 pages per file without cross region inference.AI_SIMILARITYreturns -1 to 1 and needs two inputs of the same type.TO_FILEbuilds the FILE value from a stage and a path.- Callers need the
USE AI FUNCTIONSprivilege and theSNOWFLAKE.CORTEX_USER(orAI_FUNCTIONS_USER) database role;USE AI FUNCTIONSandCORTEX_USERare granted to PUBLIC by default.
Check yourself
Which
AI_PARSE_DOCUMENTmode returns tables as Markdown?LAYOUTmode.Which function pulls an invoice total and date from a PDF into named fields?
AI_EXTRACT.Can
AI_SIMILARITYcompare a text string with an image?No, both inputs must be text or both must be images.
Topic 15 of 26 in Snowflake Gen AI Functions
Test yourself on Snowflake Gen AI Functions
The full Snowflake GES-C02 question bank has 585 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Snowflake. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.