Skip to content

Cortex Sentiment🔗

Editions

Production use of this feature is available for specific editions only. Contact our sales team for more information.

The Cortex Sentiment transformation component uses Snowflake Cortex to analyze English-language input text and return a sentiment for that text.

The returned sentiment is one of the following strings:

  • unknown: The component cannot determine the sentiment.
  • positive: The sentiment is positive.
  • negative: The sentiment is negative.
  • neutral: The sentiment is neither positive nor negative.
  • mixed: The sentiment is both positive and negative.

To use this component, you must use a Snowflake role that has been granted the SNOWFLAKE.CORTEX_USER database role. Read Required Privileges to learn more about granting this privilege.

To learn more about Snowflake Cortex, such as availability, usage quotas, managing costs, and more, read Large Language Model (LLM) Functions (Snowflake Cortex).

Use case🔗

This component can be used to analyze responses in a number of industries. The Example section of this guide shows how it could be used in the hospitality industry to analyze reviews of a coffee shop. You could also use it to analyze online product reviews, customer satisfaction survey responses, or employee engagement survey answers, to name a few examples.


Properties🔗

Name = string

A human-readable name for the component.


Columns = dual listbox

Use the arrow buttons or use drag-and-drop to move the columns you want to analyze into the right-hand listbox. A new sentiment column is created for each column that is analyzed.


Include Input Columns = boolean

  • Yes: Outputs both your source input columns and the sentiment columns. This will also include those input columns not selected in Columns.
  • No: Only includes the new sentiment column(s) generated for the selected Columns.

Example🔗

A coffee shop has been collecting customer reviews left on a website, and wants to obtain a sentiment for each review so that they can more easily sort them and focus on their positive and negative reviews. Today's reviews look like this:

Input data:

COFFEE_TYPE REVIEW
Espresso The espresso was bold and aromatic, but a tad too bitter for my taste. The barista was friendly, though, and the atmosphere was cozy.
Cappuccino My cappuccino was perfectly balanced, with a creamy foam that melted in my mouth.
Latte The latte was velvety smooth, but it lacked the flavor I was hoping for. The barista was friendly, and the ambiance was pleasant.
Americano The Americano was strong and robust, just how I like it. However, the service was a bit impersonal, and the coffee could have been hotter.
Mocha Indulging in the mocha was like sipping on liquid chocolate bliss. The ambiance was nice and the staff were friendly.
Cold Brew The cold brew tasted a bit watered down. The service was lacking, with long wait times and a disorganized atmosphere.
Macchiato The macchiato was the perfect balance of bold espresso and creamy foam. Unfortunately, the service was slow, and the coffee was lukewarm.
Flat White The flat white was silky smooth, but it lacked the depth of flavor I was expecting. The barista was friendly, though, and the atmosphere was cozy.
Turkish Coffee The Turkish coffee was rich and aromatic. The service was prompt, and the ambiance was charming.
Pour Over The pour-over coffee was fine.

The shop can use the Cortex Sentiment component to generate a sentiment from the review text. The sentiment indicates the level of negative or positive sentiment in the input text, and can then be used to sort the reviews.

Cortex Sentiment component properties:

  • Columns: REVIEW
  • Include Input Columns: YES

By setting Include Input Columns to YES, the original columns from the table will be kept as part of the pipeline run, and the sentiment column is appended to the end of the table.

Output data:

COFFEE_TYPE REVIEW sentiment_REVIEW
Espresso The espresso was bold and aromatic, but a tad too bitter for my taste. The barista was friendly, though, and the atmosphere was cozy. mixed
Cappuccino My cappuccino was perfectly balanced, with a creamy foam that melted in my mouth. positive
Latte The latte was velvety smooth, but it lacked the flavor I was hoping for. The barista was friendly, and the ambiance was pleasant. mixed
Americano The Americano was strong and robust, just how I like it. However, the service was a bit impersonal, and the coffee could have been hotter. mixed
Mocha Indulging in the mocha was like sipping on liquid chocolate bliss. The ambiance was nice and the staff were friendly. positive
Cold Brew The cold brew tasted a bit watered down. The service was lacking, with long wait times and a disorganized atmosphere. negative
Macchiato The macchiato was the perfect balance of bold espresso and creamy foam. Unfortunately, the service was slow, and the coffee was lukewarm. mixed
Flat White The flat white was silky smooth, but it lacked the depth of flavor I was expecting. The barista was friendly, though, and the atmosphere was cozy. mixed
Turkish Coffee The Turkish coffee was rich and aromatic. The service was prompt, and the ambiance was charming. positive
Pour Over The pour-over coffee was fine. neutral