- Published on
AI learning journey step 2 : Some notions to write better prompts

- Authors
- Name
- Ismail Tlemcani
- @Ismailtlem
We continue our learning journey into AI concepts, and this time we will focus here on how to write better prompts in order to get the best results from the LLM.
What is a prompt ? Simply ?
A prompt is, simply, the text input we give to the LLM, that can be a question, a request for information, or a task, or anything else we want the model to do. A simple example can be : You ask ChatGPT : 'Write me funny jokes about people who forget everything'
Does a good prompt make a difference ?
Yes, it does. At core, an AI model is a statistical model that predicts the output based on the input you give it, and this based on the huge amount of data it has been trained on. On all this training data, not everything is most appropriate for your specific needs, and therefore the model might not give the best result if you don't provide it with enough information.
Here is an example of a bad prompt

As you can see, the output of the model is not very helpful, as it is very generic, and does not necessarly correspond to our specific context. If, instead, we provide the model with a better prompt, you see that the output is clearly better and more relevant to the specific context we provided.

Few best practices to get the most out of your prompts
- Give the model a role if possible : Start your prompt by telling the model what role it should play. For example, if you are asking a tech question, start by telling the model : You are a senior software engineer.
- Give the model a context : Provide the model with as much context as possible, so that it can give you the closest answer to your specific needs. Remember that AI models are statistical models, and the more information you give them, the lower the probability of getting a generic answer.
- Provide the model with examples if possible : If you can, give the model examples of what you want to do. This is called few shot prompting. This is very effective as it makes the model learn from your examples.
- Tell the model, how do you want the output to be : If you want the output to be in a specific format, like a table, tell the model.
- Encourage the model to think first, make a plan, and then answer : This is called chain of thought. This is an effective technique to get the model to reason first, make plan, before answering. You can review the plan given, correct it if needed, and then ask the model to implement the plan if everything looks correct for you.
Conclusion
Prompts are the way we communicate with AI models, and the better we write our prompts, the better the output we will get. By using the best practices mentioned above, you will be able to reduce many irrelevant responses and strictly make the model align with your specific needs.