SnowPro Specialty: Gen AI Question 257
Single answerCortex LLM functionsA retail analytics team stores customer reviews in a Snowflake table and wants to classify each review into one of four labels: POSITIVE, NEGATIVE, NEUTRAL, or ESCALATE. They need a solution implemented entirely in SQL using Snowflake Cortex LLM functions, and they want the model output to be consistently machine-readable so it can be inserted into downstream reporting tables without fragile text parsing. Which approach is the best fit for this requirement?
- A
Use SNOWFLAKE.CORTEX.COMPLETE with a prompt that asks the model to return a JSON object containing a single field named label, then parse that JSON in SQL before inserting it into the reporting table.
- B
Use SNOWFLAKE.CORTEX.SENTIMENT because it returns one of the four required business labels directly and avoids any prompt engineering.
- C
Use SNOWFLAKE.CORTEX.SUMMARIZE on each review first, then map the summary text to one of the four labels with a CASE expression.
- D
Use SNOWFLAKE.CORTEX.EMBED_TEXT_768 and assign the label based on the largest embedding value in the returned vector.
Show answer and explanation
Correct answer: A
Explanation
The key requirement is to perform classification entirely in SQL while producing structured, machine-readable output suitable for downstream inserts without brittle parsing. Among Cortex LLM functions, SNOWFLAKE.CORTEX.COMPLETE is the best fit because it supports prompt-driven generation for custom tasks such as business-specific classification. A strong implementation pattern is to constrain the prompt to a small fixed label set and request structured JSON output, which can then be parsed and validated in SQL. By contrast, specialized functions such as SNOWFLAKE.CORTEX.SENTIMENT are useful only for their intended built-in task and do not replace custom classification logic when business labels extend beyond sentiment. Similarly, SUMMARIZE is not a classifier, and EMBED_TEXT_768 is designed for embeddings-based semantic use cases rather than direct label assignment. This aligns with Snowflake best practices: use specialized Cortex functions for their specific tasks, and use COMPLETE when you need flexible instruction-following behavior for custom outputs in SQL.
- A. Correct.
Correct. SNOWFLAKE.CORTEX.COMPLETE is the appropriate Cortex LLM function when you need flexible prompt-based generation or classification in SQL. By instructing the model to return a tightly defined JSON structure, the team can make the output more predictable and easier to consume in downstream SQL pipelines. This is a common practical pattern for LLM-powered classification when the required labels are business-specific and do not map directly to a specialized built-in function.
- B. Incorrect.
Incorrect. SNOWFLAKE.CORTEX.SENTIMENT is intended for sentiment analysis, not arbitrary multi-class business labeling. While it may help identify positive or negative tone, it does not natively return a custom label set such as POSITIVE, NEGATIVE, NEUTRAL, or ESCALATE as a business workflow output. A candidate might choose this because some of the labels resemble sentiment classes, but ESCALATE is a workflow decision rather than a standard sentiment output.
- C. Incorrect.
Incorrect. SNOWFLAKE.CORTEX.SUMMARIZE is for summarization, not deterministic classification. Summarizing first adds unnecessary cost and complexity and still leaves the team with a fragile second step that attempts to infer labels from free-form summary text. Someone might pick this if they believe reducing the text first improves classification, but it does not address the requirement for consistently machine-readable labels.
- D. Incorrect.
Incorrect. SNOWFLAKE.CORTEX.EMBED_TEXT_768 generates embeddings for semantic similarity and vector-based retrieval use cases. The returned vector is not interpreted by taking the largest numeric value to derive a class label. This option reflects a common misconception that embeddings directly produce categorical predictions without a separate similarity, clustering, or model-based classification step.