SnowPro Specialty: Gen AI Question 225
Single answerCOMPLETE (SNOWFLAKE.CORTEX)A retail analytics team is building an internal SQL-based workflow that uses SNOWFLAKE.CORTEX.COMPLETE to generate short product-summary text from catalog data. The team must minimize prompt injection risk from free-form product descriptions stored in a table, keep responses easy to parse in downstream SQL steps, and avoid unnecessary token usage. Which approach is the MOST appropriate?
- A
Construct the prompt by clearly separating trusted instructions from untrusted product-description text, explicitly tell the model to ignore instructions found inside the product description, and constrain the output to a short JSON structure.
- B
Put the entire task, formatting rules, and product description into a single natural-language paragraph so the model can infer which parts are instructions and which parts are data.
- C
Rely on COMPLETE to automatically sanitize prompt injection attempts in the product-description field, so no special prompt design or output constraints are needed.
- D
Ask the model to produce a long explanatory answer first and then post-process it in SQL to extract the needed fields, because verbose outputs are more reliable than concise structured outputs.
Show answer and explanation
Correct answer: A
Explanation
The best answer is to use prompt-engineering controls appropriate for SNOWFLAKE.CORTEX.COMPLETE in a production SQL workflow: clearly separate trusted instructions from untrusted table content, instruct the model to treat the embedded text as data rather than executable instructions, and request a compact structured response such as JSON. This approach aligns with common LLM best practices for reducing prompt injection risk and improving machine-readability. In Snowflake Cortex workflows, COMPLETE is used to generate text from prompts, but secure and reliable behavior still depends heavily on how prompts are constructed. For practical implementations, teams should minimize unnecessary output length to control token costs, use deterministic output formats when downstream SQL must parse results, and validate generated content before further use.
- A. Correct.
Correct. This is the best applied approach when using SNOWFLAKE.CORTEX.COMPLETE with untrusted text from a table. Separating system-like instructions from user-provided data reduces the chance that embedded text in the product description overrides task intent. Explicitly telling the model to treat the product description as data and ignore instructions inside it is a practical prompt-engineering safeguard. Requiring a short JSON response also improves downstream parsing in SQL workflows and reduces token consumption compared with verbose free-form output.
- B. Incorrect.
Incorrect. Mixing instructions and untrusted data in one undifferentiated paragraph increases ambiguity and makes prompt injection more likely to succeed. It also makes formatting less deterministic, which is problematic when downstream SQL logic depends on consistent output structure.
- C. Incorrect.
Incorrect. COMPLETE does not remove the need for secure prompt design. Developers should not assume that the model automatically neutralizes malicious or misleading text contained in input columns. Prompt injection mitigation still requires explicit delimiting of untrusted content, careful instructions, and validation of outputs.
- D. Incorrect.
Incorrect. Producing long free-form text increases token usage and typically makes SQL parsing harder, not easier. For operational pipelines, concise structured output is a best practice because it is less expensive, easier to validate, and more reliable for downstream transformations.