Design of prompts for use in generative AI
Written by Raúl Galán, CTO MonoM
January 11, 2024 | Artificial Intelligence | Article
Design of prompts for use in generative AI
Following the revolution brought about by the popularization of generative AIs, there is a school of thought that argues that prompt engineering is the most important skill that can be acquired and that, moreover, it can be acquired in a few hours.
What is a prompt?
Before discussing this statement, it is essential to understand the meaning of prompt engineering, which can be defined as the discipline of creating and developing instructions for conversational artificial intelligence systems. The work behind this includes understanding how these systems work and how to improve their ability to interact and communicate with users.
Basically prompts are designed in two ways:
- Interactive writing of prompts by a person in front of his or her computer.
- Writing programs that generate these prompts. This paradigm is increasingly being included under the term "RAG" (Retrieval Augmented Generation), in which a program takes a request, looks up data relevant to that request, and packages it into a complex prompt.
Writing interactive prompts may seem, and in many occasions it is, a simple task, which often provides results for small problems, although other times it can be disappointing.
On the other hand, designing automated prompting systems is challenging. It adds control over what an AI is likely to do; if you include the information needed to answer a question in the prompt and tell the AI to limit its response to the information included in that packet, it is much less likely to provide us with made-up answers or answers that have nothing to do with the subject matter. But this is a programming task that will not be learned in a few hours. It usually involves generating embeddings, using a vector database, generating a string of prompts that are responded to by different systems, combining the responses, and probably generating more prompts. Libraries such as Langchain facilitate this task, but require advanced programming skills.
It is important to note that not all prompts are created similarly. ChatGPT prompts are essentially free text. Free text sounds simple and it is, at least at first. However, other types of prompts are more detailed, and upon analysis, the reality is that they are essentially programs written in pseudocode telling the computer what to do. Prompts for an image-generating AI may include sections written in an almost formal metalanguage. It's not programming per se, but creating a prompt that produces professional-quality results is a lot like programming.
Conclusions
Therefore, the first thing anyone should learn about prompt engineering is that writing prompts is harder than it looks.
Second, while writing good interactive prompts seems like an easy goal to achieve, and one that can be useful for solving one-off problems, it is important to reflect on what a chain of thought requires, i.e., telling an AI how to solve a problem step-by-step; which implies that it is first necessary to know how to approach that problem. At times, it may be necessary to arrange or create other examples for the AI to follow, and a decision must be made as to whether the output the AI generates is correct. In short, it is necessary to really know the problem the AI is being asked to solve and the steps for solving it.
Therefore, AI tools will not eliminate programming, but will put more emphasis on higher-level activities: understanding user needs, understanding software design, understanding the relationship between components of a much larger system, and designing strategies to solve a problem. If generative AI helps us discard the idea that programming is about asocial people writing lines of code and makes us realize that it is actually about humans understanding problems and thinking about how to solve them, the programming profession may become more highly regarded.
On the other hand, to solve a problem using prompts, it is important to have a deep knowledge of the subject at hand. AI is a powerful tool that can help us perform complex tasks, but it is not a source of knowledge, it is still a tool. Those who believe that AI can replace human expertise and knowledge will never be able to take full advantage of it.
In the long run, the willingness to acquire knowledge on one's own becomes far more important than a few hours of prompts-generating knowledge acquisition. Turning to AI as a shortcut to bypass learning is a big step toward obsolescence. The key to staying relevant in the AI era lies in the desire and motivation to constantly learn.