What are sentiment analysis and sentiment prediction?
Sentiment analysis is the interpretation of queries or content to determine some of their subjective aspects, such as emotions, intentions, opinions, and so on, using machine learning. Sentiment analysis produces a sentiment model that Fusion can use to perform sentiment prediction. Since stronger sentiments can be positive or negative while a weaker sentiment is more neutral, sentiment analysis uses the positive/negative polarity to measure a sentiment’s strength:Intelligent applications with sentiment analysis and prediction
When you assign sentiment values to incoming queries or to documents at indexing time, you can leverage that data to deliver more insight to your business applications. Understanding the intent and sentiment of customers or employees can help determine which information you deliver or how you treat subsequent interactions in the workflow. This kind of intelligence is valuable for e-commerce, call centers, social media, or surveys.Pre-trained sentiment models
Lucidworks provides two pre-trained sentiment models that you can deploy to get started:sentiment-general:v1.0 | sentiment-reviews:v1.0 |
---|---|
A general-purpose model, trained on short sentences. Suitable for short texts and for intent prediction. See Deploy the sentiment-general Model for instructions. | A model trained on a variety of customer reviews. Optimized for longer texts. It also supports highlighting the tokens that provide stronger sentiment. See Deploy the sentiment-reviews Model for instructions. |
Deploy the sentiment-general Model
Deploy the sentiment-general Model
This topic explains how to deploy the sentiment-general pre-trained sentiment prediction model. This is a general-purpose sentiment prediction model, trained on short sentences. It is suitable for short texts and for intent prediction.
Install the model in Fusion
- Navigate to Collections > Jobs.
- Select New > Create Seldon Core Model Deployment.
-
Configure the job as follows:
- Job ID. The ID for this job, such as
deploy-sentiment-general
. - Model Name. The model name of the Seldon Core deployment that will be referenced in the Machine Learning pipeline stage configurations, such as
sentiment-general
. - Docker Repository. The value is
lucidworks
. - Image Name. The value is
sentiment-general:v1.0
. - Kubernetes Secret Name for Model Repo. This value is left empty.
- Output Column Names for Model. The value is
[label, score]
.
- Job ID. The ID for this job, such as
- Click Save.
- Click Run > Start.
If you are running a private Docker repository that virtualizes external images, enter your private registry into the Docker Repository field and
lucidworks/sentiment-general:v1.0
into the Image Name field.Configure the Machine Learning pipeline stages
In your index or query pipelines add Machine Learning stage and specify sentiment-general in the Model ID field (or a custom model name that was used during deployment).Configure the Machine Learning index stage
- In your index pipeline, click Add a Stage > Machine Learning.
-
In the Model ID field, enter the model name you configured above, such as
sentiment-general
. -
In the Model input transformation script field, enter the following:
-
In the Model output transformation script field, enter the following:
- Save the pipeline.
Configure the Machine Learning query stage
- In your query pipeline, click Add a Stage > Machine Learning.
- In the Model ID field, enter the model name you configured above, such as sentiment-general.
-
In the Model input transformation script field, enter the following:
-
In the Model output transformation script field, enter the following:
- Save the pipeline.
Model output
Both of the pre-trained models output the following:- a label,
negative
orpositive
- a score from
-2
to2
Deploy the sentiment-reviews Model
Deploy the sentiment-reviews Model
This topic explains how to deploy the sentiment-reviews pre-trained sentiment prediction model. This model is trained on a variety of customer reviews and optimized for longer texts. It also supports attention weights output that can be used for highlighting the tokens that provide stronger sentiment; see Model output below for an example.
Install the model in Fusion
- Navigate to Collections > Jobs.
- Select New > Create Seldon Core Model Deployment.
- Configure the job as follows:
- Job ID. The ID for this job, such as
deploy-sentiment-reviews
- Model Name. The model name of the Seldon Core deployment that will be referenced in the Machine Learning pipeline stage configurations, such as
sentiment-reviews
. - Docker Repository. The value is
lucidworks
. - Image Name. The value is
sentiment-reviews:v1.0
. - Kubernetes Secret Name for Model Repo. The value is left empty.
- Output Column Names for Model. The value is
[label, score, tokens, attention_weights]
.
- Job ID. The ID for this job, such as
- Click Save.
- Click Run > Start.
Configure the Machine Learning pipeline stages
You can put your sentiment prediction model to work using the Machine Learning index stage or Machine Learning query stage. You will specify the same Model Name that you used when you installed the model above.Generally, you only need to apply the model in the index pipeline, in order to perform sentiment prediction on your content. Optionally, you can configure the query pipeline in a similar way, to perform sentiment prediction on incoming queries and outgoing responses and apply special treatment depending on the prediction.Configure the Machine Learning index stage
- In your index pipeline, click Add a Stage > Machine Learning.
- In the Model ID field, enter the model name you configured above, such as
sentiment-reviews
. - In the Model input transformation script field, enter one of the following, depending on whether you want to output attention weights:
Without attention weights:With attention weights: - In the Model output transformation script field, enter the following:
Without attention weights:With attention weights: - Save the pipeline.
Optional: Configure the Machine Learning query stage
- In your query pipeline, click Add a Stage > Machine Learning.
- In the Model ID field, enter the model name you configured above, such as sentiment-reviews.
- In the Model input transformation script field, enter the following:
Without attention weights:With attention weights: - In the Model output transformation script field, enter the following, noting the sections that need to be uncommented if you are using attention weights:
- Save the pipeline.
Model output
Both of the pre-trained models output the following:- a label,
negative
orpositive
- a score from
-2
to2
These models support the English language only.
Model output
Both of the pre-trained models output the following:- a label,
negative
orpositive
- a score from
-2
to2