Skip to main content

๐Ÿ˜€ Sentiment Analysis

Use the Sentiment Analysis skill with ๐Ÿ”˜ Select to classify the polarity of a given text.

The sentiment_analysis skill is designed to classify text as negative, neutral, or positive.

It uses the ๐Ÿ”˜ Select endpoint, which requires you to specific candidates that are used for classification. In order to use the skill, the candidates need to be: ["-", "0", "+"], with

  • - if the expressed opinion is negative,
  • 0 if it is neutral,
  • + if it is positive.

In this short guide, learn how to use the sentiment_analysis skill with lyra-en. We assume here that the reader is familiar with the parameters of Select, as well as with the Python Bindings: for more information, check out the ๐Ÿ”˜ Select, and Python Bindings documentation pages. We start by initializing the client with the following code.

Examplesโ€‹

We start by initializing the client with

from lightonmuse import Select

selector = Select("lyra-en")

From there, using the skill is straightforward:

output = selector("The video you showed me really got me scared", ["-", "+", "0"], skill="sentiment_analysis",)
print(output[0][0]['best'])

returns, as expected

-

while a more neutral prompt

output = selector("Mary told John to check his mailbox", ["-", "+", "0"], skill="sentiment_analysis",)
print(output[0][0]['best'])

returns

0

Good luck classifying your own text!