A pleb’s guide to Prompt Engineering
If you interact with large language models and generative AI tools, prompt engineering – the principles and practice of providing inputs that can generate the outputs you want can make a difference in the usability of these tools. In this post, I will confine myself to prompt engineering interacting with chat based generative pre-trained models that include OpenAI chatGPT, Claude.ai, Google Gemini that allow a chat based interface with the end users. The concepts I have discussed here could be expanded with generative pre-trained models in general where we can access the APIs (application programming interfaces) and then use similar codes for interacting with these agents and create prompts to accomplish specific tasks.
The use cases that I have in mind are two: (1) I’d like to find prevalence, incidence, and control of type 2 diabetes among people in different countries and (2) I will use prompts in prompting AI models to write a story. I will use chatGPT and use its mobile interface to interact with these models. As chatGPT allows a specific amount of “credits” to its end users free of charge, therefore, this will allow you as a user to replicate the concepts that I will explore in this short note.
Prompt engineering is a mix of science and art, similar to finding information in a search engine. It can be specialised and can be quite complex, has many applications and use cases but for the time being for a simple research based use case, where we can search for information, ask the systems to create spreadsheets, retrieve information, interpret data, and create stories, prompts can be kept simple yet conform to the basic principles.
Zero shot prompts
We will start with our exploration of the prevalence of Type 2 Diabetes using zero-shot prompts. Think of prompts as queries, but there is a difference between a prompt and a query that we use for mining for information in a database. A query is a structured set of statements that uses or can use Boolean and fuzzy logic; for example, if I were to search a common medical information search site such as Pubmed (see https://pubmed.gov), and I wanted to find out the prevalence of Type 2 Diabetes among adults in different countries, I could start with specifying a set of dates through which I’d search for information; suppose I wanted to search for information between 1/1/2014 and 31/12/2024 to search for the previous ten years’ worth of data; then I could use a set of search terms: in this case, the search terms might be “prevalence” “Type 2 Diabetes” and leave at that. I would also specify that I’d like to search those papers that have the words “prevalence” and “Type 2 Diabetes” in their titles or abstracts of those papers. In doing so, I’d restrict myself and then build my search or query step by step. This process would yield me a set of links and list of papers that I’d then retrieve and read and extract information.
When I use a tool such as chatGPT (and indeed in the larger sense any large language models), I am interested in more than mere retrieval of information and processing that information myself; instead, I want a summary or a table for the exact information I want from the sources. Any generative pre-trained model is “trained” on a large “corpus” of data. In this case, that data sources might be international health statistics databases that the model would be able to access, and indeed large literature databases where it might access and identify research papers. I’d expect that the model after accessing such sources will abstract the information that I want and will show me the resulting information in a format that I desire, such as a spreadsheet or a comma separated value file. I can then either process that file myself using my preferred software of data analysis or I can conduct simple data analyses directly on the large language model itself.
When I issue a statement, such as a “prompt”, what I want is provide a set of keywords that enables the model to identify other words that might “go with it”, and then on that basis, the model builds a representation of what “it identifies as the expected information” to me. The model inherently does not have a way of knowing what I have in mind unless I am explicit. This is where I will initiate my initial query using a simple sentence, “Worldwide prevalence of Type 2 Diabetes is:” and stop there. This type of prompt is a simple prompt where I do not specify anything more than merely asking a question. The models will access the data sets it has set up and will provide information (See Figure 1).
You can see that with such a simple prompt where I do not provide any more information than that, it will provide some idea about the answer to my query. In this case, chatgpt has provided me with some helpful information about the extent of the prevalence of diabetes worldwide (that of about 560 million people and that the prevalence is increasing and particularly high in poor countries). But I was really interested to know more about the “epidemiology” of Type 2 Diabetes – which is the study of the distribution and determinants of diseases and use of this knowledge to betterment of public health.
Here is a limitation of the zero-shot prompt. It can only provide me with some generic information for which I might or might not be benefited or a level of information that is very abstract. I could have searched international databases to find the same information and this is a handy way to save me time. Another way might be ask the models to prepare a spreadsheet of prevalence in 100 most prevalent countries in the world. So, I could issue another zero-order prompt with something like, “Prepare a spreadsheet of the prevalence of Type 2 Diabetes in the most frequent 100 countries in the world” and you will see that it will return a spreadsheet that you can either download or you can view directly on the page.
Once again, as you can see, if your intention was to view the spreadsheet and conduct visualisation, then you would have to do additional efforts to generate the data, download the data, and then use your favourite visualisation tools to generate them. Once again, if your objective is to understand the epidemiology of diabetes, then, you will need to provide more information to the model and then it will generate more “personalised” or more specific information that you will make use of.
So, when you want to start with a very generic idea of a topic and seek some “high level” information, you may want to start with a zero shot prompt. But there are downsides of zero-shot prompts. First of all, with a zero-shot prompt, unless you specify or your model specifies the source of information, you may end up with wrong data being pushed to you. This may be because the model “hallucinates”. The reason it may happen is because generative models such as large language models are trained on say millions of data using a principle referred to as self-supervised learning. The principles were first explained in a paper by Ashish Vaswani et al (2017) titled, “Attention is all you need” where they showed a mechanism of transformer AI that would take a corpus of text or data and would use this corpus to train itself. This in turn enabled researchers to train very high volume of data corpus to generate predictive patterns. For example, it would enable you to pass images that would have some part of the images “shielded” from the overall image, and the algorithm would then be able to deduce the shielded part of the image from the remainder. Secondly, models that allow such large scale mining of data and retrieval or generation of patterns also depend on what is referred to as “Foundation AI” where a set of underlying patterns are first “learned” by the model and this “learning” then generates the rest of the pattern and information pushed to the requester of information. All of these indicate that the more specific you can be, and the clearer you are in terms of what you want from the model, the more likely that it will provide you with the answer you seek, and less chance of retrieving random, unrelated piece of information, that are often termed as “AI hallucination”.
Temperature
In this essay, we have kept a discussion of “temperature” of an AI model beyond our scope. As we have confined ourselves to popular applications (and in our case we are exploring chatGPT and DeepSeek), we have kept any discussion of adjusting the LLM parameters beyond this paper. If you were to work with application programming interfaces of such algorithms and would programmatically interact with the LLM of your choice, then you would like to adjust the randomness of the outputs of your models; you can do this by adjusting the temperature parameter of your model. The temperature parameter ranges between 0 and 2; the higher the value, the more the unpredictability. For example, if you wanted your model to produce an image, a poem, or a story, you would like to use a warmer or higher temperature model that would increase randomness; on the other hand, if you were to search and retrieve information and build a story on that basis, you would prefer a “colder” model. Typically, hidden from your sight, your chat based free version of chatGPT or DeepSeek would set up a temperature around 1.0 (cite??)
User prompt versus system prompts
Another point worth mention here is the role of system or assistant prompts. Now, as our discussion is confined within ChatGPT or chat based applications and not API based use of generative pretrained models and LLMs, as a user you will not have an opportunity to adjust the system prompts. A system prompt is one where the author of the code who has written he LLM that you are interacting with has already written a “statement” that gets “tagged” to your prompt. That prompt applies to everyone who uses the system equally. Suppose you want your chatGPT to write an email to your friend. You could issue a prompt such as “”Write an email to my friend apologising that I will not be able to attend the party this weekend”; you may find that when the software writes the email, the tone is polite and somewhat officious. It is so because hidden from your view is a system prompt that says something like “You are a manager of a firm; Write a polite official tone email based on the users prompt of writing an email to their friend apologising for not being able to attend the party over weekend”. Although you may not have any control over how system prompts are presented unless you are aware of these prompts and are allowed to change them, with zero order prompts such as the ones we have been playing with, there is not much you can do to “personalise” the outputs from your models.
Personalising the outputs: one-shot and few-shot prompts
If our aim is to personalise the information we want, then it is important that we pass additional information to the model and then let the model “generate the document”. Continuing with the example of Type 2 Diabetes, I am interested in learning more about the epidemiology Type 2 Diabetes (“T2DM”) and I want to see a more comprehensive account of the epidemiology of diabetes. In order to do that, I tell chatGPT the following:
“Epidemiology is defined as the study of distribution and determinants of diseases in populations and the use of that information for improvement of public health.
Epidemiology is defined as the study of distribution and determinants of diseases in populations and the use of that information for improvement of public health.
Example: using Epidemiology for Type 2 Diabetes (call it ‘T2DM’), we will find out the prevalence of T2DM and then we will find out what are the main causes why T2DM has increased worldwide
Based on the above information, find out what is the prevalence of T2DM in the 10 most prevalent countries and what factors have led to T2DM surges”
With that information, we not only gain an insight into the statistics of Type 2 Diabetes in the ten most prevalent countries in the world, but we also get to see a list of some of the known risk factors of diabetes. You can see that compared with the previous outputs, these outputs are getting more specific, and you can fine tune it even further. What we just observed is an example of one-shot prompt as we had a query and one example. We can embellish it further with more examples and we can in that way get even more specific information. For example, let’s say we want to find out 10 most influential papers on T2DM epidemiology since 2014 and ask LLM to list them instead of listing books. So we can add the following information:
“
Use the following format to list 10 most frequently cited research papers on the Epidemiology of Type 2 Diabetes Mellitus. Here is a format you can use to write the list of papers.
Example: Author (2014). Title of the Paper. Journal (Volume in figure): DOI
“
It returns the following:
So you can see that you can combine citation format, you can provide information, examples, and ways to build your own arguments about a topic that you want to investigate. So zero-shot, one-shot, and few-shot prompts allow us to build complex queries with examples to personalise and find out the exact information that we might be interested in. We can start with zero shot prompts to identify an abstract level information and if that is all we are interested in, then zero-shot prompt might be good enough for us to make use of prompts engineering to understand and build our knowledge about a topic. On the other hand, if we want to dig deeper into a topic, we may want to build more complex prompts providing more examples and instances to build our stories.
Chain of Thought Prompts: building stories
This brings us to the concepts of what is referred to as Chain of Thought prompts or CoT prompts. Here, we build prompts based on connected ideas that flow from one prompt to another. We start with one set of prompts, and see how chatGPT (and others) respond with their outputs. Then we use the output as a prompt to build another set of outputs and we continue to build a chain of various prompts. This is useful in building stories and a long chain of outputs that are interconnected. Let’s build a story connecting ideas together while we stay on this theme.
Here’s the first link of the chain:
“Type 2 Diabetes has very high prevalence in India and among 20–79 year old people. Ajay is a 45 year old sedentary overweight Indian man who does not exercise. What is Ajay’s risk of T2DM?
“
Then we use this information to build a story like as follows:
“Imagine you are a doctor. Ajay visits a doctor with complaints of tiredness. Build a conversation and story between the doctor that is you and Ajay and end the conversation with the doctor advising Ajay to control his diet and take exercise”
If you read the story you will see that the story flows on from the previous examples and experience of the outputs generated by the prompts you supplied to the LLM. This creates a continuity and you can see that you can move from one theme to another, and you can start with a fairly academic discussion of a particular topic and end up with a story or a conversation that you can then turn to do other things.
Putting everything together
This was a brief introduction to the world of prompting. Similar to searching databases to find specific information, using a prompt is a way to identify information, search for information, and build stories. The clue to prompting to get what you want is to start with the purpose in mind. Why are you using the prompt and what do you want from the prompt session? You can build a conversation and you can build a story.
If you want a broad based overview of a topic, start with a zero-shot prompt where you ask “generic”, broad-based questions. If you want to dig deeper into it, start with specific stories and instances. You can provide documents in the form of webpages, or pdf copies and ask the system to generate summaries and reviews. You can start providing the system with examples, and the more examples you provide the better and more specific will be the outputs. From a one-shot to a few-shots, you can generate responses by varying your prompts. You can chain together your ideas and move from one topic to another. You can also combine all of the above to generate the output you desire.
In this introduction, we have not delved into the world of prompts as this was a basic introduction to get started. There are many strategies that you can use to generate prompts and many different types of prompts other than the ones we have covered in this essay.