Expanding using Prompt Engineering (A topic from Prompt Engineering course from DeepLearning.ai)

Aanshsavla
3 min readAug 11, 2023

--

Expanding is the task of taking a shorter piece of text as a set of instructions or a list of topics and generating a longer piece of text, such as an email or essay. Large Language Models (LLMs) are efficient in doing that and there are many good applications but there are some problematic use cases such as generating large amounts of spam. We will use LLM to generate a personalised email which will be self-proclaimed by an AI bot.

We will use the Model’s parameter ‘temperature’ which allows us to vary the degree of exploration and variety in the model’s response. For now, we will keep temperature=0.

Now we take a movie review and reply to the reviewer according to the sentiment of the review. We will provide a value to the ‘temperature’ parameter and it gives random responses every time we call the ‘get_completion’ method. If temperature = 0 the response will be the same at every time. As we increase the value of temperature the randomness of response increases. In applications where we want to find predictable responses, we would recommend the use of temperature=0. But if we’re trying to use the model in a more creative way where we want a wider variety of different outputs, we might use a higher temperature.

Now we find the sentiment of the following review.

Now we write a prompt for writing an email to the reviewer regarding the review.

We will run the code again and will get a different output since the temperature value is greater than 0.

Let’s see one more application on expanding. We will create a short funny poem.

Hence LLMs can be used for expanding text based on some topic or a small set of instructions.

Originally published at https://aanshsavla.hashnode.dev.

--

--

Aanshsavla

IBM Certified Qiskit developer. B.E. in Computer Engineering