LLM Complete

The LLM Complete processor generates a response to an English-language prompt based on the selected large language model (LLM). Use this processor when you want to customize the style, language, or randomness of the results.

The processor uses the Snowflake LLM Complete function to generate the response based on the processor configuration. Note, however, that the processor supports only a single prompt. It does not support conversations with multiple prompts and responses.

When you configure the LLM Complete processor, you select the large language model to use. You specify a prompt that you want to generate a response to. You can optionally enter a system prompt that provides additional information to guide the style or language of the response.

You can define advanced options, such as specifying permitted randomness of the response or enabling guardrails to omit unsafe responses.

For more information about the Snowflake LLM Complete function and other Snowflake LLM functions, see the Snowflake documentation.

Note: At this time, Snowflake charges differently for LLM processing. See the Snowflake consumption rates for details.

Example

Say you have recipes submitted by users and want to determine what they make. To do this you can configure the LLM Complete processor as follows:
  • Model: llama3-70b
  • System Prompt: Answer in 2 or 3 words
  • Prompt: What does this recipe make? {Submission}
  • Output Column: Recipe
  • Extract Message: Enabled

With the following incoming data:

Email Submission
my@email.com Cream the butter, oil, and sugar in the bowl of a stand mixer. Add the eggs one at a time, beating well after each addition. Then, add your vanilla and stir to combine. Combine your dry ingredients in a separate bowl, then add about ⅓ of the mixture into your bowl. Use a spatula to gently stir until just combined. Follow this with about ½ of your buttermilk, and stir again until just combined. Add ½ of the remaining dry ingredients stir, and then add the remainder of the buttermilk. Finish with the final portion of dry ingredients and use your spatula to make sure the batter is smooth. Pour into a prepared pan and bake at 350 degrees until golden brown.
joe@email.com This traditional eggs benedict sauce is called hollandaise sauce. The ingredients are butter, egg yolks, lime juice, heavy cream, and salt and pepper. This is a more traditional method for making hollandaise sauce. Some people prefer to make hollandaise sauce in the blender, which would work well for this recipe. To make hollandaise sauce, start by melting butter in a saucepan. Meanwhile, beat egg yolks in separate bowl and add lime juice, heavy cream, and salt and pepper. Once the butter has melted, you’re ready to temper the eggs by adding a small amount of the hot butter to the egg mixture. Stir it well and repeat this process, slowly adding one spoonful of hot butter to the egg mixture. We do this to avoid curdling the eggs. Finally, add the mixture back to the saucepan and cook it for a few more seconds.
The processor passes the following output downstream:
Email Submission Recipe
my@email.com Cream the butter, oil, and sugar in the bowl of a stand mixer. Add the eggs one at a time, beating well after each addition. Then, add your vanilla and stir to combine. Combine your dry ingredients in a separate bowl, then add about ⅓ of the mixture into your bowl. Use a spatula to gently stir until just combined. Follow this with about ½ of your buttermilk, and stir again until just combined. Add ½ of the remaining dry ingredients stir, and then add the remainder of the buttermilk. Finish with the final portion of dry ingredients and use your spatula to make sure the batter is smooth. Pour into a prepared pan and bake at 350 degrees until golden brown. Cake recipe
joe@email.com This traditional eggs benedict sauce is called hollandaise sauce. The ingredients are butter, egg yolks, lime juice, heavy cream, and salt and pepper. This is a more traditional method for making hollandaise sauce. Some people prefer to make hollandaise sauce in the blender, which would work well for this recipe. To make hollandaise sauce, start by melting butter in a saucepan. Meanwhile, beat egg yolks in separate bowl and add lime juice, heavy cream, and salt and pepper. Once the butter has melted, you’re ready to temper the eggs by adding a small amount of the hot butter to the egg mixture. Stir it well and repeat this process, slowly adding one spoonful of hot butter to the egg mixture. We do this to avoid curdling the eggs. Finally, add the mixture back to the saucepan and cook it for a few more seconds. Hollandaise sauce

Note that changing property settings can greatly alter the generated response.

For example, without the system prompt requiring a shorter reply, the processor returns a more conversational response, such as:
This recipe makes Hollandaise sauce, a traditional eggs benedict sauce

Supported Large Language Models

The selected large language model determines how the processor generates responses. You can use the following models with the LLM Complete processor:
  • snowflake-arctic
  • llama2-70b-chat
  • llama3-8b
  • llama3-70b
  • gemma-7b
  • mistral-large
  • mistral-7b
  • mistra-8x7b
  • reka-core
  • reka-flash
For more information about working with these models, see the documentation for the model.
Important: Some models may only be available in certain regions. For details, see the Snowflake documentation.

Understanding Prompts

The prompts that you define for the LLM Complete processor determine the results that the processor generates.

You can include input columns in prompts by using the Select Column from Schema icon or by manually enclosing the column name in curly brackets, as follows: {<column>}.

Tip: Prompt styles for large language models can differ. Construct prompts appropriately for the model that you want to use. For details, see the documentation for the model.
The LLM Complete processor provides the following prompts:
Required prompt
Use the required Prompt property to specify an English-language prompt that you want the processor to use to generate the response.
For example, What does this recipe make? {<reference source column>}
Optional system prompt
Optionally use the System Prompt property to provide an English-language system prompt to provide additional instructions about how to generate the response or details on the style of the response.
For example, say you change the system prompt in the example above to the following: Respond like an 18th century philosopher. Then, the processor provides the following response for the hollandaise recipe:
My dear fellow, this recipe hath the makings of a most exquisite hollandaise sauce, a condiment of refinement and sophistication, fit for the most discerning of palates. 'Tis a sauce of rich, velvety texture, born of the union of butter, egg yolks, and cream, with a hint of lime juice to awaken the senses. A true delight, indeed!
Note: Though both prompts require using English for the prompt, the response can be in any language supported by the selected model.
For example, using the llama3-7b model in the example above, say you update the system prompt as follows: Respond in 2 or 3 words, in French. Then, the processor provides the following response for the hollandaise recipe:
Sauce hollandaise traditionnelle

Response Format

The response generated by the Snowflake LLM Complete function is a JSON object. By default, the LLM Complete processor extracts a plain text response from the JSON object. You can configure the processor to provide the full JSON response by clearing the Extract Message property.

For example, the full JSON response for the first row of the example above is as follows:
{
  "choices": [
    {
      "messages": "Cake recipe"
    }
  ],
  "created": 1724094076,
  "model": "llama3-70b",
  "usage": {
    "completion_tokens": 3,
    "prompt_tokens": 178,
    "total_tokens": 181
  }
}

By default, the Extract Message property is enabled and the processor writes Cake recipe to the output column.

If you want to use the entire JSON response in the pipeline, you simply clear the Extract Message property.

Output Column

The LLM Complete processor writes extracted answers into the column specified in the Output Column property as follows:
  • When you define an output column that does not exist in incoming data, the processor creates the column.
  • When you define an output column that exists, the processor overwrites the data in the column.

Configuring an LLM Complete Processor

Configure an LLM Complete processor to generate a response to an English-language prompt using a specified large language model.

  1. On the General tab, configure the following properties:
    General Property Description
    Name Stage name.
    Description Optional description.
    Cache Data Caches processed data.
  2. On the Complete tab, configure the following properties:
    Complete Property Description
    Model Large language model to use to respond to configured prompts.
    System Prompt Optional English-language prompt to provide additional information for the response or instructions for the response style.
    Prompt Primary English-language prompt to generate a response to.
    Output Column Column to write the generated response to.
    Extract Message Extracts a plain text response from the response JSON and writes it to the specified output column.

    When cleared, the processor passes the entire response JSON to the output column.

    Define Advanced Options Enables configuring advanced options.
    Temperature A value between 0 and 1 that determines how random the responses can be. Higher values allow a more random output.

    This property influences the selection of tokens at each step.

    Available when configuring advanced options.

    Top P A value between 0 and 1 that determines the diversity of the language used in the responses. Higher values allow a more diverse output.

    Can be used as an alternative to Temperature.

    Available when configuring advanced options.

    Max Tokens The maximum number of tokens to allow in a response. Smaller values can lead to truncated responses.

    When not specified, the processor uses the Snowflake default, which is 4096 at this time. For more information, see the Snowflake documentation.

    Available when configuring advanced options.

    Guardrails Filters out possibly unsafe or harmful responses from the results.

    Available when configuring advanced options.