Automatic Prompt and Model Optimization for Snowflake AI Functions
Automatically tune prompts and models in AI functions using labeled datasets and scoring metrics.
O que mudou
AI function optimization enables searching for improved implementations of custom AI functions by evaluating alternative model and prompt candidates against a consistent dataset and scoring metric.### Use casesImagine you have a support ticket classification AI function and want to reduce costs without losing accuracy. The feature helps to:- Evaluate multiple model candidates using the same data and scoring criteria.- Identify the most cost-efficient model meeting quality requirements.- Generate alternative prompt and model configurations without manual rewriting.- Create a reusable, optimized AI function from the selected result.### How to useTo run an optimization, create the experiment with a YAML specification and execute it.sqlCREATE OR REPLACE EXPERIMENT my_db.my_schema.redact_opt_exp TYPE = 'AI_FUNCTION_OPTIMIZATION' FROM SPECIFICATION $$function: function_name: "my_db.my_schema.redact(VARCHAR)"metrics: - name: redaction_matchdataset: name: my_db.my_schema.redaction_ds version: v1 column_mapping: argument_mapping: text: text_col ground_truth: expected_outputoptimization: models: - claude-haiku-4-5 reflection_model: claude-sonnet-4-5 strategy: quality_first budget: ultra-light$$;EXECUTE EXPERIMENT my_db.my_schema.redact_opt_exp;What happens in this code:1. Creates an experiment of type AI_FUNCTION_OPTIMIZATION pointing to the existing function.2. Defines the evaluation metric and versioned dataset with column mappings.3. Lists the candidate model and the reflection model used to generate improvements.4. Executes the experiment asynchronously on serverless compute.After running the experiment, inspect results and promote the best implementation:sqlSHOW RUNS IN EXPERIMENT my_db.my_schema.redact_opt_exp;SHOW RUN METRICS IN EXPERIMENT my_db.my_schema.redact_opt_exp RUN ITER_7;CREATE OR REPLACE AI FUNCTION my_db.my_schema.redact_tuned(text VARCHAR) RETURNS VARCHAR FROM EXPERIMENT my_db.my_schema.redact_opt_exp RUN ITER_7;What happens in this code:1. Lists all runs and generates the experiment report.2. Displays metrics for a specific run to check performance.3. Creates a new reusable AI function based on the chosen candidate.### What it returnsField | Description---|---val_score | Quality score on the validation split (0 to 1).test_score | Quality score on the held-out test split for frontier runs.cost_compared_to_seed | Candidate cost relative to the initial seed baseline.is_frontier | Indicates whether the candidate belongs to the quality/cost frontier.run_type | Run type (seed, accepted, or rejected).model | Model used by the candidate.function_impl | Tuned implementation generated.### Limitations and requirements- Stage: Public Preview.- Target must be an AI function created with CREATE AI FUNCTION; plain SQL UDFs are rejected.- The function must contain exactly one AI_COMPLETE call.- The dataset must be a versioned SNOWFLAKE.ML.DATASET object with a maximum of 1,000 rows.- Requires experiment creation privileges and the SNOWFLAKE.CORTEX_USER role.
- cortex ai
- ai function optimization
- ai_complete
- machine learning
- snowflake
September 21, 2026: Cortex AI Function Optimization for more efficient AI implementations (Public Preview)
Resumo e explicação gerados por IA a partir da release note oficial. Em caso de dúvida, a documentação oficial da plataforma prevalece.
Relacionadas
- SnowflakeGA
Geração de documentos em PDF, Word e PowerPoint no Snowflake CoWork
O Snowflake CoWork agora gera arquivos PDF, Word, PowerPoint e HTML diretamente de suas análises usando a ferramenta de execução de código do Cortex Agent.
snowflake cowork · cortex agent - SnowflakePublic Preview
Cortex Agent SDK para Python e TypeScript no Snowflake
O Cortex Agent SDK permite criar aplicações que utilizam Cortex Agents e Cortex Code em Python e TypeScript.
cortex agents · python - SnowflakeAtualização
Mensagens de erro mais detalhadas na classificação de dados sensíveis
A view DATA_CLASSIFICATION_LATEST agora traz mensagens de erro específicas e códigos do Snowflake para falhas na classificação.
data governance · trust center