| Phenomena | Prompt engineering: controlling AI systems without programming knowledge

Prompt engineering: controlling AI systems without programming knowledge

Reading time: 5 min.

What is meant by the term prompt?

A prompt is the text that is sent to a large language model (LLM). The prompt usually contains a question or task that the LLM should answer, as well as additional information such as the desired style of response or relevant contextual information. Some applications, such as ChatGPT, use an internal prompt (also known as a system or master prompt) to calibrate the type of responses that are returned to the user.

What is prompt engineering?

Prompt engineering involves techniques that aim to control and improve the output of a language model (e.g. reduce hallucinations) without changing the internal (trained) weights of the model, i.e. that only determine the way questions are posed to the model. In principle, large language models receive a text as input and generate the most probable answer. Since LLMs are trained to follow instructions, there is always a risk that they hallucinate (i.e. generate text that does not correspond to the facts), output something logically incorrect, do not follow the instruction completely or forget part of it.

Prompt engineering can be categorised by two main aspects (or dimensions):

  1. Goal: This dimension refers to the intended goal. This includes reducing hallucinations, improving reasoning ability, adapting response style, restricting the output format or even so-called jailbreaking, where inbuilt limitations of the model are overcome to generate potentially harmful or illegal content.
  2. Implementation: This dimension deals with the methods of implementing prompt engineering.

Simple prompting techniques:

In the simplest techniques, a language model (LLM) is called only once. The entire technique is implemented directly in the prompt, for example by adding a context, a role or a few examples (so-called shots). Additional elements surround the actual task, such as adding a role “You are a helpful code assistant”, inserting a context “Your goal is to give recommendations on the maintainability of the code” or asking the LLM to explain its reasoning “Let’s think step by step” (this is the basic idea of the chain-of-thought prompting technique).

Techniques based on sampling:

In some techniques, a language model (LLM) is called several times (or several different LLMs are used) to generate slightly different responses. This is called sampling and can be achieved, for example, by adjusting the temperature parameter of the LLM. The generated responses are then collected and analysed before a final response is returned to the user. This process can be carried out once (e.g. with Self-Consistency) or several times (e.g. with Tree of Thoughts).

Integration of tools:

In certain techniques, the language model (LLM) is used to execute actions using existing tools such as a database, a search engine or a code interpreter. Once the action has been performed, the results are collected and used to generate an answer. Examples of such techniques are Retrieval Augmented Generation (RAG), ReAct and Program Aided Language Model. By using these techniques, any user can fully utilise the functionalities of AI systems, regardless of their programming skills.

Comparability with analogue phenomena

Prompt engineering can be compared with various analogue phenomena in which complex systems are controlled by simple and intuitive user interactions. A classic example is the operation of a vehicle. A driver does not need to understand how the engine, electronics or drive systems work in detail in order to control the vehicle safely and efficiently. Instead, basic knowledge and the ability to operate the right levers and pedals are sufficient. Prompt Engineering also enables users to control powerful AI models without in-depth programming knowledge. This is the art of formulating clear and precise instructions that can be understood and executed by the AI.

Another analogue phenomenon is the use of graphical user interfaces (GUI) in computers and software applications. In the past, interacting with computers often required typing complicated commands into a command line. With the introduction of GUIs, this barrier has been removed, allowing users without a technical background to operate computers efficiently. Prompt engineering pursues a similar goal by reducing the complexity of interacting with AI systems and making them more user-friendly.

Social relevance

The social relevance of Prompt Engineering is enormous. It democratises access to advanced AI technology so that a wider range of people, regardless of their technical skills, can use these tools. This fosters innovation and creativity in various fields from education and healthcare to art and business. One important aspect that should not be neglected is the high energy consumption of AI systems. Training and operating large language models requires significant amounts of computing power, which leads to high power consumption. This has a direct impact on the environment and sustainability. It is therefore important that the development and utilisation of AI technologies is also considered from an ecological perspective.