BaşlayınÜcretsiz Başlayın

Embedding restaurant reviews

One common classification task that embeddings are great for is sentiment analysis. In this and the following exercises, you'll navigate through the workflow of performing sentiment analysis using embeddings.

You've been provided with a small sample of restaurant reviews, stored in reviews, and sentiment labels stored in sentiments:

sentiments = [{'label': 'Positive'},
              {'label': 'Neutral'},
              {'label': 'Negative'}]

reviews = ["The food was delicious!",
           "The service was a bit slow but the food was good",
           "The food was cold, really disappointing!"]

You'll use zero-shot classification to classify the sentiment of these reviews by embedding the reviews and class labels.

The create_embeddings() function you created previously is also available to use.

Bu egzersiz

Introduction to Embeddings with the OpenAI API

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create a list of class descriptions from the labels in the sentiments dictionary using a list comprehension.
  • Embed class_descriptions and reviews using the create_embeddings() function.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create a list of class descriptions from the sentiment labels
class_descriptions = ____

# Embed the class_descriptions and reviews
class_embeddings = ____
review_embeddings = ____
Kodu Düzenle ve Çalıştır