Image created with DALL-E3
artificial intelligence has brought about a complete revolution in the technological world.
Their ability to mimic human intelligence and perform tasks once considered exclusively human domains still amazes most of us.
However, no matter how good these latest ai advances have been, there is always room for improvement.
And this is precisely where rapid engineering comes into play!
Enter this field that can significantly improve the productivity of ai models.
Let’s all find out together!
Rapid engineering is a rapidly growing domain within ai that focuses on improving the efficiency and effectiveness of language models. It’s about creating perfect cues to guide ai models and produce the desired results.
Think of it as learning how to give better instructions to someone to ensure they understand and execute a task correctly.
Why rapid engineering is important
- Improved Productivity: By using high-quality prompts, ai models can generate more accurate and relevant responses. This means less time spent on fixes and more time leveraging the capabilities of ai.
- Cost efficiency: Training ai models is resource-intensive. Rapid engineering can reduce the need for retraining by optimizing model performance through better cues.
- Versatility: Well-crafted messaging can make ai models more versatile, allowing them to address a broader range of tasks and challenges.
Before we dive into the more advanced techniques, let’s remember two of the most useful (and basic) rapid engineering techniques.
Sequential Thinking with “Let’s think step by step”
Nowadays it is well known that the accuracy of LLM models is significantly improved by adding the word sequence “Let’s think step by step”.
Why… you might ask?
Well, this is because we are forcing the model to divide any task into multiple steps, thus ensuring that the model has enough time to process each of them.
For example, you could challenge GPT3.5 with the following message:
If John has 5 pears, then eats 2, buys 5 more, and then gives 3 to his friend, how many pears does he have?
The model will give me an answer immediately. However, if I add the ending “Let’s think step by step”, I am forcing the model to generate a thought process with multiple steps.
Few shot indications
While zero-shot prompting refers to asking the model to perform a task without providing any context or prior knowledge, the low-shot prompting technique involves us presenting the LLM with some examples of our desired outcome along with some specific question.
For example, if we want to come up with a model that defines any term using a poetic tone, it can be quite difficult to explain. Good?
However, we could use the following indications from some shots to steer the model in the direction we want.
Your task is to respond in a consistent style aligned with the following style.
: Teach me about resilience.
: Resilience is like a tree that bends in the wind but never breaks.
It is the ability to recover from adversity and continue moving forward.
: Your entry here.
If you haven’t tried it yet, you can challenge GPT.
However, since I’m pretty sure most of you already know these basic techniques, I’ll try to challenge you with some advanced techniques.
1. Chain of Thought Prompt (CoT)
Presented by Google in 2022This method involves ordering the model to go through several stages of reasoning before delivering the final answer.
Sounds familiar right? If so, you are absolutely right.
It’s like merging sequential thinking and brief prompts.
As?
Basically, CoT prompts direct the LLM to process information sequentially. This means that we model how to solve a first problem with multi-step reasoning and then send the model our real task, expecting it to emulate a comparable chain of thought in answering the real query we want it to solve.
Image taken from the paper.
So, following the first example, we could provide a message with the first problem and a sequential explanation of how to solve it. Then we can submit our feedback and watch the magic happen.
If John has 5 pears, then eats 2, buys 5 more, and then gives 3 to his friend, how many pears does he have? Let’s think step by step.
Let’s go step by step. John starts with 5 pears. He eats 2 pears, so he has 5–2 = 3 pears left. Then he buys 5 more pears. So now he has 3 + 5 = 8 pears. Finally he gives 3 pears to his friend. Therefore, you are left with 8–3 = 5 pears. So after all these steps, John has 5 pears.
Your entry here.
However, most of you must be thinking… Do I have to think of a sequential way to solve any problem every time I want to ask something on ChatGPT?
Well… you’re not the first! And this brings us to…
2. Automatic Chain of Thought (Auto-CoT)
In 2022, zhang and colleagues introduced a method to avoid this manual process. There are two main reasons to avoid any manual tasks:
- It can be boring.
- It can produce bad results, for example, when our mental processes are incorrect.
They suggested using LLM combined with the message “Let’s think step by step” to sequentially produce chains of reasoning for each proof.
This means asking ChatGPT how to solve any problem sequentially and then using this same example to train it how to solve any other problem.
3. Self-consistency
Self-consistency is another interesting stimulation technique that aims to improve the chain of thought that leads to more complex reasoning problems.
So… what is the main difference?
The main idea of self-consistency is to be aware that we can train the model with a wrong example. Imagine that I solve the above problem with an incorrect mental process:
If John has 5 pears, then eats 2, buys 5 more, and then gives 3 to his friend, how many pears does he have? Let’s think step by step.
Start with 5 pears. John eats 2 pears. Then he gives 3 pears to his friend. These actions can be combined: 2 (meals) + 3 (dice) = 5 pears total affected. Now, subtract the total number of affected pears from the initial 5 pears: 5 (initial) – 5 (affected) = 0 remaining pears.
Then any other tasks you send to the model will be incorrect.
That’s why self-consistency involves sampling several paths of reasoning, each containing a chain of thought, and then letting the LLM choose the best, most consistent path to solve the problem.
Image taken from the ai” rel=”noopener” target=”_blank”>paper
In this case, and again following the first example, we can show the model different ways to solve the problem.
If John has 5 pears, then eats 2, buys 5 more, and then gives 3 to his friend, how many pears does he have?
Start with 5 pears. John eats 2 pears, which leaves him with 5–2 = 3 pears. He buys 5 more pears, bringing the total to 3 + 5 = 8 pears. Finally, he gives 3 pears to his friend, so he has 8–3 = 5 pears left.
If John has 5 pears, then eats 2, buys 5 more, and then gives 3 to his friend, how many pears does he have?
Start with 5 pears. Then buy 5 more pears. John eats 2 pears now. These actions can be combined: 2 (eaten) + 5 (purchased) = 7 pears in total. Subtract the pear Jon has eaten from the total number of pears 7 (total amount) – 2 (eaten) = 5 pears left.
Your entry here.
And here comes the last technique.
4. General knowledge tips
A common rapid engineering practice is to augment a query with additional knowledge before submitting the final API call to GPT-3 or GPT-4.
According ai” rel=”noopener” target=”_blank”>Jiacheng Liu and companyWe can always add some knowledge to any request so that the LLM knows the question better.
Image taken from the ai” rel=”noopener” target=”_blank”>paper.
So, for example, when we ask ChatGPT if one part of golf tries to get a higher point total than others, it will validate us. But the main objective of golf is quite the opposite. This is why we can add some prior knowledge by saying “The player with the lowest score wins.”
So… what’s the fun part if we tell the model exactly the answer?
In this case, this technique is used to improve the way LLM interacts with us.
So rather than extracting supplementary context from an external database, the article’s authors recommend that the LLM produce its own knowledge. This self-generated knowledge is then integrated into the message to reinforce common sense reasoning and deliver better results.
This is how you can improve LLMs without increasing your training data set!
Rapid engineering has become a fundamental technique for improving LLM capabilities. By iterating and improving cues, we can communicate more directly with ai models and obtain more accurate and contextually relevant results, saving time and resources.
For technology enthusiasts, data scientists, and content creators, understanding and mastering rapid engineering can be a valuable asset in realizing the full potential of ai.
By combining carefully designed input cues with these more advanced techniques, having the skill set of cues engineering will certainly give you an advantage for years to come.
Joseph Ferrer He is an analytical engineer from Barcelona. He graduated in physical engineering and currently works in the field of Data Science applied to human mobility. He is a part-time content creator focused on data science and technology. You can contact him at LinkedIn, Twitter either Half.