Skip to main content
Production use of this feature is available for specific editions only. Contact our sales team for more information.
The Cortex Completions transformation component uses Snowflake Cortex to receive a prompt and then generate a response (a completion) using your chosen supported language model. To use this component, you must use a Snowflake role that has been granted the SNOWFLAKE.CORTEX_USER database role. Read Required Privileges to learn more about granting this privilege. To learn more about Snowflake Cortex, such as availability, usage quotas, managing costs, and more, read Large Language Model (LLM) Functions (Snowflake Cortex).

Use case

This component enables you to integrate generative AI output into your transformation pipeline to enrich your data. For example, you can use it to:
  • Analyze customer feedback from reviews or survey responses—the example below demonstrates this use case.
  • Automatically classify incoming documents in the legal or financial sector.
  • Convert medical notes from a range of formats into standardized ICD codes.

Properties

string
required
A human-readable name for the component.
drop-down
required
Select a language model from the drop-down menu. Review the Snowflake documentation for supported models, costs, and quotas.Read Availability for details about which models are available in which regions.
text editor
An initial plain-English prompt to your chosen language model to provide the model with background information and instructions for a style of response. An example of response steps offered by Snowflake is “Respond in the style of a pirate.”The language model doesn’t generate a response to your system prompt, but to your user prompt. The system prompt informs the model on how to answer the user prompt.Only one system prompt may be provided.To use variables in this field, type the name of the variable prefixed by the dollar symbol and surrounded by { } brackets, as follows: ${variable}. Once you type ${, a drop-down list of autocompleted suggested variables will appear. This list updates as you type; for example, if you type ${date, functions and variables containing date will be listed.
text editor
required
A plain-text prompt provided by the user. This prompt should be contextually relatable to the system prompt (if used).To use variables in this field, type the name of the variable prefixed by the dollar symbol and surrounded by { } brackets, as follows: ${variable}. Once you type ${, a drop-down list of autocompleted suggested variables will appear. This list updates as you type; for example, if you type ${date, functions and variables containing date will be listed.
column editor
Select the source columns to feed as input to the model.
  • Column Name: A column from the input table.
  • Descriptive Name (optional): An alternate descriptive name to better contextualize the column. Recommended if your column names are low-context.
floating point number
A value between 0 and 1 (inclusive) to control the randomness of the output of the language model. Higher temperatures (for example, 0.8) will result in more diverse and random outputs. Lower temperatures (for example, 0.2) make the output more focused and deterministic.
floating point number
A value between 0 and 1 (inclusive) to control the randomness of the output of the language model—typically used as an alternative to temperature.Top P restricts the set of possible tokens that the mode will output, whereas Temperature influences which tokens are chosen at each step.Many LLM models recommend altering Top P or Temperature, but not both.
integer
Set the maximum number of output tokens in the response. A small number of max tokens can result in truncated responses.
boolean
When set to Yes, responses that could be considered unsafe or harmful will be filtered out of the model’s output via Cortex Guard.
boolean
required
  • Yes: Outputs both your source input columns and the new completion columns. This will also include those input columns not selected in Inputs.
  • No: Only outputs the new completion columns.

Explanation of output

This component returns a string representation of a JSON object, containing the following keys:

Example

A coffee shop has been collecting customer reviews left on a web site, and wants to distill some key pieces of information from these reviews. The primary information wanted is: was the customer satisfied with the service? Input data: The shop can use the Cortex Completions component to ask a question (prompt) and receive an answer based on the review text given to the component. Cortex Completions component properties:
  • Model: llama2-70b-chat
  • System Prompt: [blank]
  • User Prompt: Was the customer satisfied with the service?
  • Inputs:
    • Column Name: REVIEW
    • Descriptive Name: [blank]
  • Temperature: [blank]
  • Top P: [blank]
  • Max Tokens: 6
  • Include Input Columns: YES
By setting Include Input Columns to YES, the original columns from the table will be kept as part of the pipeline run, and the completion_result column is appended to the end of the table. Output data (with completion_result column abbreviated for ease of illustration):