1. Learn
  2. /
  3. Courses
  4. /
  5. Prompt Engineering with the OpenAI API

Connected

Exercise

Sentiment analysis with few-shot prompting

You're working on market research and your goal is to use few-shot prompting to perform sentiment analysis on customer reviews. You are assigning a number for a given customers conversation: -1 if the sentiment is negative, 1 if positive. You provide the following examples as previous conversations for the model to learn from.

  • The product quality exceeded my expectations -> 1
  • I had a terrible experience with this product's customer service -> -1

The OpenAI package has been pre-loaded for you.

Instructions

100 XP
  • Provide the examples as previous conversations assigning the text as context for the user role and the number as context for the assistant role.
  • Provide the following text for the model to classify and use the appropriate role: The price of the product is really fair given its features.