Automatically understand user sentiment in product reviews. Our multilingual product review model will analyze text passages and predict the number of stars ascribed to a given review on a scale from 1-5, with 1 representing the most negative sentiment and a 5 representing the most positive sentiment.
Getting Started
First things first. You will need to set up a Clarifai account and create an application. This how-to article shows you how to label images with the Clarifai API and through Portal. If you would like to label images via API, you will also need to generate an API key.
Moderate text in Portal
You can do almost anything that Clarifai can do with Clarifai Portal, and we work hard to make Portal the world's easiest interface for using AI. Classifying images with Portal is as simple as uploading your data, and choosing the right base workflow.
Create your application and choose your base workflow
Simply log in to Clarifai Portal and create a new application. To use the Product Review Sentiment model, select "Text" as your base workflow.
Create a new workflow and add the Product Review Sentiment model
Click on the "Model Mode" tab on the left hand side of the screen. Click the workflows tab. Click create a new workflow, select "clarifai" as the user and add the "product-review-sentiment-multi" model to your workflow.
View your text passage in Explorer view
Upload text to your application in data mode.
Click on one of your inputs and select your new workflow in the in the righthand sidebar under the tab that says "App Workflow".
Review Product Sentiment Via API
Use the following Python snippet as an example of how to use the Product Review Sentiment model via API. For more details and information on working with predictions in our other client languages, please refer to our API documentation.
from clarifai_grpc.grpc.api import service_pb2, resources_pb2 from clarifai_grpc.grpc.api.status import status_code_pb2 # This is how you authenticate. metadata = (('authorization', 'Key {{YOUR_CLARIFAI_API_KEY}}'),) post_model_outputs_response = stub.PostModelOutputs(
service_pb2.PostModelOutputsRequest(
model_id="{THE_MODEL_ID}",
version_id="{THE_MODEL_VERSION_ID}", # This is optional. Defaults to the latest model version.
inputs=[
resources_pb2.Input(
data=resources_pb2.Data(
text=resources_pb2.Text(
base64=file_bytes
)
)
)
]
),
metadata=metadata
)
if post_model_outputs_response.status.code != status_code_pb2.SUCCESS:
raise Exception("Post model outputs failed, status: " + post_model_outputs_response.status.description)
# Since we have one input, one output will exist here.
output = post_model_outputs_response.outputs[0]
print("Predicted concepts:")
for concept in output.data.concepts:
print("%s %.2f" % (concept.name, concept.value))