-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathW3_snowflake_cortex_LLM_functions.sql
45 lines (40 loc) · 2.37 KB
/
W3_snowflake_cortex_LLM_functions.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
---> use the mistral-7b model and Snowflake Cortex Complete to ask a question
SELECT SNOWFLAKE.CORTEX.COMPLETE(
'mistral-7b', 'What are three reasons that Snowflake is positioned to become the go-to data platform?');
---> now send the result to the Snowflake Cortex Summarize function
SELECT SNOWFLAKE.CORTEX.SUMMARIZE(SNOWFLAKE.CORTEX.COMPLETE(
'mistral-7b', 'What are three reasons that Snowflake is positioned to become the go-to data platform?'));
---> run Snowflake Cortex Complete on multiple rows at once
SELECT SNOWFLAKE.CORTEX.COMPLETE(
'mistral-7b',
CONCAT('Tell me why this food is tasty: ', menu_item_name)
) FROM FROSTBYTE_TASTY_BYTES.RAW_POS.MENU LIMIT 5;
---> check out what the table of prompts we’re feeding to Complete (roughly) looks like
SELECT CONCAT('Tell me why this food is tasty: ', menu_item_name)
FROM FROSTBYTE_TASTY_BYTES.RAW_POS.MENU LIMIT 5;
---> give Snowflake Cortex Complete a prompt with history
SELECT SNOWFLAKE.CORTEX.COMPLETE(
'mistral-7b', -- the model you want to use
[
{'role': 'system',
'content': 'Analyze this Snowflake review and determine the overall sentiment. Answer with just \"Positive\", \"Negative\", or \"Neutral\"' },
{'role': 'user',
'content': 'I love Snowflake because it is so simple to use.'}
], -- the array with the prompt history, and your new prompt
{} -- An empty object of options (we're not specify additional options here)
) AS response;
---> give Snowflake Cortex Complete a prompt with a lengthier history
SELECT SNOWFLAKE.CORTEX.COMPLETE(
'mistral-7b',
[
{'role': 'system',
'content': 'Analyze this Snowflake review and determine the overall sentiment. Answer with just \"Positive\", \"Negative\", or \"Neutral\"' },
{'role': 'user',
'content': 'I love Snowflake because it is so simple to use.'},
{'role': 'assistant',
'content': 'Positive. The review expresses a positive sentiment towards Snowflake, specifically mentioning that it is \"so simple to use.\'"'},
{'role': 'user',
'content': 'Based on other information you know about Snowflake, explain why the reviewer might feel they way they do.'}
], -- the array with the prompt history, and your new prompt
{} -- An empty object of options (we're not specify additional options here)
) AS response;