Prompts : way to get the next right thing

Prompts : to ask/encourage someone to take actions based on input(could be commands, statements, tasks etc.).
In simple when we ask ChatGPT: HI! How are you?
-*(*This is a prompt)And in response we may get: Hi, I am really good, I hope you are also fine, tell me what I can assist you with today…
-\(*This is the response or result for the prompt)*
Real Life exp
We all must have visited doctor, there we tell him/her about our injury or disease in detail and ensure that everything is correct, so that we get the right medicines and treatment.
Similarly, here also in AI World we must provide the clear, correct and concise input to get the right output.
Prompt 1: I want to play give me roadmap.
Prompt 2: I want to play Basketball for India. My height is 6 ft 1 inch. Tell me about the positions I could play with some exercises to improve on my shooting. A weekly routine would be really helpful. Also the competitions I could participate.
It’s clearly visible which prompt will give you desired results.
I hope you get the idea about prompting.
Now let’s move technical use case of prompting.
Prompting in AI
AI models or computers can’t think like humans, that’s why they need some pre-trained data, from where they access the required data or results based on the input.
Prompting makes it easy for them to get the data and display. As data is first converted into tokens and then stored in form of vector embeddings (in multi-dimensions). So to get such complexly stored data while keeping the Token Cost low, the prompts matter the most.
It’s mandatory to write good prompts.
- Good Prompts:
Gives clear instructions.
Provide the context on which the question will be asked. For eg: The report has to be made for marketing strategy on social media using AI.
Specifying format and tone. For eg: Give output in a formal tone
Being concise and using specific keywords to get the desired output.
Giving constraints. For eg: Give a paragraph on AI Prompting under 450 words.
Types of Prompting Techniques in AI
There are different types of Prompting techniques, and there’s no right or wrong in it.
This totally depends on the user’s use case
Let’s get to know each one of them:
1. Instruction Based Prompting
Giving direct instructions to the AI for an specific task.
- For eg: Summarize the paragraph in 5 bullet points.
2. Role Based Prompting
Here we give or assign the AI a persona or role and it responds in that way only.
For eg:
messages : [ { role: 'system', content: 'You are an AI assistant for beginners going to Gym' }, { role: 'user', content: 'I am going to start for the first time, I am 21 years old, 6ft Basketball player, currently a bit out of shape, weighing 90kgs, provide me with a roadmap to start with' }
There’s a extended version of this also know as Persona based prompting.
3. Zero Shot Prompting
Here we ask GPTs to give the output without actually giving them any examples.
Use Case: when the task is simple and unambiguous.
- For eg: Translate : “I Love Coding” in German.
4. Few Shot Prompting
Here we give exp to the LLM, that enhances the accuracy nearly by 10 times.
This is one of the most widely used prompting.
For eg:
messages : [ { role: 'system', content: ` You are an AI assistant for beginners going to Gym Examples: Q: Who are you? A: I am your personalised Gym Assistant and my name is GybodAI Q: What you can do? A: I can provide you all the info related to Gym, be it your workout plans, diet plans, Gym routines, exercises for isolated muscles, and yaa i would motivate you in your low time to show up to Gym everyday Q: I am not able to follow diet plan A: No problem, it happens with all of us, just be consistent and start slow, don't get overwhelemed, I will give you a new healthy diet plan according to your body ` }, { role: 'user', content: 'I am working hard but not able to stick with my diet plan and workout schedule also hampers a lot' },
5. Chain of Thoughts Prompting
Encourages the AI to think and think through steps and rules (that maybe given using system-prompt) before giving answers.
Mainly used for mathematics, logics or reasoning purposes.
- For eg: Solving a BODMAS problem requires specific steps to solve.
async function main() {
const System_Prompt = `
You are a mathematical AI that works on the format : Start, Think, Think, Review, and Answer.
Rules:
1. You will not answer directly, first you'll break the problems into sub-problems
2. Always perform only one step at a time.
3. Provide details of each step.
4. You must ONLY output one single JSON object for each step.
5. Do NOT include multiple JSON objects in one message.
6. Do NOT include code blocks or extra text.
Output format:
{"step" : "Start | Think | Output", "content": "string"}
Exp:
User: Can you solve: 3 + 6 / 2 * 5 - 2 + (9 - 5);
Assistant: { "step": "Start", "content": "The user wants me to 3 + 6 / 2 * 5 - 2 + (9 - 5)" }
Assistant: { "step": "Think", "content": "This is typical mathematical BODMAS problem used for calculations" }
Assistant: { "step": "Think", "content": "First we need to solve bracket containing 9-5 which is eqauls to 4" }
Assistant: { "step": "Think", "content": "Now the equation has become 3 + 6 / 2 * 5 - 2 + 4, now we'll go for divide i.e. 6/2 which is eqauls to 3" }
Assistant: { "step": "Think", "content": "Now the equation will become 3 + 3 * 5 - 2 + 4, now solving multiplication 3*5, we get 15" }
Assistant: { "step": "Think", "content": "Now the equation will become 3 + 15 - 2 + 4, and we have left with basic addition and subtraction, 3+15+4=22 and 22-2=20" }
Assistant: { "step": "Output", "content": "So the final output is 20 usingBODMAS" }
`;
const messages = [
{
role: 'system',
content: System_Prompt
},
{
role: 'user',
content: 'Solve 7 * 9 / 3 + 6 - 2 + (9 - 7)'
}
]
while(true){
const response = await client.chat.completions.create({
model: 'gpt-4.1-mini',
messages : messages
});
const rawContent = (await response).choices[0].message.content;
const parsedContent = JSON.parse(rawContent);
messages.push({"role": "assistant", "content": JSON.stringify(parsedContent)})
if(parsedContent.step === 'Start')
{
console.log("🔥", parsedContent.content);
continue;
}
if(parsedContent.step === 'Think')
{
console.log(`\t🧠 ${parsedContent.content}`)
continue;
}
if(parsedContent.step === "Output")
{
console.log(`🤖 ${parsedContent.content}`);
break;
}
}
6. Self - Consistency Prompting
Here, we generate the output using 2 or more AI models and can have judge LLM at the end that will give the best results or maybe what’s common in them .
7. Persona - Based Prompting
Here, we give data about a personality and our model behaves like him/her.
For eg: we can give commands like: You are Virat Kohli, Indian cricketer with confident and inspiring personality, knows Punjabi as well.
Now here our we can feed more data, like talking styles, even social media links from where our model could get to know how this person types captions and all such data so that it can actually behave like that particular personality.
So this was the basic of Prompting and different Prompting styles.
Subscribe to my newsletter
Read articles from Yash Rawat directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
