SnowPro Specialty: Gen AI Question 148
Single answerCORTEX_PARSE_DOCUMENTA financial services team stores monthly account statements as PDF files in an internal stage. They need to extract the document contents into a structured representation that preserves layout cues such as headings, tables, and sections before passing the output to downstream LLM workflows in Snowflake. The team wants to do this directly in SQL with the Snowflake Cortex function designed for document parsing. Which approach best meets this requirement?
- A
Call SNOWFLAKE.CORTEX.PARSE_DOCUMENT on the staged PDF file and request markdown output so the parsed result retains structural elements useful for downstream GenAI processing.
- B
Call AI_COMPLETE on the staged PDF file directly, because it automatically parses binary documents and returns a structured JSON representation of the file.
- C
Use SPLIT_TEXT_RECURSIVE_CHARACTER on the PDF file in the stage first, because text chunking functions can parse binary documents and preserve table structure.
- D
Load the PDF into a VARCHAR column with COPY INTO, then call EMBED_TEXT_1024 on the raw PDF bytes to convert the document into a structured text format.
Show answer and explanation
Correct answer: A
Explanation
The best answer is to use SNOWFLAKE.CORTEX.PARSE_DOCUMENT against the staged PDF and select an output format appropriate for downstream use, such as markdown when structural fidelity matters. In Snowflake Cortex, document parsing is a distinct step from generation, chunking, or embedding. Best practice is to first extract the document into a machine-usable representation, then optionally chunk the resulting text and generate embeddings or prompts for LLM tasks. This reflects the documented separation of concerns across Cortex document parsing, text splitting, embedding, and completion functions.
- A. Correct.
Correct. CORTEX_PARSE_DOCUMENT is the Snowflake Cortex function intended for extracting content from documents such as PDFs stored in a stage. Requesting markdown output is appropriate when the goal is to preserve structural cues like headings, lists, and tables in a text-friendly format for retrieval, summarization, or other LLM workflows.
- B. Incorrect.
Incorrect. AI_COMPLETE is for text generation or response generation from prompts; it is not the document parsing function for binary PDF files in a stage. A common misconception is that a general LLM completion function can replace document extraction, but document parsing should be done first with the dedicated parsing function.
- C. Incorrect.
Incorrect. Text chunking functions such as SPLIT_TEXT_RECURSIVE_CHARACTER operate on text that has already been extracted. They do not parse binary PDFs from stages and are not responsible for preserving document layout during extraction.
- D. Incorrect.
Incorrect. EMBED_TEXT_1024 generates embeddings from text input, not from raw PDF bytes, and it does not transform binary documents into structured text. Also, simply loading raw PDF bytes into a VARCHAR column would not produce usable parsed content.