import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
Introduction
Mistral AI's open and commercial models can be leveraged from the Snowflake Cortex platform as fully managed endpoints. Mistral models on Snowflake Cortex are serverless services so you don't have to manage any infrastructure.
As of today, the following models are available:
- Mistral Large
- Mistral 7B
For more details, visit the models page.
Getting started
The following sections outline the steps to query the latest version of Mistral Large on the Snowflake Cortex platform.
Getting access to the model
The following items are required:
- The associated Snowflake account must be in a compatible region (see the region list in the Snowflake documentation).
- The principal that is calling the model must have the
CORTEX_USER
database role.
Querying the model (chat completion)
The model can be called either directly in SQL or in Python using Snowpark ML.
It is exposed via the
COMPLETE
LLM function.
1 For local execution you need to:
2 - Create a virtual environment with the following package:
3 - `snowflake-ml-python` (tested with version `1.6.1`)
4 - Ensure that you have a [configuration file](https://docs.snowflake.com/en/user-guide/snowsql-config)
5 with the proper credentials on your system. The example below assumes that you have a named connection
6 called `mistral` that is configured appropriately.
7
8 ```python
9 from snowflake.snowpark import Session
10 from snowflake.ml.utils import connection_params
11 from snowflake.cortex import Complete
12
13 # Start session (local execution only)
14 params = connection_params.SnowflakeLoginOptions(connection_name="mistral")
15 session = Session.builder.configs(params).create()
16
17 # Query the model
18 prompt = "Who is the best French painter? Answer in one short sentence."
19 completion = Complete(model="mistral-large2", prompt=prompt)
20 print(completion)
21 ```
22</TabItem>
Going further
For more information and examples, you can check the Snowflake documentation for:
- LLM functions
- The API of the
COMPLETE
function in SQL and Python.