Skip to main content

Cortex

Test different models with SQL

This example demonstrates how you can run a SQL query that produces an output from Cortex’s COMPLETE method, testing different model versions for various customers. Winning Variant is used to determine which model should be used per customer ID. Later, we would tie business KPIs (i.e., revenue, churn, returns, etc) back to each variant to see which model should be deployed. We have the following declared for this example:
  • A 50/50 test between control (llama3.2-1b model) and treatment (claude-3-5-sonnet)
  • The Winning Variant experiment ID is cortex-test
  • The ID of your user in this example is abc123

ML Models

This following examples demonstrate how you would use Winning Variant to run predictions for a set of customers using two model versions from the Snowflake Model Registry. The experiment has the following definition:
  • A 50/50 test between control (v1 of our model) and treatment (v2)
  • Winning Variant experiment ID of ml-test
customer_test_data in these examples contains the following fields:
  • customer_id: ID of the customer
  • age: how long the customer has been a customer
  • usage: some arbitrary integer that defines how much the customer has used the product
The sample model customer_churn_model has been trained to predict churn given an age and usage for a customer. The “Python (Simple)” example below uses the Winning Variant Python SDK.