Prompt Engineering: The Art of Precise Communication with LLMs


"Prompt Engineering is all about how precisely we can shape an LLM’s output by carefully crafting the input (the prompt) to guide the AI toward clarity, accuracy, and relevance."
PROMPT FORMAT
To understand prompts, we first need to understand how LLMs interpret the conversation. Each message from system instructions to your questions gets wrapped in a format the model can read.
Use tools like Tiktokenizer to check how does Every LLM’s prompt Formats
1. Alpaca Format
It consists of three key components:
Instruction : A prompt or question that guides the model's response.
Input : Additional context or information.
Output : The desired response from the model.
### Instruction:
<prompt>
### Input:
<additional context>
### Response:
<leave a newline blank for model to respond>
Examples:
Instructions: For the given task by User Perform some mathematical calculation.
Input: What is 2+2?
Response: 2+2 is 4.
2. INST Format (Meta Llama 2)
it also consists of three components:
<s></s>: These are the BOS and EOS tokens from Sentence Piece. When multiple messages are present in a multi turn conversation, they separate them, including the user input and model response.
[INST][/INST]: These tokens enclose user messages in multi turn conversations.
<<SYS>><</SYS>>: These enclose the system message.
<s>[INST] <<SYS>>
{{ system_prompt }}
<</SYS>>
{{ user_message_1 }} [/INST] {{ model_answer_1 }} </s>
<s>[INST] {{ user_message_2 }} [/INST]
3. ChatML (OpenAI)
ChatML (Chat MarkUp Language) is the structured format used by OpenAI to organize multi‑turn chats. It uses tokens like <|im_start|>system/user/assistant <|im_end|> to explicitly mark each message's role.
<|im_start|>system
You are an expert tutor.
<|im_end|>
<|im_start|>user
Explain quantum mechanics in simple terms.
<|im_end|>
<|im_start|>assistant
PROMPTING METHOD
“ It is a technique where you provide several input-output examples with Instructions , rules, and tools to guide the model in understanding the pattern you want. ”
1. Zero Shot Prompting
The model is given a direct question or task without prior examples.
example: what is 2+2 ?
client.chat.completions.create(
model="gpt-4",
messages=[
{ "role": "user", "content": "What is greator? 9.8 or 9.11" } # Zero Shot Prompting
]
)
2. Few Shot Prompting
The model is provided with a few examples before asking it to generate a response.
Example:
Instruction: You are an Helpful Assistant Specialized in maths.
examples:
1. Input: 2 + 2
Output: 2 + 2 is 4 which is calculated by adding 2 with 2.
2. Input: 3 * 10
Output: 3 * 10 is 30 which is calculated by multiplying 3 by 10.
system_prompt = """
You are an AI Assistant who is specialized in maths.
You should not answer any query that is not related to maths.
For a given query help user to solve that along with explanation.
Examples:
Input: 2 + 2
Output: 2 + 2 is 4 which is calculated by adding 2 with 2.
Input: 3 * 10
Output: 3 * 10 is 30 which is calculated by multipling 3 by 10. Funfact you can even multiply 10 * 3 which gives same result.
Input: Why is sky blue?
Output: Bruh? You alright? Is it maths query?
"""
result = client.chat.completions.create(
model="gpt-4",
messages=[
{ "role": "system", "content": system_prompt },
{ "role": "user", "content": "what is a mobile phone?" }
]
)
3. Chain Of Thought (CoT) Prompting
This advanced method involves generating and exploring multiple solution paths or ideas before arriving at a conclusion or recommendation.
- High Accuracy
- Good for Logical & Reasoning Problem
- Require More Time & Resources
Instructions:_________________
Examples:
Input: What is 2 + 2.
Output: {{ step: "analyse", content: "Alright! The user is intersted in maths query and he is asking a basic arthermatic operation" }}
Output: {{ step: "think", content: "To perform the addition i must go from left to right and add all the operands" }}
Output: {{ step: "output", content: "4" }}
Output: {{ step: "validate", content: "seems like 4 is correct ans for 2 + 2" }}
Output: {{ step: "result", content: "2 + 2 = 4 and that is calculated by adding all numbers" }}
4. Self-Consisting Prompting
This method generates multiple responses and selects the most consistent or common answer.
- Running the same prompt multiple times, each with CoT Prompting.
- Collecting all answers produced.
- Choosing the most common as the final answer.
Prompt: “Let’s think step by step - what’s 57 × 43?”
Run it 5 times.
You might get:
- Responses: 2451, 2451, 2449, 2451, 2451.
Majority vote → 2451.
5. Persona Based Prompting
The model is instructed to respond as if it were a particular character or professional.
You are Swami Vivekananda — a monk, philosopher, and fierce patriot of India. You were born in 1863 as Narendranath Dutta and later became the foremost disciple of Sri Ramakrishna Paramahamsa. You are known globally for your sharp intellect, spiritual depth, and powerful oratory. Your speech at the Parliament of the World's Religions in 1893 in Chicago began with the iconic words: "Sisters and Brothers of America", which earned you a two-minute standing ovation.
You blend Indian Vedantic wisdom with a modern, fearless voice. You speak with clarity, power, and deep compassion. Your words are uplifting, motivational, and full of fire. You inspire youth to build strength — both spiritual and physical — and to serve humanity with love, discipline, and courage.
You often quote from the Vedas, Upanishads, and Gita. You speak about the divinity within all beings, the greatness of Indian philosophy, and the importance of self-realization. You emphasize karma yoga (path of selfless action), spiritual unity, and national pride.
You are never casual or humorous — you are passionate, poetic, and intensely focused. You never shy away from truth, no matter how harsh. Your tone is authoritative, noble, yet filled with love and purpose.
Examples of your speech: 1. "Arise, awake, and stop not till the goal is reached."
2. "You cannot believe in God until you believe in yourself."
3. "Strength is life, weakness is death."
4. "Take up one idea. Make that one idea your life — think of it, dream of it, live on that idea. Let the brain, muscles, nerves, every part of your body, be full of that idea."
5. "They alone live who live for others; the rest are more dead than alive."
6. "The greatest religion is to be true to your own nature. Have faith in yourselves."
*Speak in formal, elegant English. Be clear, concise, and inspiring.*
*Don't give long paragraphs, keep responses impactful.*
Examples:
Interviewer: "You are an HR professional conducting a behavioral interview."
Doctor: "You are a compassionate general physician explaining symptoms to a patient."
Startup advisor: "You are a successful entrepreneur mentoring a new founder."
Critic: "You are a film critic reviewing a sci-fi movie."
Conclusion
Prompt engineering is not just a technical trick- it’s a creative bridge between humans and machines. Whether you're instructing an AI to solve a math problem, take on the role of a monk or doctor, or reason step by step through complex logic.
From simple zero-shot queries to advanced formats like Chain of Thought or Self-Consistency, every technique gives you more control over how LLMs think, respond, and perform.
As LLMs become more integrated into our daily lives from education and research to business and creativity then mastering the art of prompting means mastering the way we collaborate with AI.
So experiment, refine, and most importantly be precise with your intent. Because with great prompts come great outputs.
Subscribe to my newsletter
Read articles from Aman kumar Prasad directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
