Welcome back to our Snowflake + AI series, where we’ve been peeling back the layers of how prompt engineering actually works inside your data warehouse. Today, we’re getting hands-on — tuning the knobs that shape how your AI sounds, behaves, and sometimes… argues with you.
Because just like a guitar amp, an AI model in Snowflake Cortex has dials. Turn them too high, and you’ll get noise. Too low, and your outputs will B Flat.

Tuning the Temperature: Creativity vs. Control
The temperature parameter in Snowflake’s CORTEX.COMPLETE() function is your creativity slider.
It defines how “random” or “predictable” your AI’s responses are.
- Low temperature (0.0–0.3) → Consistent, boring, good for structured answers (like generating SQL).
- Medium (0.4–0.7) → A mix of logic and flair, somewhere between prog-rock precision and KISS showmanship.
- High (0.8–1.0) → Creative, unhinged, maybe too chatty — think freestyle jazz.
Example:
SELECT CORTEX.COMPLETE(
'mistral-large',
OBJECT_CONSTRUCT(
'prompt', 'Write a short limerick about Snowflake data warehouses',
'temperature', 0.9
)
) AS ai_output;
Output:
There once was a schema so tight,
That queries all ran in one night.
With Cortex in play,
AI led the way,
And storage was feathered and light.
Want Cortex to summarize a meeting transcript like a data exec? Stay under 0.5.
Want it to generate a new company slogan based on your warehouse schema? Crank it up and let Freddie Mercury take the mic.
Max Tokens: Keeping the Song from Going Too Long
max_tokens sets the ceiling on how many tokens (think: words and symbols) your AI can generate.
- Set it too low, and your answers get cut off mid-sentence.
- Set it too high, and you’re paying for the AI to ramble about your schema’s feelings.
Example:
SELECT CORTEX.COMPLETE(
'mistral-large',
OBJECT_CONSTRUCT(
'prompt', 'Explain Snowflake’s Time Travel in two sentences.',
'max_tokens', 100
)
) AS ai_output;
This keeps things concise — like a radio edit instead of a 47-minute prog-rock solo.
System vs. User Prompts: The Lead Singer and the Band
When you use Snowflake Cortex, you can define both system and user instructions.
Think of the system prompt as the “band’s style,” and the user prompt as the “song request.”
Example:
SELECT CORTEX.COMPLETE(
'mistral-large',
OBJECT_CONSTRUCT(
'system_prompt', 'You are a helpful Snowflake DBA who always answers with SQL examples.',
'prompt', 'How do I find the size of a table?',
'temperature', 0.4
)
) AS ai_output;
Output:
SELECT TABLE_NAME, BYTES/1024/1024 AS SIZE_MB
FROM INFORMATION_SCHEMA.TABLE_STORAGE_METRICS;
Dialing in your system prompt sets the tone across your entire session. It’s like telling the AI: “We’re not doing death metal today — play it smooth.”
Prompt Chaining: Building Setlists
If you want your AI to remember context across queries (say, analyzing text then summarizing results), you can chain prompts together using tables or variables.
Example:
CREATE OR REPLACE TABLE ai_stage AS
SELECT CORTEX.COMPLETE(
'mistral-large',
OBJECT_CONSTRUCT(
'prompt', 'Summarize this sales note: ' || NOTE_TEXT,
'temperature', 0.3
)
) AS SUMMARY
FROM SALES_NOTES;
Then run a follow-up query using those summaries for sentiment analysis.
Just like sequencing tracks for an album — you’re shaping an overall experience.
Pro Tip: Use Variables for Reusable “Presets”
If you’re calling Cortex from stored procedures or tasks, define your common settings once:
SET base_params = OBJECT_CONSTRUCT(
'temperature', 0.5,
'max_tokens', 300
);
SELECT CORTEX.COMPLETE(
'mistral-large',
OBJECT_INSERT($base_params, 'prompt', 'Explain micro-partitioning in one paragraph.')
);
That’s your AI preset — consistent tone, reusable logic, and way easier governance.
Coming Up Next: Cost and Chaos
Next time, we’ll talk about how to keep your AI pipelines lean and predictable — batching prompts, caching results, and evaluating outputs so you’re not spending “Money for Nothing.”
Until then, keep your queries clean and your prompts clever.
Because when it comes to AI tuning inside Snowflake, as Journey said — Don’t Stop Believin’.
Leave a Reply
You must be logged in to post a comment.