AI Prompt — Tips and Tricks

Thiago Bomfim
3 min readJun 10, 2024

--

Using AI is becoming a routine activity and will soon become a must-do. AI can help us increase productivity, and those who don’t know how to use it will be left behind.

Let’s see some best practices for how to create better prompts and how to obtain better results.

Tips

Use a Persona

The first command you are going to give to the model should be instructions to the model to act as a persona.

❌ Ask direct questions, without giving a persona

✅ Ask the model to act as a persona, for example: Act as a Senior Software engineer with more than 15 years of experience with Java

Give context

You can give context in the first or second question, so the model will keep with it, and you will avoid the necessity to send the context for every question.

❌ Ask questions without context, without giving the model enough knowledge about the situation.

✅ Give the model some context, for example: Based on our project which uses Spring 3.2, Java 21, can you give me the best solution to solve the problem ...

Be aware that models may take time to update with new developments and may not be familiar with newer tools and technologies.

Be specific, descriptive and avoid ambiguous questions

❌ Ask generic questions

✅ Chances are your question has more than one answer, so try to be clear on what you want.

Break big tasks into small steps

❌ Asking to do complex things that requires a big answer

✅ Break the complex task into small steps and ask the model to answer each step separated

Define a template for your answer

❌ Only askign the model, the changes to give random answers are very big

✅ Asking the model to follow a a template, increase the chances to have a better result.
Example:
Generate 3 presentations about X following this template:
[Title]
[Subtitle]
[Abstraction]

Tricks

You probably have already heard of or used ChatGPT, but do you know how it works?

In short, an AI model has thousands of neural networks, which allows it to talk about all the topics it knows.

This model is not trained during your chat conversation, which are the prompts we give, but uses the chat history to maintain context on the topic and provide better answers.

ChatGPT 4 also offers the ability to receive files and save them to a vector database to provide better responses.

Long chats

❌ Keep long chat

✅ Using short chat is better, the ChatGPT tries to use the entire history to give better responses, which can make it slow, and also less precise.

Chat with many subjects

❌ Chat with many subjects

✅ Ideally, create a chat for different subjects, it will provide you with better results, as the model will keep one only context.

Be careful with hallucinations

❌ Asking complex and specific questions, can increase the chances of hallucinations

✅ For specific questions, such as an unknown framework, or a specific problem, you can ask the model to answer with 95% accuracy, and if it doesn't know it must say I don't have this knowledge. This decreases the chances of having wrong answers. However, you should be careful with the answers

Conclusion

There are many ways to create better prompts, and you should reuse them.

We should not believe 100% in these model answers, but we can create better prompts to avoid the number of hallucinations and bad answers.

AI is evolving a lot, so we need to keep updated with the best practices to have better results.

I hope these tips & tricks can help you, and if you want to keep updated, please subscribe.

Subscribe

References

Prompt Engineering — ChatGPT

Best practices for prompt engineering with the OpenAI API

--

--

Thiago Bomfim
Thiago Bomfim

Written by Thiago Bomfim

I'm a happy developer, trying to help the world and peoples with technologic

No responses yet