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

Connected

Exercise

One-shot chain-of-thought prompts

When you need to sum the even numbers within a given set, you first have to identify these even numbers and then sum them. You can teach this to a language model via one or more examples, and it will follow this strategy to operate on new sets.

Your goal in this exercise is to teach the model how to apply this procedure on the following set: {9, 10, 13, 4, 2}, and then ask the model to perform it on a new set: {15, 13, 82, 7, 14}. This is how you perform chain-of-thought prompting through one-shot prompting.

The OpenAI package and the get_response() function have been pre-loaded for you.

Instructions

100 XP
  • Define an example that teaches the model how to sum the even numbers on the set {9, 10, 13, 4, 2}.
  • Define a question, similar to the one in the example, that asks the model to reason on a new set {15, 13, 82, 7, 14}.
  • Create the final prompt.