Everything about prompts

Raghavi_bala
3 min readMar 19, 2023

Did we ever think, they’ll come a day where anyone could do be a Software Engineer provided we know how to construct a “Prompt”. Now, it’s the day and for you to do that you have to be good at one thing, Prompts.

Prompts are the input/description we give to the model on the task that we want it to perform. There are certain things to remember before we construct a prompt and that’s what we’ll see here.

For this blog, I’ll explain it with Chat GPT . Chat GPT has a playground which is a little different from the other Open AI models.

It has 3 important components, System, User and Assistant.

System : This defines the function of the assistant.

Ex : You’re a witty assistant that creates tag lines for commercial business.

Notice how I includes the word “witty” in-order to set tone to the model. This helps us add character to our model. This is what will distinguish your assistant from someone else’s. But there are few constraints to it, we can’t set it to use profanity or hate speech.

User : This is where we give the input to the model.

Ex : “Create a Tagline for a ice cream shop”

Assistant : The Assistant will give the output for the given Input.

Ex : “Scoops of happiness in every cone!” -Chat GPT

Now, let’s go into the techniques.

Variations

If you’re a data analyst or someone who’s in the field of data you would have heard the term A/B testing. This holds true in this scenario as well. Have a sheet with list of prompts to try and try it on 5 of your same samples. This will help you compare them to get the best one.

Details

Always make it detail, it’s never TMI when it comes to prompt engineering. Be specific about the context, outcome, length, format. This is where the System comes in handy, you don’t have to include it in each prompt, you can just include all these details and provide it in System.

There’s few things to note while providing detail.

  1. Always say what you expect from the model, not what you don’t what it to do.

Do this,

“The following is a conversation between an Agent and a Customer. The agent will attempt to diagnose the problem and suggest a solution, whilst refraining from asking any questions related to PII. Instead of asking for PII, such as username or password, refer the user to the help article <include link>“

Not this,

“The following is a conversation between an Agent and a Customer. DO NOT ASK USERNAME OR PASSWORD. DO NOT REPEAT.”

2. Do not be verbose. Try to provide as much information as possible without using many words.

Do this,

“Generate a review for the product in 3 to 4 sentence”

Not this,

“Generate a review for a product that is short, with few sentences, but capture the information”

Do not write prompt in a way you’d describe it to people. Write it like instructions.

Examples : Just like humans, it’s easier for models when you give them examples. That’s why I gave you guy’s examples here 😉

We have terms for this. We have Zero-Shot and Few-Shot learnings.

Zero-Shot Learning : When we don’t provide any examples at all.

Few-Shot Learning : We provide few Examples to the model, so it understand’s what we’re expecting from it.

Notice how before giving an example the format of Output is different from what it is after I gave an example (few-shot).

With this we come to THE END.

--

--

Raghavi_bala

Data Science Machine Learning Data & Business Analytics