Akhil D • about 2 years ago
Snowflake arctic model response as SQL for cortex complete function?
Hi am using snowflake cortex complete function with model as snowflake-arctic..but when I pass prompt and document text..it is returning response as sql statement instead of free text.It is working fine if I use different model like gemma Can u please help.
Comments are closed.

6 comments
Anna Filippova Manager • about 2 years ago
Hey Akdil! Thanks for your question!
Could you share a code snippet of how you are using the command? It will help me debug with you.
Akhil D • about 2 years ago
Hi Anna, please find the details
Code:
from snowflake.cortex import Complete, ExtractAnswer, Sentiment, Summarize, Translate
text = load_pdf('Files/ContractAgreement.pdf')
prompt = f"""Provide all dates along with event details from given text in form of json array with keys like Timestamp, EventType, EventDescription
in descending order of Timestamp: {text}"""
cortex_prompt = "'[INST] " + prompt + " [/INST]'"
print(Complete('snowflake-arctic', prompt))
Response:
SELECT * FROM XYZ CORPORATION LIMITED WHERE EventDate = '1st April, 2023'; AND EventDate = '1st April, 2023'; AND EventDate = '1st April, 2023';
Anna Filippova Manager • about 2 years ago
Thank you, very helpful!
While I work to reproduce this on my end, a simple thing you can try: rewriting the Complete command using parameters to force a JSON output to be returned. E.g. https://docs.snowflake.com/en/sql-reference/functions/complete-snowflake-cortex#controlling-temperature-and-tokens
Also, I would check if you mean to use "print(Complete('snowflake-arctic', cortex_prompt))" instead of print(Complete('snowflake-arctic', prompt))!
Akhil D • about 2 years ago
Hi Anna, I tried both ways but didn't work. Can you please help here?
Anna Filippova Manager • about 2 years ago
Hey Akhil! I'm not able to reproduce this with a different PDF. Can you sent your source file to me? You can find me in Discord @ annafilippova_65737
Akhil D • about 2 years ago
Hi Anna, sent request in discord