IKH

Applying Prompt Engineering for Language Tasks

In the upcoming video, we will apply the techniques covered in the previous session to create a prompt for a specific application. Let’s hear from Kshitij as he elaborates on these techniques.

In the video, you observed the prompt Kshitij used to generate the ad copy for a marketing campaign and rewriting emails. You can access these prompts through this link.

Let’s analyse the prompt using the knowledge we have gained so far.

Role: ‘You are an experienced marketing professional who specialises in writing successful ads.’
Here, the role specifies the model act as an experienced marketing professional who specialises in writing successful ads. This additional information about the role (or persona) helps in generating text from the perspective of an experienced marketing professional. 

Task: ‘Write an ad copy for a gaming chair using the product description given below. The target audience is avid gamers in the age group 16-25 who value comfort and aesthetics and are price conscious.’

Note that we have mentioned the objective clearly with the intended audience. This helps the model tailor the output to cater to the various aspects mentioned in the task. 

Context:

This provides additional context for the task. Here, we have specified that the generated ad copy is to be shown on the landing page of an e-commerce website. The text ‘the brand is known for its innovative products and witty appeal’ is mentioned to ensure that the model output aligns with the intended context.

Note that the context provided in this prompt helps steer the output towards the desired response. In the upcoming segments, you will explore some additional prompts that do not contain additional context. In the subsequent portion, the product description is specified. We have separated the product description with delimiters ‘####’ as shown below.

Example

Python
####
Brand: Baybee
Colour: Emperor Wine Red
Material: Leather
Product Dimensions: 60D x 50W x 140H cms
Size: Single Seat
Back Style: Wing Back
Special Feature: Adjustable Lumbar, Adjustable Height, Ergonomic, Arm Rest, Rolling, Swivel, Head Support
Seat Material Type: Faux Leather
Recommended uses: Office, Relaxing, Reading, Gaming
####

Output

The delimiters ensure that the model can separate the product description from the rest of the text input. When using delimiters, it is essential to use consistent delimiters in the prompt to ensure proper parsing and interpretation. Improper use of delimiters can confuse the model and lead to incorrect output responses.

Guidelines: Occasionally, it’s helpful to provide additional instructions to guide the LLM in performing the main task. In the first example, the task was to write an ad copy and the guidelines specified that the copy should be written in a fun and witty manner.

Output format:  In some applications, it may be necessary to have the LLM’s output in a particular format, such as string or boolean outputs, or more complex data structures like lists of objects or JSON objects. Specifying the output format in the prompt ensures that the completion output is in the correct format.

Now, compare the output of the above prompt to a prompt where you omit each of the parameters mentioned above and observe the differences. Experiment and modify the various input parameters of the prompt to generate output texts and observe how the model’s outputs vary with different input prompts.

Apart from the prompt engineering techniques we have discussed so far, you can also consider using techniques such as adding seed phrases, self-criticism prompting technique, iterative technique etc., to generate outputs as per your requirements.

In the next segment, we’ll learn how to leverage ChatGPT’s capabilities to generate code, and build end-to-end applications with just a few lines of text.

Additional Readings:

  • You can refer to this resource for more prompt engineering techniques: Prompt Engineering.
  • In this GitHub repo, you can find a collection of prompts for testing ChatGPT’s capabilities Awesome Chatpt Prompts.
  • This paper describes a catalogue of prompt engineering techniques presented in pattern form that have been applied to solve common problems when conversing with LLMs – A Prompt Pattern Catalog to Enhance Prompt Engineering With ChatGPT.

Report an error