From the course: Applied AI: Getting Started with Hugging Face Transformers

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Predicting sentiment with Pipelines

Predicting sentiment with Pipelines

- [Instructor] Now that we have downloaded the artifacts for the sentiment analysis task let's use the pipeline to predict sentiment. Predicting sentiment is a simple one line of code. We simply call the sentiment classifier pipeline with the input text for which sentiment needs to be predicted. Under the hood, a lot of operations happen. This input is first tokenized using the default tokenizer for the pipeline. It is then vectorized with embeddings. Then the model is called. Because it's a bird model, it only uses the encoder stack of the transformer architecture. The model would predict probabilities for various sentiment classes. This was then decoded to the corresponding sentiment string and printed. The results contained the sentiment label, as well as the confidence score for the prediction. Let's run this code now and review the results. We can also try another example that returns a negative sentiment.…

Contents