In today’s rapidly progressing world, the use of artificial intelligence has been integrated into the daily lives of many, be it while working, studying or researching. Large language models (LLMs) such as Chat GPT, Perplexity, Gemini, Deepseek, etc, are easily accessible on the web, making our lives much more convenient. The widespread usage of Generative AI has led to the rise of prompt engineering, which has become the interface between humans and AI.
What is Prompt Engineering?
While using AI models, you must have noticed that you don’t always get the desired results and have had to modify your prompt to guide the AI. Doing so, you unknowingly make use of prompt engineering. Prompt engineering is a relatively new discipline; it’s the practice of crafting your prompt to provide context in a way that helps AI models generate useful responses. A well-written prompt can steer a large language model towards your desired output.
The Importance of Prompt Engineering
If you’re wondering why prompt engineering is used, it helps in understanding the limitations and capacity of large language models. These skills are important to effectively interact with the model to get better responses. Prompting is the core of interaction with AI. The aim of prompt engineering is to: Direct the AI models’ behaviour, unlock their full potential, and ensure accurate results.
Techniques in Prompt Engineering
Basic Prompt Engineering
A good prompt requires the user to provide the task, context, and examples. A prompt such as “Write about GenAI” is too vague to get a proper response. Instead, a prompt such as “Write a concise, engaging haiku with the word ‘farduddle’. To do a ‘farduddle’ means to jump up and down really fast. Examples of sentences that use farduddle: When we won the game, we all started to farduddle in celebration. Seeing the artist perform my favourite song live made me want to farduddle out of joy.” This is an example of few shot prompting.
There are different types of prompting useful in different situations: zero shot, one shot, and few shot. When you simply type a question and hit the enter key, it’s known as zero shot prompting since you don’t provide any examples to assist the AI. An example of zero shot prompting would be “Write an article about digital marketing”. With the same logic, one shot prompting refers to providing only one example along with your instruction and a desired output format, and few shot prompting translates to providing 2/more examples.
Improved Prompting
The user plays an integral role in an AI model’s output as they write the prompt. Under prompt engineering, there are different features and techniques to be applied to prompts that can substantially elevate the standard of the result you receive.
Clear communication is essential. If your question is vague, the answer will be vague too. Hence, it’s necessary to provide context (additional background information) and frame concise, detailed and direct questions to produce a relevant response.
Providing the LLM with a tone and persona also enhances answers. This requires instructing the AI to assume a role/identity and specifying the emotion and attitude that should be conveyed through the language of the text. Assigning a tone and persona helps the AI adopt a perspective and style to craft the response.
After receiving the initial response, you can refine it by iteratively improving the prompt based on the previous interaction. Another effective method is asking the AI for feedback on how to provide better prompts and information you could include to better its contextual understanding. This tells you the issues the AI is facing and gives you a precise resolution as well.
Advanced Techniques
Although these strategies are meant to enrich AI models’ replies, we need to consider the limitations of large language models and be careful about things such as context overload (overwhelming the AI by providing too much information). Keep in mind that AI assistants have constraints on processing abilities.
Tactics such as task breakdown, chain of thought, and rephrasing help us work with these limitations. If you have a complex request that requires the AI to execute multiple tasks, it’s best to break your request into smaller, more manageable prompts, each prompt building on the previous response. In addition to this, making use of chain of
thought – prompting AI to explain its reasoning in steps – will give the AI time to think and support it in navigating through the question and finding the right answer. This method is especially useful for questions that require reasoning, e.g., “If there are 3 red balls and 5 blue balls in a bag, and you randomly draw two balls without replacement, what is the probability that both are red? Let’s think step by step.” It’s important to mention that you want the AI to go through the problem stepwise. You can even specify some of the steps to further direct the model.
If the AI is not able to generate a proper response or is overloaded, try simplifying the task. A suggestion for long prompts would be not to enter all the information at once. First, inform the AI about the goal to be achieved and the type of task you want it to perform; in a separate prompt, provide it with the tone, persona and context. An alternative method is to include all the information in one prompt; however, repeat the main aim/ instruction at the end. Sometimes, the AI tends to read and answer only the latter part of the prompt.
Final Thoughts
Prompt engineering is a medium for talking to AI; it is the interface between human thinking and machine understanding. This subtle art has given us the opportunity to unleash the true potential of AI models and maximise their value. Prompt engineering will only develop and evolve further, with new prompting techniques aiming not only for effective communication but also for amalgamating the realm of AI with our reality.
There is much more to prompt engineering that hasn’t been covered in this blog but is utilised by researchers and developers to get detailed and high-quality replies. If you wish to learn more, you can delve deeper into prompt engineering and learn advanced prompt engineering strategies (Prompt engineering by OpenAI), including the usage of delimiters, specifying task steps, mentioning desired output length, offering reference texts, leveraging external tools, etc.
Kimaya is currently a grade 12 student in the IB diploma program at Legacy School, Bangalore. She takes Physics, Chemistry and Math Analysis and Approaches Higher Level due to her interest in STEM. She has developed a curiosity towards the world of Artificial Intelligence and completed multiple courses to gain understanding and knowledge. She wants to pursue computer/data science in college and learn further more.