Get startedGet started for free

Batch classifying multiple reviews

Your sentiment analysis pipeline works well on one review. Now it's time to handle multiple reviews in one batch. This is a key step before analyzing user feedback at scale.

This exercise is part of the course

Natural Language Processing (NLP) in Python

View Course

Exercise instructions

  • Initialize a pipeline for sentiment-analysis using "distilbert-base-uncased-finetuned-sst-2-english".
  • Use the pipeline to classify all reviews in the review_batch list.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

from transformers import pipeline

classifier = pipeline(task="sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")

review_batch = [
    "Absolutely love the new design!",
    "The app crashes every time I open it.",
    "Customer support was helpful and quick.",
    "Too many ads make it unusable.",
    "Everything works fine, but it’s a bit slow."
]

# Classify sentiments
results = ____
print(results)
Edit and Run Code