For an existing legacy-function Retrieval-Augmented Generation (RAG) workflow, a staged document exceeds the completion context window.
Arrange the functions shown in the answer area in the correct order to extract and chunk the document text, retrieve relevant chunks for a user query, and generate a response using the retrieved context.
Assume that the user query is also embedded using the same embedding model.
Select the appropriate function for each step in the answer area.

Reveal Solution
Discussion
Correct Answer:

Explanation:
Order
Correct selection
Order 1
PARSE_DOCUMENT
Order 2
SPLIT_TEXT_RECURSIVE_CHARACTER
Order 3
EMBED_TEXT_768
Order 4
VECTOR_COSINE_SIMILARITY
Order 5
CORTEX.COMPLETE
Comprehensive and Detailed Explanation From SnowPro Specialty: Gen AI topics:
Snowflake supports Retrieval-Augmented Generation (RAG) workflows by combining document processing, text chunking, vector embeddings, similarity calculations, and LLM inference.
First, PARSE_DOCUMENT extracts textual content from the staged document. Next, SPLIT_TEXT_RECURSIVE_CHARACTER divides the extracted text into manageable chunks, addressing the LLM's context window limitations. EMBED_TEXT_768 converts each text chunk into a 768-dimensional vector representation.
The user query is embedded using the same embedding model, ensuring that the query and document vectors occupy the same embedding space. VECTOR_COSINE_SIMILARITY then measures semantic similarity between the query vector and document chunk vectors to identify the most relevant content.
Finally, CORTEX.COMPLETE receives the user query and retrieved document chunks as contextual input to generate a grounded response. This workflow improves response relevance and reduces the risk of hallucinations without requiring model fine-tuning.