How to articulate an effective AI prompt?
Let us start our discussion with a quote that is often attributed to Albert Einstein, "If you can't explain it simply, you don't understand it well enough". In the next few paragraphs, you will get to know why I bring up this quote.
The ideas I am going to present relate to the domain of AI-assisted code generation. We start with the motivation of quickly developing a software system using AI. At the end of this, you will realize there is no really no free lunch. To get AI to do something meaningful, you have to work just as hard.
Recommended methodology to make better use of AI.
Most GenAI tools are similar
Do not waste time evaluating and experimenting with different GenAI tools. Choose the one you like the most and stick with it. Our approach should work with most tools.
Know precisely what you want the software system to do
This is where you should invest most of your time. Enumerate the requirements and strategy (algorithms) you wish to use to realize your software system. This is where your understanding of the system becomes useful. Create a system level architecture to get started.
Breakdown the system into several miniature sub-systems
Use the system architecture and requirements to breakdown the system into miniature sub-systems or modules. Try to simplify the modules to the lowest level of abstraction you possibly can.
Write a prompt to realize the miniature sub-system
Now write a prompt to request the GenAI tool to generate code for the simplified miniature sub-system. This request is likely to be simple and precise; something that the tool can effectively handle. It may take a few iterations, before the AI tool generates the code that you are looking for.
Recommended by LinkedIn
Modify, integrate and test the generated sub-systems
The AI generated code is likely to need some modifications. Hopefully, these modifications will be trivial and straight forward. Note, for this step, you need to have working knowledge of the code syntax. Integrate the generated code with the previously generated code and test it.
No wasted effort
In a possible scenario, if the AI tool disappoints by its generated code, the steps we have followed are still useful and valuable. You can use it to manually create the software system you wanted.
As you see, the bulk of the effort of creating an effective AI prompt comes from the developer. If the developer does not know exactly what is needed, and how to render it, the AI tool cannot help. The developer has to explain to the tool in simple terms, what is required. This is where the quote we started with is useful - to explain something in simple terms, you need to understand it really well.
This writeup was not created by GenAI. In fact, we need a logo (similar to Non-GMO Project verified) where the author self-certifies that the particular writeup was not created using AI.
Senior Staff Engineer/Senior Manager
7moExcellent article 👍