Snowflake for Gen AI · Topic 7 of 13

Gen AI Capabilities: Prompting, AI Functions, Embeddings and Context Windows

Outline Snowflake Gen AI capabilities: prompting AI_COMPLETE, the Cortex AI functions, vector embeddings with AI_EMBED and similarity, and context windows.

  • 4 min
In a nutshell
  • Pick the task function by verb; AI_COMPLETE is the generic one.
  • Conversation roles (older COMPLETE): system, user, assistant; options temperature, top_p, max_tokens, guardrails.
  • AI_EMBED makes vectors; 768 or 1024 dimensions by model.

What it is

This page is the capability map for the Cortex AI functions. The exam asks you to pick the right function for a task, write a sound prompt, choose an embedding approach and respect model limits. Cortex AI functions (also called AISQL) are SQL functions that call hosted models, so a model call becomes part of a normal query.

Promptinstructions and dataAI functionSQLruns onHosted modelinside SnowflakereturnsColumn valuetext, JSON, vector

How it works

Prompting

A prompt is the text you send to the model. For AI_COMPLETE it is a single string or a prompt object built with PROMPT. The older COMPLETE function also accepts a conversation of messages with the roles system, user and assistant: the system message sets behavior, the user message carries the task and data, and assistant messages hold earlier replies in a multi turn exchange. Models do not remember between calls, so send the history each time.

Model options control the output.

OptionEffect
temperatureHigher values give more varied text; low values are more predictable
top_pLimits choices to the most likely tokens
max_tokensCaps the length of the reply
guardrailsFilters unsafe responses

Good prompts state the task, the format and the data separately. Examples inside the prompt (few shot prompting) improve consistency. The PROMPT helper builds a prompt object from a template, so you can pass columns and images into the prompt. Use AI_COUNT_TOKENS to check input size.

Exam tip

When the exam asks how to get a repeatable answer, lower the temperature and give a clear format instruction. Prompt wording is cheaper than a new model.

Cortex AI functions

TaskFunction
Free form generationAI_COMPLETE
Assign labelsAI_CLASSIFY
True or false filterAI_FILTER
Pull named fieldsAI_EXTRACT
SentimentAI_SENTIMENT
Summary of one valueAI_SUMMARIZE
Summary across rowsAI_SUMMARIZE_AGG, AI_AGG
TranslateAI_TRANSLATE
Hide personal dataAI_REDACT
Audio or video to textAI_TRANSCRIBE
Read a documentAI_PARSE_DOCUMENT
EmbeddingsAI_EMBED, AI_MULTI_EMBED
Compare two inputsAI_SIMILARITY

AI_COMPLETE is the updated form of COMPLETE. The functions that work on one row run per row, so they scale with the table. The aggregate functions AI_AGG and AI_SUMMARIZE_AGG work across rows and are not subject to context window limits.

Error handling differs by function. AI_PARSE_DOCUMENT, for example, returns NULL for a failed row by default without stopping the query, and its optional return_error_details argument returns the error in an object when set to TRUE.

SELECT review_id,
       AI_CLASSIFY(review_text, ['praise','complaint','question']) AS category
FROM reviews;

Vector embedding

An embedding turns text or an image into a vector of numbers so that similar meaning gives close vectors. AI_EMBED(model, text) creates one, and EMBED_TEXT_768 and EMBED_TEXT_1024 are the older text functions. The result goes in a VECTOR(FLOAT, 768) style column.

ModelDimensionsContext
snowflake-arctic-embed-m-v1.5768512 tokens
snowflake-arctic-embed-l-v2.01024512 tokens
voyage-multilingual-2102432,000 tokens

Compare vectors with VECTOR_COSINE_SIMILARITY, VECTOR_L2_DISTANCE, VECTOR_INNER_PRODUCT or VECTOR_L1_DISTANCE. Cosine similarity compares direction and is the usual choice for meaning. Embedding functions bill on input tokens, while the similarity functions have no token based cost.

DocumentstextAI_EMBEDVECTOR column768 or 1024VECTOR_COSINE_SIMILARITYTop matchesORDER BY LIMITpromptAI_COMPLETEanswer

Context windows

A context window is the most tokens a model can handle in one call, counting the prompt and the reply. If the input is too long the call returns an error, so long documents must be chunked. The embedding models above have 512 token windows except voyage-multilingual-2, which allows 32,000 and is the pick for long passages and multilingual text.

Watch out

A bigger context window costs more tokens and adds latency. Chunk and retrieve instead of pasting a whole document into every prompt.

Common mistakes

Mixing embedding models. Vectors from different models are not comparable, and dimensions must match the column.

Assuming memory across calls. Resend the conversation each time.

Ignoring context limits. Long text needs chunking or an aggregate function.

Using AI_COMPLETE for everything. A task function is simpler and often cheaper.

Reading cosine similarity as distance. Higher cosine similarity means more alike; for L2 distance, lower means more alike.

What to remember for the exam

  • Pick the task function by verb; AI_COMPLETE is the generic one.
  • Conversation roles (older COMPLETE): system, user, assistant; options temperature, top_p, max_tokens, guardrails.
  • AI_EMBED makes vectors; 768 or 1024 dimensions by model.
  • voyage-multilingual-2 has the 32,000 token window; the other models in the table have 512.
  • Aggregate functions are not limited by context windows.
  • AI_COUNT_TOKENS checks input size.

Check yourself

  • Which function gives a single summary across many rows?

    AI_SUMMARIZE_AGG (or AI_AGG for a prompt based insight), which are not limited by context windows.

  • Which embedding model suits long multilingual passages?

    voyage-multilingual-2, with a 32,000 token context.

  • How do you make completions more predictable?

    Lower the temperature and give a clear output format.

Topic 7 of 13 in Snowflake for Gen AI

Test yourself on Snowflake for Gen AI

The full Snowflake GES-C02 question bank has 585 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Snowflake. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.