Predict Text Sentiment with Hugging Face and MindsDB
In this tutorial, we’ll use a model from the Hugging Fae hub to predict text sentiment.
Connect a database
We start by connecting a demo database using the CREATE DATABASE
statement.
Let’s preview the user_comments
table.
Create a Hugging Face model
Our Hugging Face integration automatically manages downloading and deploying of pre-trained transformers from Hugging Face’s hub. For example, we can download a transformer which has been trained to classify the sentiment of text.
To create a model in MindsDB, we use the CREATE MODEL
statement. Next, we define the target column using the PREDICT clause. Finally, we specify all required parameters in the USING
clause.
Once the above query is executed, we can check the status of the creation process:
Make predictions
Once the status is complete, the behavior is the same as with any other AI table you can query it and provide input data in the WHERE
clause, like this:
The above query should predict the comment as ‘positive’.
We can also make batch predictions by joining the input data table with the model, like this: