Text Sentiment Analysis and Context Understanding

InfoGenerateCreated ByPackages

The provided code is an SQL query that leverages a Snowflake function called `SNOWFLAKE.CORTEX.COMPLETE` to interact with the 'llama2-70b-chat' language model. The query sends two messages to the model: one from the 'system' role, which instructs the model to act as a helpful AI assistant and to understand the sentiment and context of the provided text, and one from the 'user' role, which contains the text for analysis. The model is expected to return a sentiment classification ('Positive', 'Negative', 'Neutral') along with a brief explanation of the sentiment. The result is aliased as 'response'.

SELECT SNOWFLAKE.CORTEX.COMPLETE(
    'llama2-70b-chat',
    [
        {'role': 'system', 'content': 'You are a helpful AI assistant. Understand the sentiment and context of the given text field. Answer with just "Positive", "Negative", "Neutral", and provide a brief explanation of what is happening.' },
        {'role': 'user', 'content': '<Your text field data here>'}
    ], {}
    ) as response;