The Chain Gang of Prompt Engineering
Prompt engineering ain’t dead. Here’s how to use it.
There’s been a lot of talk about prompt engineering being dead and buried as of late. In the wake of OpenAI’s DALLE-3 release last month, outlets galore parroted the company’s line that “prompt engineering is dead”, all off the back of its text-to-image model’s ability to create better-than-average outputs out of average prompts.
Here at ACQUAINTED, we aren’t so sure. As we all know, AI models are trained using vast datasets and then fine-tuned for specific tasks, often demanding extensive computational resources — prompt engineering offers a more nuanced approach, guiding AI models to generate responses that are less prone to hallucinations and require less computational power overall.
Techniques such as Skeleton-of-Thought (SoT), Chain-of-Thought (CoT), and Chain-of-Density (CoD) are at the forefront of this transformation, steering us towards more human-like interactions with Large Language Models (LLMs) and generating better interactions as a result.
This article delves into these techniques, elucidating their differences, the mechanics behind their success, and the practicalities of their implementation. In short, this is yet another way to make GenAI’s usability challenges your competitive advantage.
Skeleton-of-Thought (SoT)
What is it?
SoT minimises generation latency in LLMs by first creating a basic "skeleton" of the answer and then elaborating on each point in parallel.
How to implement:
Start by asking the AI for a high-level overview or outline of the topic.
Once you have the skeleton, prompt the AI to elaborate on each point in detail.
Prompt: "Provide a skeleton answer about how a car engine works."
AI's Skeleton Response: "Car engine operates in cycles: intake, compression, combustion, and exhaust."
Follow-up Prompt: "Now, elaborate on each point of the skeleton in detail."
AI's Detailed Response: "In the intake stage, air and fuel enter the engine. During compression, the mixture is compressed, making it more volatile. Combustion occurs when a spark ignites the mixture, producing energy. Finally, in the exhaust stage, waste gases are expelled."
Why it works:
SoT's efficiency stems from its emulation of human thinking, which often involves laying out a basic framework before diving into specifics.
When to use it:
Ideal for scenarios demanding quick, structured AI outputs. For instance, when processing a query about British history, SoT could first provide a chronological skeleton of major events, then elaborate on each event's significance in parallel.
Chain-of-Thought (CoT)
What is it?
CoT encourages LLMs to elucidate their reasoning process sequentially, ensuring each step is based on the preceding one.
How to implement:
Ask the AI to think step by step or to explain its reasoning sequentially.
Prompt: "Walk me through the process of how plants produce oxygen using photosynthesis, step by step."
AI's CoT Response: "First, plants absorb sunlight using chlorophyll in their leaves. Next, this light energy splits water molecules, releasing oxygen in the process. The remaining components are used to produce glucose through a series of chemical reactions."
Why it works:
By making the AI articulate its reasoning, CoT not only enhances the model's accuracy but also its transparency, making its responses more comprehensible to humans.
When to Use it:
Beneficial for tasks requiring a detailed breakdown of the AI's thought process. For example, when understanding the economic implications of being in the EU, CoT could guide the AI to first outline the affected economic sectors, then delve into the specific impacts on each, following a logical chain.
Chain-of-Density (CoD)
What is it?
CoD generates summaries with varying levels of detail.
How to implement:
Start by asking the AI for a brief summary.
Then, request a denser or more detailed summary based on the initial response.
Prompt: "Give a brief summary of the British monarchy's history."
AI's Brief Response: "The British monarchy has a rich history spanning centuries."
Follow-up Prompt: "Now, provide a denser summary with more details."
AI's Denser Response: "The British monarchy, established over a millennium ago, has seen numerous dynasties from the early Plantagenets to the current House of Windsor. It has witnessed pivotal events like the Magna Carta's signing, the English Civil War, and the establishment of a constitutional monarchy."
Why it works:
Balancing informativeness and readability, CoD ensures summaries are both exhaustive and lucid.
When to Use it:
CoD is optimal for tasks requiring dense, informative summaries that remain clear and concise. For instance, when summarising a lengthy article about the British monarchy, CoD could first provide a brief overview and then a more detailed account of significant events and reigns.
Chain-of-Verification (CoVe)
What is it?
CoVe offers a method for AI to self-verify the accuracy of its responses, ensuring a higher degree of factual correctness before delivering information.
How to implement:
Initiate by asking the AI to provide a draft response.
Prompt: "Provide a draft answer about the significance of the Boston Tea Party."
AI's Draft Response: "The Boston Tea Party was a protest against British taxation policies by American colonists, marked by the dumping of British tea into Boston Harbor on December 16, 1773."
Generate verification questions to fact-check the draft.
Follow-up Prompt: "Generate verification questions."
AI's Verification Questions:
What was the main cause of the Boston Tea Party?
When did the Boston Tea Party occur?
What specific action characterized the Boston Tea Party?
Request independent answers for the verification questions.
Follow-up Prompt: "Answer the verification questions."
AI's Independent Answers:
Protest against British taxation policies.
December 16, 1773.
Dumping of British tea into Boston Harbor.
Refine the initial draft based on the verification answers.
Follow-up Prompt: "Refine the draft answer based on the verification answers."
AI's Refined Response: "The Boston Tea Party, occurring on December 16, 1773, was a protest by American colonists against British taxation policies, symbolized by the act of dumping British tea into Boston Harbor."
Why it works:
CoVe works by instigating a self-check mechanism within the AI, ensuring that the generated responses are vetted for accuracy before being presented. This method promotes a higher degree of trust and reliability in AI-generated content.
When to Use it:
CoVe is especially beneficial in scenarios where factual accuracy is paramount. It's optimal for tasks that demand the AI to provide historical facts, scientific explanations, or any other type of information where verification against factual inaccuracies is crucial. By employing CoVe, users can obtain refined and factually accurate responses, promoting a more reliable and trustworthy AI interaction.
The ongoing advent of prompt engineering techniques such as the above signifies a move towards more human-centric AI and accurate interactions that also achieve more with less computational resources. In an era where computational efficiency, explainability and AI safety are increasingly paramount, these techniques offer both a sustainable and logical path forward. Despite what many may hope for, reports of prompt engineering’s demise have been greatly exaggerated, and the chain gang isn’t bare bones just yet.
If you want to harness the power of GenAI get in touch today and we will build you safe and effective solutions that future-proof your business.